imread corruption
Afficher commentaires plus anciens
Every time I use imread to get an image it corrupts the input. Here's a link to a before and after picture. The after is what I'm seeing in matlab. Is this my doing or does matlab have a bug somewhere?
Code used:
I = imread('pout.gif');
imwrite (I, 'output.gif');
1 commentaire
Image Analyst
le 29 Sep 2011
It looks like you're displaying just a bit plane, or perhaps an indexed image without the associated colormap. But the "pout" image supplied by the Mathworks is not a GIF image - it's a TIFF image. So that brings up the question "Where did you get the GIF version of pout?" Also, post all your actual code, including the calls to imshow() or whatever.
Bottom line is, I'd say with 99.99% confidence that it's your doing and not a bug, based on thousands of prior observations of this kind of posting.
Réponses (1)
All GIF files are indexed-color images. If you're not reading the colormap, the array you're looking at is the index array. It's not a viewable image.
[Aind map] = imread('canoe.tif'); % this is also an indexed image
imshow(Aind,map) % using an indexed image requires both the index array and the map
If you don't read the map, this is what you will get. It's just a bunch of indices into a color table. There's no reason to expect that the indices are ordered in a way that naturally produces a clear image.
imshow(Aind) % if you don't have the map, you don't have the image.
Similarly, if you write an indexed image to a GIF without specifying the appropriate colormap, a default gray colormap will be substituted, which will likely destroy the image.
imwrite(Aind,'completegarbage.gif') % don't do this if the input is indexed
There are further complications specifically with multiframe GIF files, but that's a story for another time.
Catégories
En savoir plus sur Images dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

