-1

With the following code I get the error message To RESHAPE the number of elements must not change.

[Ilabel, num] = bwlabel(Ifill);
disp(num);
Iprops = regionprops(Ilabel);
Ibox = [Iprops.BoundingBox]; 
Ibox = reshape(Ibox,[4,50]);%Error using reshape .
imshow(Ibox)

Can anyone help me?

cifz
  • 1,078
  • 7
  • 24
user3500980
  • 11
  • 1
  • 1
  • 1

1 Answers1

3

The error message is pretty self-explanatory.

What you try to reshape doesn't have 4*50 elements (can be more or less). Check the size of Ibox and select the new dimensions such as the number of elements in Ibox doesn't change.

As a side comment, regionprops returns a struct, so even if you reshape it right the imshow will fail as it wants a matrix. If you want to display the bounding boxes I suggest you to read this previous question:

How to get a rectangular subimage from regionprops(Image,'BoundingBox') in Matlab?

Community
  • 1
  • 1
cifz
  • 1,078
  • 7
  • 24