How to exclude points when calculating the normalized cross correlation coefficients with normxcorr2?

2 次查看(过去 30 天)
I am using the normalized cross correlation coefficients function; normxcorr2(template, A)
to to compute the normalized cross correlation coefficients. My two images have been gathered with microscope and bright white pixels(FillValue 1) represent no data. Is there a way I could utilize the normxcorr2 to get the normalized cross correlation coefficients for all pixels but excluding the bright white ones?
Thanks, Shayan

回答(3 个)

Image Analyst
Image Analyst 2011-7-15
Perhaps you can set the bad pixels to NaN - MATLAB often seems to harmlessly ignore such values when it does computations.
  2 个评论
Sean de Wolski
Sean de Wolski 2011-7-15
That won't work because it expects the template to be finite:
A = magic(3);
B = padarray(magic(3),[10 10])
A(5) = nan
normxcorr2(A,B)
??? Error using ==> iptcheckinput
Function NORMXCORR2 expected its first input, T, to be finite.
Error in ==> normxcorr2>ParseInputs at 231
iptcheckinput(T,{'logical','numeric'},{'real','nonsparse','2d','finite'},mfilename,'T',1)
Error in ==> normxcorr2 at 55
[T, A] = ParseInputs(varargin{:});

请先登录,再进行评论。


Sean de Wolski
Sean de Wolski 2011-7-15
I think I would start by creating a second image with the bright white pixels interpolated over.
MORE
nxcorr formula
It should be easy enough to implement this formula using nanmean, nanstd, and nansum (either with stats toolbox or available here: fex:nan_suite. Slide the template over every possible combination using double- for-loops; calculate the nxcorr and then find the highest value.
  1 个评论
Shayan
Shayan 2011-7-15
I can't do interpolation for percision reseans. Otherwise interpolation is the way to go. I actually tried it and i get the cross correlation coefficient to be almost 1.

请先登录,再进行评论。


bart
bart 2013-5-29
Hellò, I have a similar problem. I cannot use an interpolation solution for precision reason too. Anyone could post a nannormxcorr2 function? I'm neophyte with matlab and i've some difficult to modify normxcorr2.. I tried modifying with nanmean, nanstd, nansum, nancumsum, conv2nan etc.. but it doesn't work. I suppose that is not so simple.
Thanks, Berto.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by