【问题标题】:To RESHAPE the number of elements must not change要重塑元素的数量不能改变
【发布时间】:2014-04-05 19:58:30
【问题描述】:

使用以下代码,我收到错误消息要重塑元素的数量不得更改

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

谁能帮帮我?

【问题讨论】:

    标签: matlab


    【解决方案1】:

    错误信息是不言自明的。

    您尝试重塑的内容没有 4*50 元素(可以或多或少)。检查 Ibox 的大小并选择新的维度,例如 Ibox 中的元素数量不会改变。

    作为旁注,regionprops 返回一个结构,所以即使你正确地重塑它,imshow 也会失败,因为它需要一个矩阵。 如果您想显示边界框,我建议您阅读上一个问题:

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

    【讨论】:

      猜你喜欢
      • 2011-05-01
      • 1970-01-01
      • 2022-08-15
      • 1970-01-01
      • 2023-04-07
      • 2021-08-19
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多