[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: xvloadimage with imagesc and colormap
From: |
Stefan van der Walt |
Subject: |
Re: xvloadimage with imagesc and colormap |
Date: |
Wed, 8 Mar 2006 10:58:57 +0200 |
User-agent: |
Mutt/1.5.9i |
Hi Mika
On Tue, Mar 07, 2006 at 08:13:14PM -0600, Mike Miller wrote:
> I'm finding it tricky to make an imagesc() plot with a particular colormap
> and save it in a file (I want PNG but can get to that from some other
> format if necessary). I think maybe imagesc() doesn't respect the
> colormap, but if I try to use image(), or imshow(), the image is just
> solid black. My colormap is grayscale. I could just use
> colormap("default"), and I tried it but it didn't work. The commmand
> "imagesc(X,1)" makes a reasonable image but it isn't using my
> colormap.
I find it strange that `imshow' displays a black image. Imshow tries
to determine what kind of picture you supply, since they come in so
many shapes and forms. Your image values can be in [0,1], or in
[0,255], or in [0,2^anything].
If the largest value of the image is slightly larger than 255, imshow
will probably assume it is in [0,512]. If `I' is your image, you
should therefore have
min(I(:)) >= 0
max(I(:)) <= 255 or max(I(:)) <= 1
You are right about imagesc: it does look like the colormap specified
is ignored. A quick workaround is to set the colormap before calling
it, i.e.
colormap(jet(256));
imagesc(...)
> If I want to save an imagesc() image to a file, what do I have to do? It
> isn't using gnuplot, so the usual __gnuplot_set__ methods don't
> work.
Use the `ind2rgb' function to convert your indexed image to RGB, after
which you can use `imwrite' (`jpgwrite' or `pngwrite') to store the
image to a file.
> In case it matters, I'm running Octave 2.1.71 under Linux with Octave
> Forge and I don't have xv or ImageMagick installed, but I do have
> xloadimage.
Without ImageMagick you will have to rely on `jpgwrite` or `pngwrite`.
Regards
Stéfan
-------------------------------------------------------------
Octave is freely available under the terms of the GNU GPL.
Octave's home on the web: http://www.octave.org
How to fund new projects: http://www.octave.org/funding.html
Subscription information: http://www.octave.org/archive.html
-------------------------------------------------------------