[EDIT: 20110524 09:49 CDT – reformat – WDR]
I have been trying to implement object based phase correlation tracking to track birds in my images….and there are some issues with my code…On running the code I got these errors which are quite clear that they is something wrong with the code I wrote to perform erosion…
% To implement Correlation Tracking
%Author: Harsha Vardhan Rao Avunoori
%Steps to implement Correlation 1.Load Images 2.Convert into Gray Scale
%3.Perform FFT on images 4.Convolve Images 5.Post Processing stage which
%includes Median Filtering Dilation and Erosion
%Loading Input Image
a = imread('img_9.jpg');figure(1)imshow(a)%Loading Target Image
b = imread('img_11.jpg');figure(2)imshow(b)size(a)size(b)%RGB2GRAY conversion of input image
i = rgb2gray(a);[r c] = size(i);figure(3)imshow(i)size(i)%RGB2GRAY conversion of target image
p=rgb2gray(b);figure(4)imshow(p)%Performing FFT of input image and target image
img_i = fft2(i);img_p=fft2(p);figure(5)plot(img_i)figure(6)plot(img_p)img_f = zeros(r,c);%Multiplying the FFT of Input and Target Images
for i=1:r for j= 1:c img_f(i,j) = img_i(i,j).*img_p(i,j); end endimg_if = zeros(r,c);%Perfrom inverse FFT on multiplied image
for i=1:r for j=1:c img_if(i,j) = ifft2(img_f(i,j)); endendfigure(7)imshow(img_if)img_if1 = zeros(r,c);%Perform Median filtering using medfilt2 for a 3 x 3 neighborhood
%Point to note is medfilt2 is not accepting complex values so I took
%abs(img_if) to make it a real value
img_if1 = medfilt2(abs(img_if),[3 3]);figure(8)imshow(img_if1)%Perform Erosion using imerode function
%Never tried erosion before so took a simple strel
z = ones(4,4)SE = strel(z)img_ero=imerode(img_if1,'SE');%Something is wrong erosion gives out an error
figure(9)imshow(img_ero)%Perform Dilation using imdilate function
h = eye(5)SE = strel(h)img_dil=imdilate(img_ero,'SE');figure(10)imshow(img_dil)
Errors after executing the code
??? Error using ==> strelcheck at 19Function imerode expected its second input argument, SE, to be either numeric or logical.Error in ==> morphop>ParseInputs at 165se = strelcheck(se,func_name,'SE',2);Error in ==> morphop at 14[A,se,pre_pad,...Error in ==> imerode at 123B = morphop(A,se,'erode',mfilename,varargin{:});Error in ==> Test2 at 81img_ero=imerode(img_if1,'SE');
What might be the problem ?? Any help would be appreciated…
Best Answer