MATLAB regionprops bounding box | centroid | MATLAB Image Processing | Lecture#06

Описание к видео MATLAB regionprops bounding box | centroid | MATLAB Image Processing | Lecture#06

Regionprops is a function in matlab used to compute BoundingBox of an Binary Object found after bwlabel function which returns connected components. We can also compute centroid of object or Area of the object. There are also some other statistical properties with the help of regionprops function in MATLAB. This function is part of Image Processing Toolbox so we can also use this function in Gnu Octave which is opensource alternative of MATLAB. This lecture is part of Digital Image Processing fundamentals with help of MATLAB/Octave Course series. The number of this lecture is lecture number 06. If you had not watched previous lectures in which we had explained reading image, resizing, displaying image with help of imshow function. writing image with help of imwrite function. You should watch previous playlist. But we also summarized all previous lectures in this lecture as well. so the final code is like this

to crop a bounding box    • crop a bounding box from image return...  

x=imread('t1.jpg');
gray_x =rgb2gray(x);
bw_x = ~im2bw(gray_x,0.8);
bw = bwareadopen(bw_x,1000);
[bwLabel,num]=bwlabel(bw,8);
s = regionprops(bwLabel,'Area', 'BoundingBox', 'Centroid');
disp(size(s));
disp(strcat('Area = ',num2str(s.Area)));
cent = cat(1,s.Centroid);
bbox = cat(1,s.BoundingBox);
imshow(x); hold on
plot(cent(:,1),cent(:,1),'g*')
rectangle('Position',bbox,'EdgeColor','b',...
'LineWidth',3)
hold off;


Twitter:
  / ar_2050  
facebook:
  / strange.lab.2050  

Комментарии

Информация по комментариям в разработке