How can I fix this Imrotate error in my program?

4 views (last 30 days)
%% Loading the image into the script
I = imread('DSC00157.jpg');
pause()
imshow(I); title('China is beautiful in color')
pause()
%% Converting I to Grayscale
I_gray = rgb2gray(I);
pause()
imshow(I_gray);
pause()
%% Grayslice Function
map=[0 0 0;0 0 1;1 0 0;1 1 0;1 1 1];
pause()
I_graycolor = grayslice(I_gray,5);
pause()
I_graycolor = imshow(I_graycolor,map);
pause()
%% Rotating the Image
I = I_graycolor;
imrotate(I, 180)
imshow(I)
pause()
figure(2)
title('China is beautiful in grayslice');
imshow(I_graycolor);
pause()
imwrite(I_graycolor,'BA_ce11pic.bmp');
But when I run the code - the last section gets the following error message:
Error in CE11 (line 20)
imrotate(I, 180)
Error using imrotate
Expected input number 1, input image, to be one of these types:
numeric, logical
Instead its type was matlab.graphics.primitive.Image.
Error in imrotate>parse_inputs (line 223)
validateattributes(A,{'numeric','logical'},{},mfilename,'input image',1);
Error in imrotate (line 67)
[A,ang,method,bbox] = parse_inputs(args{:});

Answers (1)

KALYAN ACHARJYA
KALYAN ACHARJYA on 4 Apr 2019
Edited: KALYAN ACHARJYA on 4 Apr 2019
imrotate(I, 180);
Where I must be image, But in your case you rotatinng the I_graycolor= imshow(I_graycolor,map); figure window.
If you rotate the indexed or gray scale image it perfectly OK.
Check it works, do the modification for map
I_graycolor = grayslice(I_gray,5);
pause()
%I_graycolor = imshow(I_graycolor,map);
%% Rotating the Image
I = I_graycolor;
imrotate(I, 180)

Community Treasure Hunt

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

Start Hunting!