ind2gray problem
6 views (last 30 days)
Show older comments
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
Stephen23
on 19 Dec 2017
% 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 ?
Answers (1)
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.
0 Comments
See Also
Categories
Find more on Image Filtering and Enhancement in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!