Clear Filters
Clear Filters

i can't display .tif image in matlab,where i can read it through imread,bt can't able to show it

1 view (last 30 days)
i can't display .tif image in matlab,where i can read it through imread,bt can't able to show it. showing the error like this
Error using imageDisplayValidateParams>validateCData (line 117)
Unsupported dimension.
Error in imageDisplayValidateParams (line 31)
common_args.CData = validateCData(common_args.CData,image_type);
Error in imageDisplayParseInputs (line 79)
common_args = imageDisplayValidateParams(common_args);
Error in imshow (line 198)
[common_args,specific_args] = ...
while checking imfinfo
Filename: [1x112 char]
FileModDate: '11-Aug-2015 07:30:15'
FileSize: 336095
Format: 'tif'
FormatVersion: []
Width: 106
Height: 115
BitDepth: 64
ColorType: 'grayscale'
FormatSignature: [77 77 0 42]
ByteOrder: 'big-endian'
NewSubFileType: 0
BitsPerSample: [32 32]
Compression: 'Uncompressed'
PhotometricInterpretation: 'BlackIsZero'
StripOffsets: [2x1 double]
SamplesPerPixel: 2
RowsPerStrip: 115
StripByteCounts: [2x1 double]
XResolution: 1
YResolution: 1
ResolutionUnit: 'None'
Colormap: []
PlanarConfiguration: 'Planar'
TileWidth: []
TileLength: []
TileOffsets: []
TileByteCounts: []
Orientation: 1
FillOrder: 1
GrayResponseUnit: 0.0100
MaxSampleValue: [4.2950e+09 4.2950e+09]
MinSampleValue: [0 0]
Thresholding: 1
Offset: 10
ImageDescription: [1x86 char]
SampleFormat: {2x1 cell}
ModelPixelScaleTag: [3x1 double]
ModelTiepointTag: [720x1 double]
GeoKeyDirectoryTag: [16x1 double]
UnknownTags: [1x1 struct]
i got like this and my image size given by size= 115 106 2 how i can display this image
  1 Comment
Stephen23
Stephen23 on 13 Aug 2015
Edited: Stephen23 on 13 Aug 2015
Please upload the image using the paperclip button and then pressing both the Choose file and Attach file buttons. You might need to change the file extension or zip the file first (please give a precise description if you do this).

Sign in to comment.

Answers (2)

D Joseph
D Joseph on 13 Aug 2015
use imshow

Walter Roberson
Walter Roberson on 13 Aug 2015
Look at ColorType: 'grayscale' but SamplesPerPixel: 2 . The image has two bitplanes even though grayscale images should only have one. You should index the array at (:,:,1) to display it.
I suspect that it might be a grayscale image with an Alpha plane. The UnknownTags might give some hints about that. You could try reading it in as
[Imagedata, Map, Transparency] = imread('filename.tif');
and see what size(Imagedata) and size(Transparency) is. But I suspect that the file is not constructed exactly properly -- and it is possible that it is two different images stored together.
With your current imread() if it is intended to be transparency then you would be able to view it with
image(Imagedata(:,:,1), 'AlphaData', Imagedata(:,:,2)); %where Imagedata is the image read in
colormap(gray(256))
However, notice that the data is indicated as 32 bits for each of the planes, and notice that MaxSampleValue: [4.2950e+09 4.2950e+09] . That 4.2950e+09 happens to be 2^32 -- the data is probably in uint32 format and the entire range is used. You are going to have to rescale the data to view it properly -- the second plane as well. Try
plane1 = double(Imagedata(:,:,1)) / 2^32; %where Imagedata is the image read in
plane2 = double(Imagedata(:,:,2)) / 2^32;
subplot(3,1,1)
image(plane1);
colormap(gray(256));
title('first layer by itself')
subplot(3,1,2)
image(plane2);
colormap(gray(256));
title('second layer by itself');
subplot(3,1,3)
image(plane1, 'AlphaData', plane2);
colormap(gray(256));
title('second layer is Alpha on first layer')

Categories

Find more on Images in Help Center and File Exchange

Tags

No tags entered yet.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!