ind2gray problem

6 views (last 30 days)
romain dalidet
romain dalidet on 19 Dec 2017
Edited: Guillaume on 19 Dec 2017
Hello eveyone, I have a small problem using the function ind2gray. Here is the code I wrote :
figure(4);
hen = line(x(3:end-1),y(3:end-1),'linestyle','none','marker','.','markersize',0.001,'color','k');
pbaspect([1 1 1])
set(gca,'xtick',[],'ytick',[])
saveas(gcf,'henon.tif');
[henon,map] = imread('henon.tif');
henon2 = ind2gray(henon,map);
I get this error :
Undefined function 'ind2gray' for input arguments of type 'uint8'.
But in the matlab documentation for ind2gray it is written :
X can be of class uint8, uint16, single, or double. map is double. I is of the same class as X.
further more, when I type whos henon I get :
whos henon
Name Size Bytes Class Attributes
henon 656x875x3 1722000 uint8
Is there something I am doing wrong ? I would like to simply create a grayscale picture from a figure. If anyone have a more simple way, please tell me ! Thank you.
  2 Comments
Guillaume
Guillaume on 19 Dec 2017
Edited: Guillaume on 19 Dec 2017
It may be that the critical part of the error message is Undefined function 'ind2gray'.
ind2gray requires the image processing toolbox. Have you got that installed?
What is the output of
which ind2gray -all
Stephen23
Stephen23 on 19 Dec 2017
romain dalidet's "Answer" moved here:
% Has no license available
Didn't knew that i needed image processinf toolbox ! Thank you for your anwser.
Do you know if there is another way for me to create a grayscale picture ?

Sign in to comment.

Answers (1)

Guillaume
Guillaume on 19 Dec 2017
Edited: Guillaume on 19 Dec 2017
Do you know if there is another way for me to create a grayscale picture ?
This can be achieved any number of ways. An easy one is to convert your image to RGB (which doesn't require the image processing toolbox) then to greyscale
greyimage = rgb2gray(ind2rgb(yourindexedimage, yourmap));
This may or may not produce the same results as ind2gray (haven't tested) since there is no unique way to convert from colour to grey scale.

Tags

Community Treasure Hunt

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

Start Hunting!