ind2gray problem

8 ビュー (過去 30 日間)
romain dalidet
romain dalidet 2017 年 12 月 19 日
編集済み: Guillaume 2017 年 12 月 19 日
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 件のコメント
Guillaume
Guillaume 2017 年 12 月 19 日
編集済み: Guillaume 2017 年 12 月 19 日
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 2017 年 12 月 19 日
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 ?

サインインしてコメントする。

回答 (1 件)

Guillaume
Guillaume 2017 年 12 月 19 日
編集済み: Guillaume 2017 年 12 月 19 日
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.

カテゴリ

Help Center および File ExchangeImage Filtering and Enhancement についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by