Why insetShape function doesn't accept unit8 or double gray image as an input

This error is appears when I call my function: "Undefined function 'insertShape' for input arguments of type 'uint8'." insertShape is a built-in function in matlab and I use it in my function as that
if debug
img = insertShape(img, 'circle', [yrt(:),xrt(:),2*ones(size(xrt(:)))],'Color','r');
img = insertShape(img, 'circle', [ylt(:),xlt(:),2*ones(size(xrt(:)))],'Color','blue');
I passed to the function rgb unit8 image and it is converted inside the function to gray by rgb2gray before entering to insertShape the function is works in another device with different matlab version, so maybe the problem from my matlab version (R2011b)but I don't know what exactly the difference that cause the problem.
the function using Mapping toolbox and maybe other toolboxes.

2 Comments

I ran into the same problem with 'insertShape'. I even tried the example in the help file verbatim and it failed with the same error message you stated. Here is my code:
I = imread('peppers.png');
RGB = insertShape(I, 'circle', [150 280 35], 'LineWidth', 5);
pos_triangle = [183 297 302 250 316 297];
pos_hexagon = [340 163 305 186 303 257 334 294 362 255 361 191];
RGB = insertShape(RGB, 'FilledPolygon', {pos_triangle, pos_hexagon}, 'Color', {'white', 'green'}, 'Opacity', 0.7);
imshow(RGB);
Here is the error message I get back:
Undefined function 'insertShape' for input arguments of type 'uint8'.
Error in circle_on_Peppers (line 2) RGB = insertShape(I, 'circle', [150 280 35], 'LineWidth', 5);
Do you have Computer Vision Toolbox R2014a or later installed and licensed?

Sign in to comment.

Answers (1)

insertShape is not a built-in function in MATLAB. insertShape() is part of the Computer Vision Toolbox, and was introduced in R2014a.
If you have Computer Vision but a version before R2014a then use ShapeInserter

Asked:

on 18 Feb 2016

Commented:

on 18 Mar 2016

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!