|
Hi Steve,
this is the solution. Now it works perfectly.
Thank you very much,
Ralf
On 6 Okt., 14:21, Steve Eddins <Steve.Edd...@mathworks.com> wrote:
> Ralf wrote:
> > Hello all,
>
> > I'm getting strange results when opening a TIFF-file with imread.
> > Opening the same picture as a JPEG-file, when it had been converted
> > externally, it is no problem but the result is not usable for me
> > because too much information is lost due to storage in JPEG even if
> > choosing no compression. Resaving the picture with an external program
> > as TIFF does not help, too.
>
> > After performing RGB=imread('test.tif') I get the following values in
> > RGB (showing a small section). RGB is only a n x n x 1 matrix,
> > although it should be n x n x 3, which means that somehow no colormap
> > is imported. If I change the standard colormap, it is possible to see
> > the picture with image(RGB), but only with a one-color-based picture.
> > With the standard colormap, it is just black. Do you have any hints?
>
> > Thank you,
> > Ralf
>
> > ***************************************
> > RGB=imread('test.tif');
> > size(RGB)
> > ans =
>
> > 802 1024
> > RGB(1:10,1:10)
>
> > ans =
>
> > 20 20 20 20 20 20 20 20 20 20
> > 20 20 20 20 20 20 20 20 20 20
> > 20 20 13 13 13 13 13 13 13 13
> > 20 20 13 13 13 13 13 13 13 13
> > 20 20 13 13 13 13 13 13 13 13
> > 20 20 13 13 13 13 13 13 13 13
> > 20 20 13 13 13 13 13 13 13 13
> > 20 20 13 13 13 13 13 13 13 13
> > 20 20 13 13 13 13 13 13 13 13
> > 20 20 13 13 13 13 13 13 13 13
>
> > *****************************
>
> > imfinfo gives the following result:
>
> > Filename: 'test.tif'
> > FileModDate: '06-Jun-2007 13:08:12'
> > FileSize: 183092
> > Format: 'tif'
> > FormatVersion: []
> > Width: 1024
> > Height: 802
> > BitDepth: 8
> > ColorType: 'indexed'
> > FormatSignature: [77 77 0 42]
> > ByteOrder: 'big-endian'
> > NewSubFileType: 0
> > BitsPerSample: 8
> > Compression: 'LZW'
> > PhotometricInterpretation: 'RGB Palette'
> > StripOffsets: [101x1 double]
> > SamplesPerPixel: 1
> > RowsPerStrip: 8
> > StripByteCounts: [101x1 double]
> > XResolution: []
> > YResolution: []
> > ResolutionUnit: 'Inch'
> > Colormap: [256x3 double]
> > PlanarConfiguration: 'Chunky'
> > TileWidth: []
> > TileLength: []
> > TileOffsets: []
> > TileByteCounts: []
> > Orientation: 1
> > FillOrder: 1
> > GrayResponseUnit: 0.0100
> > MaxSampleValue: 255
> > MinSampleValue: 0
> > Thresholding: 1
> > ImageDescription: 'converted PNM file'
>
> Your color image is stored in indexed form, not truecolor form. (See
> the ColorType field in the output of imfinfo.) That means you need to
> call imread with two output arguments in order to get the colormap.
>
> [X,map] = imread('test.tif');
> image(X)
> colormap(map)
>
> JPEG doesn't support indexed image storage, so your external program
> converted the image from indexed to truecolor form in order to store it
> as a JPEG. That's why you got an M-by-N-by-3 array when you read in the
> converted JPEG file.
>
> ---
> Steve Eddinshttp://blogs.mathworks.com/steve/
|