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.
Code:
% 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.. Is it correct to proceed this way?
Please explain these and suggest me a book/guide related to image processing in MATLAB
I assume here, m1, m2, m3, m4 are taken from one of your previous questions, meaning that
they are medians of 3×3 subwindows of a 5×5 window.
That is, they form a matrix like this:
or in some similar configuration.
That is, the first “if” branch means: if both the m1 and m4 medians are smaller than the average and m2 and m3 are greater (or the full opposite of this happens), there should be a steep change from left to right in that particular 5×5 subwindow. (Remember that medians filter out any single peak value which means that there will be not so many false edges detected even if the image is noisy.) As for vec,
just stores the vertical middle points of the search window. I don’t think it would work in this form, I would think storing the edge indices would make more sense here:
It would be the coordinates of the five edge points, where the edge is assumed to go from top to down in the middle of the current search window. (You can check this manually too.)
The “else if”‘s work similarly.
As for a starting point on image processing I can recommend you a book called “Learning OpenCV” by Gary Bradski and Adrian Kaehler although that is not a Matlab book. If you do not read the C++ programs in the book and the detailed description about OpenCV, you will still get quite a nice general round-up knowledge about image processing — or at least you’ll get familiar with the main concepts.
As for Matlab specifics, I recommend you reading through the entire help on image processing toolbox. As though as it might sound, I think there is only hard way to learn image processing.