我正在尝试使用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
是我之前加载的灰度图像。
答案 0 :(得分:0)
img
的类型是什么?它似乎不是imshow
允许的类型之一:uint8,uint16,single或double。如果是这种情况,您应该将其转换为其中一种类型。
如果您有最新版本的MATLAB,请尝试使用insertShape
功能,该功能具有更简单的界面。