White images with 'imshow'
John W. Eaton
jwe at octave.org
Wed May 27 09:39:48 CDT 2009
On 27-May-2009, Søren Hauberg wrote:
| ons, 27 05 2009 kl. 15:42 +0200, skrev Jaroslav Hajek:
| > still, it seems you're right that encode_uint_image does not handle
| > indexed images at all.
| > I searched through GraphicsMagick docs but could not find the proper way.
|
| We could simply convert indexed images into RGB images (using 'ind2rgb')
| before calling the underlying C++ functions.
I tried to fix __magick_write__ but I don't seem to have it right
yet. Jaroslav just checked in a change that I think fixes the
colormap encoding and avoids the exception that I saw earlier, but
saving indexed images is still not completely right. Note the
difference in the two images below:
[I, M] = imread ("default.img");
imwrite (I, M, "foo.png");
X = imread ("foo.png");
class (X)
subplot (1, 2, 1);
imshow (I, M);
subplot (1, 2, 2);
imshow (X);
The first one is displayed correctly. Note that the class of X is
uint8, and it is apparently being interpreted as pixel values, not
indices into the colormap.
I have no idea how to insert the index data into the GraphicsMagick
data structure properly, and it is not at all clear to me from reading
the documentation.
So to avoid further delay, I checked in the following change, which
simply converts the indexed image to RGB before saving it. Then the
above sequence of commands appears to produce the correct results for
both images.
http://hg.savannah.gnu.org/hgweb/octave/rev/86f475d5e7d1a
jwe
More information about the Bug-octave
mailing list