Reference to non-existent field 'BoundingBox'. can you help me? why?

조회 수: 2 (최근 30일)
vu chung
vu chung 2015년 4월 16일
댓글: Image Analyst 2015년 4월 21일
a=imread('image201504160001.jpg');
>> figure,imshow(a);
>> title('Original Image');
>> %Convert the Image to binary
>> b=im2bw(a);
>> %Fill the holes
>> c=imfill(b,'hole');
>> %Label the connected components
>> [Label,Total]=bwlabel(c,8);
>> figure,imshow(c);title('Labelled Image');
>> %Rectangle containing the region
>> Sdata=regionprops(Label,'BoundingBox');
>> %crop all the car
>> for i=1:Total
img=imcrop(a,sdata(i).BoundingBox);
Name=strcat('Object Number:',num2str(i));
figure,imshow(Img); title(Name);
end
  댓글 수: 2
Guillaume
Guillaume 2015년 4월 16일
In the above code, the case of the S in sdata changes between the two lines referencing it (one is Sdata, the other is sdata). Is it a genuine error or a copying error? It would generate a different error message though, so I'm not sure why you're getting this error.
vu chung
vu chung 2015년 4월 21일
thanks for your answer! i understand, it was run but wrong. i have one image include two car but it count 26 car. it donot know position car to count 1 1 point white on image it count is one can you help me,please thanks.

댓글을 달려면 로그인하십시오.

채택된 답변

Image Analyst
Image Analyst 2015년 4월 21일
Please address Guillaume's suggestion that you mistyped the name. Sdata is a different variable than sdata because MATLAB is case sensitive. Capital or lower case "s" - it makes a huge difference!!! You must use the same case letters throughout your program , otherwise it will think you have two different variables: sdata and Sdata. Sdata came out of regionprops() so it will have a BoundingBox field, while sdata was not defined so it certainly won't have ANY fields at all, much less one called BoundingBox.
  댓글 수: 2
vu chung
vu chung 2015년 4월 21일
thanks your answer yes, i repaired sdata but it count wrong in image have two car count result many car How to result right two car Thanks
Image Analyst
Image Analyst 2015년 4월 21일
Your segmentation algorithm is wrong. I don't know what you're doing, but you say it's wrong. Looks like you might be able to find the background color or texture (with stdfilt() or rangefilt()) and then invert it and fill holes, but I don't know.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Computer Vision with Simulink에 대해 자세히 알아보기

태그

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by