[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: matrix to image to file

From: William Krekeler
Subject: RE: matrix to image to file
Date: Thu, 8 Sep 2011 12:48:53 +0000

-----Original Message-----
From: address@hidden [mailto:address@hidden On Behalf Of Luiz Portella
Sent: Thursday, September 08, 2011 7:31 AM
To: address@hidden
Subject: matrix to image to file


I have
a = zeros(7,7); # faz uma matriz 7x7 cheia de zeros
a(3,3) = 1; a(5,3) = 1; a(5,4) = 1; a(5,5) = 1; # monta a imagem

How  can I create a image?

the code:
img01 = imagesc(a);
imwrite(img01, 'img01.gif', "gif"); #imprime a imagem original

don't works:
Luiz Portella address@hidden


'help imwrite' gives you the input argument set as one of the following:
  Function File:  imwrite (IMG, FILENAME, FMT, P1, V1, ...)
  Function File:  imwrite (IMG, MAP, FILENAME, FMT, P1, V1, ...)
The function likely failed because you tried to call imwrite on a figure. 
Argument IMG is meant to be a matrix.

        a = rand( 3, 3);
        imwrite( a, 'test.gif', 'gif')

with regard to colormaps use 'x = colormap('gray');' if you wish to pass to 
imwrite or if you wish to plot then print to file try:

a = rand( 3, 3);
figure, imagesc( a ); colormap('gray'); print( gcf, '-dpng', fullfile( pwd, 
'filename.png' ) );

Use help command on print, fullfile functions to change to your desired format 
and file location.

Hope that helps.

W. Krekeler

reply via email to

[Prev in Thread] Current Thread [Next in Thread]