从图像中的这么多边界框,我想要特定高度和宽度比的边界框。我在32个不同的对象周围创建了边界框。
首先,我必须标记每个边界框。 然后我想计算特定框的值,在输出中我想要特定高度和宽度比的边界框。怎么做。
我的代码是:
f=imread('G:\..pooja project\prjct nw\r.jpg');
f=imresize(f,[400 NaN]); % Resizing the image keeping aspect ratio same.
g=rgb2gray(f);
g=medfilt2(g,[3 3]);
se=strel('disk',1);
gi=imdilate(g,se);
ge=imerode(g,se);
gdiff=imsubtract(gi,ge);
gdiff=mat2gray(gdiff);
gdiff=conv2(gdiff,[1 1;1 1]);
gdiff=imadjust(gdiff,[0.5 0.7],[0 1],0.1); .
B=logical(gdiff);
er=imerode(B,strel('line',50,0));
out1=imsubtract(B,er);
F=imfill(out1,'holes');
figure(2) ,imshow(F)
H=bwmorph(F,'thin',1);
H=imerode(H,strel('line',3,90));
figure(3),imshow(H)
final=bwareaopen(H,100);
figure(4),imshow(final);
[Ilabel num]=bwlabel(final);
disp(num)
figure(7),imshow(final)
Iprops=regionprops(Ilabel);
stats = regionprops(final,'eccentricity','orientation','area')
%stats()
Ibox=[Iprops.BoundingBox];
Ibox=reshape(Ibox,[4 num]);
for cnt=1:num
rectangle('position',Ibox(:,cnt),'edgecolor','r');