I wrote code based on the first part of this article (when detecting a path). However, the image that my code produces does not look like the image shown in the document. I am new to image processing, and because of this, I thought maybe there is something that I do not fully understand.
I am going to write what the document said, and how I implemented it so that you can see if there is a misunderstanding. The document said:
We suggest using a local method that examines lighting changes in a selected n * n window. Usually we use a 3 * 3 window, and we split the image into many overlapping areas of this size. For each of these areas, we calculated the mean and standard deviation of the pixel intensities in an 8-pixel neighborhood.
In this part, I wrote:
e=imread('1.jpg');
p=rgb2gray(e);
p=im2double(p);
h=[1 1 1;
1 1 1;
1 1 1;];
h=h/9;
u=imfilter(p,h);% average filter
Size=size(e);
n=3;
e=[1 1 1;
1 1 1;
1 1 1;];
Di=stdfilt(p,e); % standard deviation
I have a problem: what does an 8px neighborhood mean? Is it that (a) I should not use a center pixel for every 3 * 3 local window, or is this (b) just another term for a local window?
Now the rest of the algorithm from the article:
, . Ihigh Ilow S (i, j), :
S (I, J) = IHIGH-ILOW
. T (i, j), . T = u-k * sd (sd = ), k - . : g (i, j) = 1, S (i, j) >= T (i, j) 0, S (i, j) T (i, j) g (i, j) . , k , "
:
k=1;
Div=k*Di;
t=u-Div;
min=ordfilt2(p,1,ones(3,3));
max=ordfilt2(p,3*3,ones(3,3));
s=max-min;
g=zeros(Size(1),Size(2));
for I=1:Size(1)
for J=1:Size(2)
if(s(I,J) >= t(I, J))
g(I, J) = 1;
else
g(I, J) = 0;
end
end
end
g=imadjust(g,[0 1],[1,0]);
imshow(g)
:
min=ordfilt2(p,1,ones(3,3));
max=ordfilt2(p,3*3,ones(3,3);
, , -, ? ?
, :

, :

:
