Formation of Clusters in MATLAB

1 次查看(过去 30 天)
Premnath
Premnath 2012-12-11
I am working on a switching bilateral filter.. In this, they have formed clusters of pixels to detect the edges in the image. They have used Sorted Quadrant Median Vector.
The code they have used for this purpose is
% Formation of clusters
if((((m1 < avg) && (m4 < avg))&&((m2 >= avg) && (m3 >= avg))) || (((m2 < avg) && (m3 < avg))&&((m1 >= avg) && (m4 >= avg))))
p=i+2;
q=j+2;
vec=[L(p-2,q) L(p-1,q) L(p+1,q) L(p+2,q)]; % Vertical edge
dav=double(sum(vec)/4);
%disp('vertical edge');
elseif((((m3 < avg) && (m4 < avg))&&((m1 >= avg) && (m2 >= avg))) || (((m1 < avg) && (m2 < avg))&&((m3 >= avg) && (m4 >= avg))))
p=i+2;
q=j+2;
vec=[L(p,q-2) L(p,q-1) L(p,q+1) L(p,q+2)]; % Horizontal edge
dav=double(sum(vec)/4);
%disp('horizontal edge');
elseif((((m1 < avg) && (m3 < avg))&&((m2 >= avg) && (m4 >= avg))) || (((m2 < avg) && (m4 < avg))&&((m1 >= avg) && (m3 >= avg))))
p=i+2;
q=j+2;
vec=[L(p-1,q+1) L(p-1,q-1) L(p+1,q-1) L(p+1,q+1)]; % Diagonal line
dav=double(sum(vec)/4);
%disp('diagonal line');
end
m1,m2,m3 and m4 are the medians.. Please explain me what does these three lines do p=i+2; q=j+2; vec=[L(p-2,q) L(p-1,q) L(p+1,q) L(p+2,q)]; % Vertical edge
Please explain these and suggest me a book/guide related to image processing in MATLAB

回答(1 个)

Image Analyst
Image Analyst 2012-12-11
It looks like it takes an intensity profile of 4 pixels in length going diagonally.
  2 个评论
Premnath
Premnath 2012-12-11
Please explain in Detail
Image Analyst
Image Analyst 2012-12-11
L is a matrix. Look at this line:
vec=[L(p-1,q+1) L(p-1,q-1) L(p+1,q-1) L(p+1,q+1)]; % Diagonal line
the comment tells a lot. Also the fact that the row and column indexes have + and - 1 means that you're going around the pixel at (p,q). vec is essentially a list of 4 numbers extracted from L. I think you can figure it out if you study it. It's not rocket science.

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Image Processing Toolbox 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by