numpy - Need explanation about results produced from Python's sci-kit template matching library -


edit:

template url: http://c.nordstromimage.com/assets/idev/common/00-00-00-free-shipping-evergreen-cid0330153898-7-adam-a4c331d8-38ab-4337-baf9-a46801899b3e-fil-file.png?version=1

image url:http://shop.nordstrom.com/

i read through sample tutorial here on template matching. template matching technique used identify/locate small patch image (aka "template") within larger image. , here easy-to-read documentation explaining input/outputs using template_matching library in python.

now here question. output of template_matching library supposed numpy array consisting of correlation coefficient values. these coefficients supposed values between -1.0 , 1.0 have values > 1.0 in output array. below code using (it's same 1 provided in tutorial):

def template_match(self):      #self.main_image screenshot of [this](http://shop.nordstrom.com/) webpage taken in selenium     #self.template [this](http://c.nordstromimage.com/assets/idev/common/00-00-00-free-shipping-evergreen-cid0330153898-7-adam-a4c331d8-38ab-4337-baf9-a46801899b3e-fil-file.png?version=1)  image      image = rgb2gray(imread(self.main_image))     template = rgb2gray(imread(self.template))      result = match_template(image, template) #call scikit library here      ij = np.unravel_index(np.argmax(result), result.shape)     x, y = ij[::-1] #coordinate positions       h_template, w_template = template.shape #height , width of image     aspect_ratio = float(w_template)/float(h_template)     confidence = np.amax(result)      self.log.info(self.template_url)     self.log.info('template coordinates: {0}, {1}'.format(x, y))     self.log.info('image width x height pixel size: {0} || template width x height pixel size: {1}'.format(image.shape[::-1], template.shape[::-1]))     self.log.info('aspect ratio: {0}'.format(aspect_ratio))     self.log.info('confidence-level: {0}\n'.format(confidence))      #filter out images low confidence-levels      if confidence < self.min_confidence:          return      #here confused, according docs, result should array of values between -1.0 , 1.0, yet values > 1     elif confidence > 1:         self.log.info('why confidence value > 1.0? url: {0}'.format(self.template_url))         return      return 

what trying here keep values correlation coefficient (in case, called "confidence") above threshold, specified self.min_confidence, , reject below threshold. yet reason, template images (such 1 in example) produce correlation coefficient > 1. going on here?


Comments

Popular posts from this blog

jquery - How do you format the date used in the popover widget title of FullCalendar? -

asp.net mvc - SSO between MVCForum and Umbraco7 -

Python Tkinter keyboard using bind -