---------------------------------------------------------------------------------
imdilate is a local maximum operation. imerode is a local min.
imopen is imerode followed by imdilate. imclose is imdilate followed
by imerode.
Have a next of 4 for loops. Basic process:
halfWindow = windowSize/2;
for col = 1:lastColumn
for row = 1:lastRow
for x=(col-halfWindow ):(col+halfWindow )
for y = (row-halfWindow ):(row+halfWindow )
% Look for max or min in the window centered around (row,
col) using standard techniques.
end
end
end
end
That's basically kind of it. You need to tweak the indexes to make
sure you're not going outside the image, handle edge conditions, and
things like that but I think you get the basic idea. You can also see
if it's faster to have the columns or rows be the outermost loop
(probably it will be the columns since I htink MATLAB goes down rows
in a single column first before moving to the next column). You could
also replace the inner 2 for's with standard indexing and a mean(mean
()) statement if you wanted to.
Good luck,
ImageAnalyst
---------------------------------------------------------------------------
I'm not sure what you don't understand. Is it that you don't
understand how to get iterate over a 3 by 3 window looking for the
largest value?
Beside coding from scratch, you can find the the link ready-in-the-cane functions
http://www.mathworks.com/matlabcentral/fileexchange/24705
You need to be able to compile MEX.
Bruno
IM=imread('paint.bmp');
Image=im2bw(IM);
Se = ones(3,2);
Ap = [2,2];Method=('binary');
Isize=size(Image);
Iout=zeros(size(Image));
tmpSize=size(Se);
for i=1:Isize(1,1)
for j=1:Isize(1,2)
if(Image(i,j)>0)
for m=1:tmpSize(1,1)
for n=1:tmpSize(1,2)
tmp1=i-Ap(1,1)+m;
tmp2=j-Ap(1,2)+n;
if(Se(m,n)>0 & tmp1>0 & tmp2>0 & tmp1<=Isize(1,1) & tmp2<=Isize(1,2))
Iout(tmp1,tmp2)=Iout(tmp1,tmp2)+Se(m,n);
end
end
end
end
end
end
for i=1:Isize(1,1)
for j=1:Isize(1,2)
if(Iout(i,j)>1) Iout(i,j)=1;
end;
end
end
figure,imshow(Image)
figure,imshow(Iout)
>>real function for dilation:
IM=imread('beras.bmp');
Se=ones(3,2);
IMage2=imdilate(IM,Se);
figure,imshow(IM),figure,imshow(IMage2)
can someone help me to generate a plot/graphical between these comparison?
You can subtract the images and then show the difference to compare
them.
Good luck,
ImageAnalyst
--------------------------------------------------------------------------------------------
Use imsubtract() to subtract.
Use imshow() to show the subtracted image in a figure window or axes.
----------------------------------------------------------------------------------------------------------
What do you mean by calibration? You have the official MATLAB-
supplied way of doing a dilation, and you have your own flavor of it
(to put it nicely). Since you aren't doing it right, they will be
different. Subtracting is one way of showing differences. PSNR is
another. I don't think you really know what you want to do and so I
think you should rethink this a bit. I have no idea what it is that
you think you want to graph (presumably a line-type of plot).