【问题标题】:matlab can't show image after drawing a shape using shapeInserter使用shapeInserter绘制形状后matlab无法显示图像
【发布时间】:2014-11-10 16:18:27
【问题描述】:

我正在尝试使用 shapeInserter,如 here 所示,但是当我使用 imshow 时出现此错误:

Error using imageDisplayValidateParams>validateCData (line 126)
RGB images must be uint8, uint16, single, or double.

Error in imageDisplayValidateParams (line 27)
common_args.CData = validateCData(common_args.CData,image_type);

Error in imageDisplayParseInputs (line 78)
common_args = imageDisplayValidateParams(common_args);

Error in imshow (line 219)
[common_args,specific_args] = ...

Error in myScript (line 35)
imshow(img1);

这是我的代码:

shapeInserter = vision.ShapeInserter('Shape','Rectangles','BorderColor','Custom', 'CustomBorderColor', uint8([255 0 0]));
rect = int32([x, y, 10, 10]);
rgb = repmat(img, [1, 1, 3]);
img1 = step(shapeInserter, rgb, rect);
imshow(img1);

img 是我之前加载的灰度图像。

【问题讨论】:

  • 我试过你的代码,它工作正常。

标签: image matlab matlab-cvst


【解决方案1】:

img 的类型是什么?看来它不是imshow 允许的类型之一:uint8、uint16、single 或 double。如果是这种情况,您应该将其转换为其中一种类型。

如果您有最新版本的 MATLAB,请尝试使用界面更简单的 insertShape 函数。

【讨论】:

  • img 的类型是 int16imshow 工作正常!但是当我尝试显示rgbimg1(两者都是int16)时它不起作用。我在使用insertShape 时遇到了同样的问题。
  • 嗯,看起来 imshow 显示的是灰度 int16 图像,但是对于 rgb int16 图像会引发错误。此时您唯一能做的就是使用不同的数据类型。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2021-05-11
  • 2012-01-12
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多