Formation of Clusters in MATLAB
1 view (last 30 days)
Show older comments
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
0 Comments
Answers (1)
Image Analyst
on 11 Dec 2012
It looks like it takes an intensity profile of 4 pixels in length going diagonally.
2 Comments
Image Analyst
on 11 Dec 2012
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.
See Also
Categories
Find more on Image Processing Toolbox in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!