0
$\begingroup$

Lets say. I have an image of 100 samples, and I want to find the presence of smaller image of 24 sample using cross-correlation in the fourier domain. I use Bartlett's and Welch's method for PSD, where I split up the original 100 samples into 4 segments of 25 samples.

Now I want to find the maximum or peak response,

Do I look at all 4 segments to find the maximum response?

$\endgroup$
  • 1
    $\begingroup$ One thing you should do is to prewhiten your image and patch. If you have the processing power and memory, compare the patch over the whole image, not partitions of it. $\endgroup$ – Peter K. Sep 14 '15 at 0:11
  • $\begingroup$ Thanks for the info, but I am not too concerned on where the image is as of yet. Moreover I am concerned with if the smaller image is present in the larger image. $\endgroup$ – IkeJoka Sep 14 '15 at 0:20
  • $\begingroup$ Prewhitening will also help with detection (presence / absence) as well as localization. $\endgroup$ – Peter K. Sep 14 '15 at 0:21
  • $\begingroup$ Oh okay thanks, I will definitely keep that in mind. Do you by any chance have answer to my aforementioned question perhaps? $\endgroup$ – IkeJoka Sep 14 '15 at 0:30
  • $\begingroup$ Just working on an answer... give me a bit. :-) $\endgroup$ – Peter K. Sep 14 '15 at 0:43
1
$\begingroup$

This is just a 1D example that shows the idea (I can't seem to get scilab to cooperate with real images; at least not yet).

The top plot in blue shows the "image". The "patch" is indicated by the red dots. I've selected the location of the "patch" randomly throughout the "image".

The bottom plot shows the cross-correlation between the patch and the image (in green), and the red dot indicates the actual location (start position) of the patch.

The code below does no prewhitening because the "image" is generated using white noise. Apart from the mean-correction, that is.

enter image description here

// 25803
clf;
NIM = 100;
IM = rand(1,NIM,"uniform");
IM = (IM - min(IM))/(max(IM) - min(IM))*255;
subplot(211)
plot(IM)

NPT = 24;
idx = ceil(rand(1,1,"uniform")*75);
PT = IM(idx + [0:NPT-1]);
plot(idx+[0:NPT-1],PT,'r.')
title('Original and patch')
NFFT = NIM + NPT - 1;

IMFFT = fft([IM-mean(IM),zeros(1,NPT-1)]);
PTFFT = fft([PT-mean(PT),zeros(1,NIM-1)]);

subplot(212)
CORR = ifft(IMFFT.*conj(PTFFT));
plot(CORR,'g')
plot(idx,CORR(idx),'r.')
title('Cross correlation and actual patch position')
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.