[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: matrix to image to file
From: |
Luiz Portella |
Subject: |
Re: matrix to image to file |
Date: |
Thu, 8 Sep 2011 10:46:31 -0300 |
2011/9/8 William Krekeler <address@hidden>:
> -----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
>
> Hello,
>
> 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
> _______________________________________________
>
> Luiz,
>
> '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.
>
> try:
> a = rand( 3, 3);
> imwrite( a, 'test.gif', 'gif')
b = rand( 3, 3);
imwrite( b, 'test.gif', 'gif')
dont works, I get:
octave: magick/semaphore.c:525: LockSemaphoreInfo: Assertion
`semaphore_info != (SemaphoreInfo *) ((void *)0)' failed.
panic: Aborted -- stopping myself...
attempting to save variables to `octave-core'...
save to `octave-core' complete
Abortado
octave-core is anexed.
> 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' ) );
Well, I put off "a = rand(3,3)" because I need my matrix 7x7.
xmap = colormap('gray');
img01 = imagesc(a);
print( gcf, '-dpng', fullfile( pwd, 'img01.png' ) );
works fine! Thanks a lot!
I think: what print unlike imwrite and saveas dont need indication of
image/matrix?
> Use help command on print, fullfile functions to change to your desired
> format and file location.
>
> Hope that helps.
Gxis poste
--
Luiz Portella address@hidden