Python cv2.max() Examples

The following are 6 code examples of cv2.max(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module cv2 , or try the search function .
Example #1
Source File: pySaliencyMap.py    From pliers with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
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 
Example #2
Source File: pySaliencyMap.py    From aim with MIT License 6 votes vote down vote up
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 
Example #3
Source File: trackManager.py    From crazyflieROS with GNU General Public License v2.0 5 votes vote down vote up
def setMaxDepth(self, m=4.5):
        """ Sets max considered depth """
        self.maxDepth = m 
Example #4
Source File: BloodVessels.py    From Diabetic-Retinopathy-Feature-Extraction-using-Fundus-Images with GNU General Public License v3.0 5 votes vote down vote up
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 
Example #5
Source File: CheckNight.py    From RMS with GNU General Public License v3.0 5 votes vote down vote up
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 
Example #6
Source File: CheckNight.py    From RMS with GNU General Public License v3.0 4 votes vote down vote up
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