normalized 2D cross correlation

9 次查看(过去 30 天)
I am trying to utilize the c=normxcorr2(template,A) function for two surface plots and I am running into the following errors;
??? Error using ==> iptcheckinput Function NORMXCORR2 expected its second input, A, to be finite.
Error in ==> normxcorr2>ParseInputs at 232 iptcheckinput(A,{'logical','numeric'},{'real','nonsparse','2d','finite'},mfilename,'A',2)
Error in ==> normxcorr2 at 55 [T, A] = ParseInputs(varargin{:});
Both matrices are the Z coordinates for the plots and and I can find the template in A and yes A is bigger than template. Matrix A is 427x249 and template is 299x149. The elements in both matrices range from -50 to +75 and also have NaN as fill elements.
I was wondering if someone knows whether it is appropriate to use this function for such manipulation if not can you help me to perform the 2D cross correlation for two surface plots?
Thanks, Shayan

采纳的回答

Sean de Wolski
Sean de Wolski 2011-9-6
No. normxcorr2 requires that the elements be finite, i.e. not nan and not inf. The normalized cross correlation algorithm is not a difficult one ( wikipedia:normalized X-correlation )
I would recommend coding it yourself using functions that ignore nans ( nansum, nanmean, nanstd ). If you don't have the stats toolbox that contains these there is a nan-suite on the FEX.
  2 个评论
Shayan
Shayan 2011-9-6
Sean,
I saw your comment for normalized 2D cross correlation with rotation after I posted this question;
http://www.mathworks.com/matlabcentral/answers/3252-normalized-cross-correlation-with-rotated-images
I looked at the link you sent over there. Do you know if I can use that "Automatic 2d Rigid Body Image Registration" tool for my case?
So I have this surface plots and I need to over lay them. I have to do cross correlation in;
x
y
z
and rotation about z
Do you know of any function, script or tool box that can do this? I transferred my surface plots into gray scale image and used the image processing tool box in matlab but the result wasn't that pleasing.
If I have to I will write these functions myself but for now I am trying to prevent myself from reinventing the wheel.
Thanks,
Shayan
Sean de Wolski
Sean de Wolski 2011-9-7
2d x-correlation is what you wanted above. So you're expecting there to be a rotation about the z-axis and to recover the x/y translations correct?

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Surface and Mesh Plots 的更多信息

产品

Community Treasure Hunt

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

Start Hunting!

Translated by