how to extract the bounding box area as segmented object from video frame?...I have been trying imcrop but the rectangle cropped out is not as same as bbox rectangle.
조회 수: 5 (최근 30일)
이전 댓글 표시
I am using computer vision toolbox.. this is the code..Is there any other way of doing it??
please help..thankyou in advance!
crop=bbox(:,); % all bbox that hav objects
crop=transpose(crop); % bbox as crop in row major as for rectangles
num = size(crop,1);
for k = 1: num
crop(k,2)=crop(k,2)-crop(k,3); % ymin is required but ymax is in upper left corner
temp=crop(k,3); % swapping height and width as required in rectangle! crop(k,3)=crop(k,4); crop(k,4)=temp;
[Xtest,Ytest,itest,Rtest]=imcrop(image,crop(k,:));
imshow(itest);
댓글 수: 0
채택된 답변
Image Analyst
2013년 4월 24일
I don't know what bbox is. Don't use image as the name of your image variable because it's the name of a built-in function. Simply crop like this:
croppedImage = imcrop(fullImage, [leftColumn, topRow, numberOfColumns, numberOfRows]);
You have to figure out how to get leftColumn, topRow, numberOfColumns, numberOfRows.
댓글 수: 2
Image Analyst
2013년 4월 29일
I don't know what step() does, but in all the MATLAB functions that I can think of when it wants a rectangle, it's [xStart, yStart, xSize, ySize]. Check with the documentation for step() - for example make sure it's not using row, column instead of x,y.
추가 답변 (1개)
Anand
2013년 4월 29일
It seems to work for me...The rectangle specification provided by the vision.BlobAnalysis object is the same as that required by imcrop.
im = padarray(strel('disk',100,0).getnhood,[50 25],'pre');
hblob = vision.BlobAnalysis;
[area,centroid,bbox] = step(hblob,im);
>> bbox
bbox =
26 51 201 201
out = imcrop(im,bbox);
imshow(out);
참고 항목
카테고리
Help Center 및 File Exchange에서 Computer Vision Toolbox에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!