Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/matlab/14.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Image 使用shapeInserter绘制形状后,matlab无法显示图像_Image_Matlab_Matlab Cvst - Fatal编程技术网

Image 使用shapeInserter绘制形状后,matlab无法显示图像

Image 使用shapeInserter绘制形状后,matlab无法显示图像,image,matlab,matlab-cvst,Image,Matlab,Matlab Cvst,我正试图使用shapeInserter,如图所示,但当我使用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(co

我正试图使用shapeInserter,如图所示,但当我使用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是我之前加载的灰度图像。

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


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

我尝试了您的代码,效果很好。img的类型是int16,imshow效果很好!但当我试图显示rgb或img1都是int16时,它就不起作用了。我在使用insertShape时也遇到了同样的问题。好吧,它看起来像是imshow显示了灰度int16图像,但对rgb int16图像抛出了一个错误。此时您唯一能做的就是使用不同的数据类型。