thanks imageanalyst. appreciate the help guy. I tested it.
But when I have change the Rs1 matrix to include more blobs as follows:
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
clc; clear all;
Rs1 = [ 0,0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0;
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0;
0, 0, 0, 0, 3, 3, 3, 3, 3, 3, 0, 0;
0, 0, 0, 0, 0, 0, 3, 3, 3, 0, 4, 0;
0, 0, 0, 0, 0, 5, 0, 0, 0, 4, 4, 0;
0, 0, 0, 0, 5, 5, 0, 0, 0, 4, 4, 0;
0,0, 0, 0, 5, 5, 0, 0, 0, 4, 4, 0;
0, 0, 0, 0, 5, 0, 6, 6, 6, 0, 4, 0;
0, 0, 0, 0, 0, 6, 6, 6, 6, 6, 0, 0;
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0;
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0;
0, 0, 0, 0, 0, 0, 0, 0,0, 0, 0, 0]
STATS = regionprops(Rs1, 'PixelList', 'BoundingBox' )
for k = 1 : length(STATS)
x1 = STATS(k).BoundingBox(1) + 0.5;
x2 = x1 + STATS(k).BoundingBox(3) - 1;
y1 = STATS(k).BoundingBox(2) + 0.5;
y2 = y1 + STATS(k).BoundingBox(4) - 1;
fprintf(1, 'BoundingBox for blob #%d: x1=%d, x2=%d, y1=%d, y2=%d\n', ...
k, x1, x2, y1, y2);
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
the output is:
BoundingBox for blob #1: x1=1, x2=0, y1=1, y2=0
BoundingBox for blob #2: x1=1, x2=0, y1=1, y2=0
BoundingBox for blob #3: x1=5, x2=10, y1=3, y2=4
BoundingBox for blob #4: x1=10, x2=11, y1=4, y2=8
BoundingBox for blob #5: x1=5, x2=6, y1=5, y2=8
BoundingBox for blob #6: x1=6, x2=10, y1=8, y2=9
how I can get rid of the BoundingBox for blob#1 and blob#2 which is really non-existent blobs?
appreciate the help
thanks
ravi
|