當前位置: 首頁>>代碼示例>>Python>>正文


Python cv2.max方法代碼示例

本文整理匯總了Python中cv2.max方法的典型用法代碼示例。如果您正苦於以下問題:Python cv2.max方法的具體用法?Python cv2.max怎麽用?Python cv2.max使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在cv2的用法示例。


在下文中一共展示了cv2.max方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: CFMGetFM

# 需要導入模塊: import cv2 [as 別名]
# 或者: from cv2 import max [as 別名]
def CFMGetFM(self, R, G, B):
        # max(R,G,B)
        tmp1 = cv2.max(R, G)
        RGBMax = cv2.max(B, tmp1)
        RGBMax[RGBMax <= 0] = 0.0001    # prevent dividing by 0
        # min(R,G)
        RGMin = cv2.min(R, G)
        # RG = (R-G)/max(R,G,B)
        RG = (R - G) / RGBMax
        # BY = (B-min(R,G)/max(R,G,B)
        BY = (B - RGMin) / RGBMax
        # clamp nagative values to 0
        RG[RG < 0] = 0
        BY[BY < 0] = 0
        # obtain feature maps in the same way as intensity
        RGFM = self.FMGaussianPyrCSD(RG)
        BYFM = self.FMGaussianPyrCSD(BY)
        # return
        return RGFM, BYFM
    # orientation feature maps 
開發者ID:tyarkoni,項目名稱:pliers,代碼行數:22,代碼來源:pySaliencyMap.py

示例2: CFMGetFM

# 需要導入模塊: import cv2 [as 別名]
# 或者: from cv2 import max [as 別名]
def CFMGetFM(self, R, G, B):
        # max(R,G,B)
        tmp1 = cv2.max(R, G)
        RGBMax = cv2.max(B, tmp1)
        RGBMax[RGBMax <= 0] = 0.0001 # Prevent dividing by 0
        # min(R,G)
        RGMin = cv2.min(R, G)
        # RG = (R-G)/max(R,G,B)
        RG = (R - G) / RGBMax
        # BY = (B-min(R,G)/max(R,G,B)
        BY = (B - RGMin) / RGBMax
        # clamp nagative values to 0
        RG[RG < 0] = 0
        BY[BY < 0] = 0
        # Obtain feature maps in the same way as intensity
        RGFM = self.FMGaussianPyrCSD(RG)
        BYFM = self.FMGaussianPyrCSD(BY)

        return RGFM, BYFM


    # Orientation feature maps 
開發者ID:aalto-ui,項目名稱:aim,代碼行數:24,代碼來源:pySaliencyMap.py

示例3: setMaxDepth

# 需要導入模塊: import cv2 [as 別名]
# 或者: from cv2 import max [as 別名]
def setMaxDepth(self, m=4.5):
        """ Sets max considered depth """
        self.maxDepth = m 
開發者ID:omwdunkley,項目名稱:crazyflieROS,代碼行數:5,代碼來源:trackManager.py

示例4: applyKirschFilter

# 需要導入模塊: import cv2 [as 別名]
# 或者: from cv2 import max [as 別名]
def applyKirschFilter(self):
        gray = self.curImg
        if gray.ndim > 2:
            raise Exception("illegal argument: input must be a single channel image (gray)")
        kernelG1 = np.array([[ 5,  5,  5],
                             [-3,  0, -3],
                             [-3, -3, -3]], dtype=np.float32)
        kernelG2 = np.array([[ 5,  5, -3],
                             [ 5,  0, -3],
                             [-3, -3, -3]], dtype=np.float32)
        kernelG3 = np.array([[ 5, -3, -3],
                             [ 5,  0, -3],
                             [ 5, -3, -3]], dtype=np.float32)
        kernelG4 = np.array([[-3, -3, -3],
                             [ 5,  0, -3],
                             [ 5,  5, -3]], dtype=np.float32)
        kernelG5 = np.array([[-3, -3, -3],
                             [-3,  0, -3],
                             [ 5,  5,  5]], dtype=np.float32)
        kernelG6 = np.array([[-3, -3, -3],
                             [-3,  0,  5],
                             [-3,  5,  5]], dtype=np.float32)
        kernelG7 = np.array([[-3, -3,  5],
                             [-3,  0,  5],
                             [-3, -3,  5]], dtype=np.float32)
        kernelG8 = np.array([[-3,  5,  5],
                             [-3,  0,  5],
                             [-3, -3, -3]], dtype=np.float32)
    
        g1 = cv2.normalize(cv2.filter2D(gray, cv2.CV_32F, kernelG1), None, 0, 255, cv2.NORM_MINMAX, cv2.CV_8UC1)
        g2 = cv2.normalize(cv2.filter2D(gray, cv2.CV_32F, kernelG2), None, 0, 255, cv2.NORM_MINMAX, cv2.CV_8UC1)
        g3 = cv2.normalize(cv2.filter2D(gray, cv2.CV_32F, kernelG3), None, 0, 255, cv2.NORM_MINMAX, cv2.CV_8UC1)
        g4 = cv2.normalize(cv2.filter2D(gray, cv2.CV_32F, kernelG4), None, 0, 255, cv2.NORM_MINMAX, cv2.CV_8UC1)
        g5 = cv2.normalize(cv2.filter2D(gray, cv2.CV_32F, kernelG5), None, 0, 255, cv2.NORM_MINMAX, cv2.CV_8UC1)
        g6 = cv2.normalize(cv2.filter2D(gray, cv2.CV_32F, kernelG6), None, 0, 255, cv2.NORM_MINMAX, cv2.CV_8UC1)
        g7 = cv2.normalize(cv2.filter2D(gray, cv2.CV_32F, kernelG7), None, 0, 255, cv2.NORM_MINMAX, cv2.CV_8UC1)
        g8 = cv2.normalize(cv2.filter2D(gray, cv2.CV_32F, kernelG8), None, 0, 255, cv2.NORM_MINMAX, cv2.CV_8UC1)
        magn = cv2.max(g1, cv2.max(g2, cv2.max(g3, cv2.max(g4, cv2.max(g5, cv2.max(g6, cv2.max(g7, g8)))))))
        self.curImg = magn 
開發者ID:ebdulrasheed,項目名稱:Diabetic-Retinopathy-Feature-Extraction-using-Fundus-Images,代碼行數:41,代碼來源:BloodVessels.py

示例5: make_long_frames

# 需要導入模塊: import cv2 [as 別名]
# 或者: from cv2 import max [as 別名]
def make_long_frames(self):
      # Start the image producer
      self.imageQueue = queue.Queue(maxsize=2)
      self.imageProducer = ImageProducer("Producer", self.imageQueue)
      self.imageProducer.start()
      self.max_index = 0

      try:
         self.max_image = self.imageQueue.get(timeout = QUEUE_TIMEOUT)
         while True:
            # Get the next image from the queue and update the max
            self.im = self.imageQueue.get(timeout = QUEUE_TIMEOUT)
            cv2.max(self.im, self.max_image, self.max_image)

            self.max_index += 1

            # Write a long image
            if self.max_index >= NUM_LONG_MAX_IMAGES:
               self.max_index = 0
               cv2.imwrite(("long-" + self.imageProducer.get_currentimagefilename()), self.max_image)
               self.max_image.fill(0)

      except:
         cv2.imwrite(("long-" + self.imageProducer.get_currentimagefilename()), self.max_image)
         print("Exception checking file ", sys.exc_info()[0])
         self.finish()


# Main program 
開發者ID:CroatianMeteorNetwork,項目名稱:RMS,代碼行數:31,代碼來源:CheckNight.py

示例6: check_key

# 需要導入模塊: import cv2 [as 別名]
# 或者: from cv2 import max [as 別名]
def check_key(self):
      self.key_pressed64 = cv2.waitKey(1) & 0xffff
      self.key_pressed = self.key_pressed64 & 0xff
      # if self.key_pressed64 != 255: print(hex(self.key_pressed64))
      if (self.key_pressed64 < 0 or self.key_pressed64 == 255): return    # No key pressed
      elif(self.key_pressed == 0x1b) or (self.key_pressed == 0x71): # <Esc> or q key
         self.finish()
      elif (self.key_pressed == 0x72):  # 'r' reset
         self.short_max_im8u.fill(0)
      elif (self.key_pressed == 0x0A):  # 'Enter' key - pause and reset
         self.pause = not self.pause
         self.short_max_im8u.fill(0)
      elif (self.key_pressed == 0x73): # 's' key - save image
         cv2.imwrite(self.named_image.image_name + "-saved.png", self.short_max_im8u)
         print("Saved image: ", self.named_image.image_name + "-saved.png")
      elif (self.key_pressed == 0x20): # space key - pause
         self.pause = not self.pause
         self.single_step = False
      elif (self.key_pressed == 0x6d): # m key - toggle max pixel display
         self.short_max_im8u.fill(0)
         self.show_max = not self.show_max
      elif (self.key_pressed64 == 0x055): # pgup arrow - rewind 100 frames
         self.short_max_im8u.fill(0)
         self.imageProducer.move_index(-100)
         self.clear_queue()
         self.pause = False
      elif (self.key_pressed64 == 0x056): # pgdown arrow - forward 300 frames
         self.short_max_im8u.fill(0)
         self.imageProducer.move_index(300)
         self.clear_queue()
         self.pause = False
      elif (self.key_pressed == 65361) or (self.key_pressed64 == 0x051): # left arrow - rewind 100 frames
         self.short_max_im8u.fill(0)
         self.imageProducer.move_index(-100)
         self.clear_queue()
         self.pause = False
      elif (self.key_pressed == 65363) or (self.key_pressed64 == 0x053): # right arrow - forward 100 frames
         self.short_max_im8u.fill(0)
         self.imageProducer.move_index(100)
         self.clear_queue()
         self.pause = False
      elif (self.key_pressed == 65362) or (self.key_pressed64 == 0x052): # up arrow - flip display frame
         self.short_max_im8u.fill(0)
         self.flip = not self.flip
      elif (self.key_pressed == 0x63): # 'c' key - change contrast
         if len(self.display_image) == 3:
            cv2.imshow("CheckNight", cv2.resize(self.clahe.apply(cv2.cvtColor(self.display_image, cv2.COLOR_RGB2GRAY)), (0,0), fx=self.scale, fy=self.scale))
         else:
            cv2.imshow("CheckNight", cv2.resize(self.clahe.apply(self.display_image), (0,0), fx=self.scale, fy=self.scale))
         self.contrast = not self.contrast
         self.pause = True
      #elif (self.key_pressed == 0x76): # 'v' key to view latest frame using eog
      #   try:
      #      os.system ('eog ' + self.named_image.image_name)
      #   except:
      #      print("Unable to view image")
      elif (self.key_pressed == 0x2e): # '.' key to single step
         self.single_step = True
         self.pause = False 
開發者ID:CroatianMeteorNetwork,項目名稱:RMS,代碼行數:61,代碼來源:CheckNight.py


注:本文中的cv2.max方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。