Hi, I am currently implementing an algorithm of segmentation based on flow orientation, and one of the equations in the paper uses autocorrelation and crosscorrelation of image gradient.
The code runs fine, but when I try to reshape the final values into a matrix with same dimension as the input image, I receive error. The following is my code:
close allx = imread(imfile);x = im2double(x);%%Gradient - orientation estimate
[Gx,Gy] = imgradientxy(x);gxx = xcorr2(Gx(:,:));gyy = xcorr2(Gy(:,:));gxy = xcorr2(Gx(:,:), Gy(:,:));angle = 0.5.*atan((2.*gxy)./(gxx - gyy)); % Equation 4
temp = (angle< 0);angle(temp) = angle(temp) + 2.*pi; % angle within 0 to 2pi
angle = angle / pi *180;
Equation 4:
I spent some time looking at the length of each entry, and it turned out that all the values after processing by corr2 are double of the initial size; i.e.
input_image = 450 x 369
gx (after imgradientxy) = 450 x 450
gxx = 899 x 750
angle = 899 x 737
My questions:
1) How to make the matrix after autocorrelation & cross correlation same as the initial image dimension?
2) Why is there a difference in the matrix dimension after processing by imgradientxy ?
Any help would be greatly appreciated, thanks!
Best Answer