Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

matchTemplate Resultspace

Hello everyone, in the matchTemplate function there is a picture illustrating the slinding-window-approach (the one with the two black arrows). First of all: as I understand the code, the coordinates in this pictures are not right, are they? I came to this assumption, because the result-variable contains the match between left upper corner from template with left upper corner from queryimage (not the center of template with left upper corner from query as shown in the picture). If this is correct it means that the whole template has to fit on the searchimage. A situation as shown (half dogs had correlate to nothing) is not possible. Could someone confirm this assumption, please?

I also worked with the matlab version of the normalized cross-correlation normxcorr2. In this function the result space is in the dimensions of (rows.template + rows.query +1) x (cols.template + cols.query +1). Can you give me a hint, if or how such an output is possible as well with openCV? could adding a black boarder do the trick?

matchTemplate Resultspace

Hello everyone, in the matchTemplate function there is a picture illustrating the slinding-window-approach (the one with the two black arrows). First of all: as I understand the code, the coordinates in this pictures are not right, are they? I came to this assumption, because the result-variable contains the match between left upper corner from template with left upper corner from queryimage (not the center of template with left upper corner from query as shown in the picture). If this is correct it means that the whole template has to fit on the searchimage. A situation as shown (half dogs had correlate to nothing) is not possible. possible. Could someone confirm this assumption, please?please?
edit: see berak's post. I also did an example with should explain the situation: see the pictures below where I used berak's suggested cv::copyMakeBorder. This solution leads me to the following Question: What kind of borders seems to be the more general sultion? A black or a borderInterpolate?

I also worked with the matlab version of the normalized cross-correlation normxcorr2. In this function the result space is in the dimensions of (rows.template + rows.query +1) x (cols.template + cols.query +1). Can you give me a hint, if or how such an output is possible as well with openCV? could adding a black boarder border do the trick? -> it does see the pictures

Template matching without border Template matching with border Template

matchTemplate Resultspace

Hello everyone, in the matchTemplate function there is a picture illustrating the slinding-window-approach (the one with the two black arrows). First of all: as I understand the code, the coordinates in this pictures are not right, are they? I came to this assumption, because the result-variable contains the match between left upper corner from template with left upper corner from queryimage (not the center of template with left upper corner from query as shown in the picture). If this is correct it means that the whole template has to fit on the searchimage. A situation as shown (half dogs had correlate to nothing) is not possible. Could someone confirm this assumption, please?
edit: see berak's @berak 's post. I also did an example with should explain the situation: see the pictures below where I used berak's suggested cv::copyMakeBorder. This solution leads me to the following Question: What kind of borders seems to be the more general sultion? A black or a borderInterpolate?

I also worked with the matlab version of the normalized cross-correlation normxcorr2. In this function the result space is in the dimensions of (rows.template + rows.query +1) x (cols.template + cols.query +1). Can you give me a hint, if or how such an output is possible as well with openCV? could adding a black border do the trick? -> it does see the pictures

Template matching without border Template matching with border Template

matchTemplate ResultspaceResultspace Padding

Hello everyone, in the matchTemplate function there is a picture illustrating the slinding-window-approach (the one with the two black arrows). First of all: as I understand the code, the coordinates in this pictures are not right, are they? I came to this assumption, because the result-variable contains the match between left upper corner from template with left upper corner from queryimage (not the center of template with left upper corner from query as shown in the picture). If this is correct it means that the whole template has to fit on the searchimage. A situation as shown (half dogs had correlate to nothing) is not possible. Could someone confirm this assumption, please?
edit: see @berak 's post. I also did an example with should explain the situation: see the pictures below where I used berak's suggested cv::copyMakeBorder. This solution leads me to the following Question: What kind of borders seems to be the more general sultion? A black or a borderInterpolate?

I also worked with the matlab version of the normalized cross-correlation normxcorr2. In this function the result space is in the dimensions of (rows.template + rows.query +1) x (cols.template + cols.query +1). Can you give me a hint, if or how such an output is possible as well with openCV? could adding a black border do the trick? -> it does see the pictures

Template matching without border Template matching with border Template