Multibandread function makes my uint8 image tingly

I have a uint8 multiband tif image. I'm using the 'multibandread' function in my code. But when I try display the image it becomes a tingly image. Here is the script I use to display my image:
image = multibandread('l7_ms.tif',[512, 512, 7],'uint8=>uint8',...
128,'bil','ieee-le',{'Band','Direct',[4 3 2]}); % Convert the multiband image to 3 band image
figure; imshow(image); title('CIR Composite'); % Display image
Here is my display output:
is there something wrong with my code? If so how do I fix it?

 Accepted Answer

I couldn't upload my image due to its size. Do you know any way to make it's size smaller or different way to upload here?

7 Comments

If you zip it up will it work?
Did imread() work? Did you try it? Otherwise, how about read()?
No it's still larger than the 5mb.
I tried it but it didn't worked. It gives an error:
Expected input number 1, I, to be one of these types:
double, single, uint8, uint16, uint32, uint64, int8, int16, int32, int64, logical
Instead its type was matlab.graphics.primitive.Image.
What was the call to read() or imread() you used? For imread() the first argument should be the filename, not a number so I don't know what function was throwing that error that it wants a number. You forgot to give your latest code.
Perhaps you can put the image on your MATLAB or Google drive.
Sorry you're right I forgot to upload my code. Here:
img=imread('l7_ms.tif');
figure; imshow(img); title('CIR Composite'); % Display image
And I upload it via Google dirve. Here is the link: https://drive.google.com/file/d/1sb7I6ITlVUBVeNTwXORLeQ0IN8NVa8Jc/view?usp=sharing
Okay I figured it out it out. I decreased the bands using:
img=imread('l7_ms.tif');
img=img(:,:,1:3);
figure; imshow(img); title('CIR Composite'); % Display image
and I got an output.
Thanks for everything!
This image appears to have 12 channels.
fname = 'l7_ms.tif';
inpict = imread(fname);
imfinfo(fname)
Filename: '/data/homebak/cad_and_projects/imagepooper/l7_ms.tif'
FileModDate: '14-Mar-2017 09:08:02'
FileSize: 48029304
Format: 'tif'
FormatVersion: []
Width: 2000
Height: 2000
BitDepth: 96
ColorType: 'grayscale'
FormatSignature: [73 73 42 0]
ByteOrder: 'little-endian'
NewSubFileType: 0
BitsPerSample: [8 8 8 8 8 8 8 8 8 8 8 8]
Compression: 'Uncompressed'
PhotometricInterpretation: 'BlackIsZero'
StripOffsets: [1×2000 double]
SamplesPerPixel: 12
RowsPerStrip: 1
StripByteCounts: [1×2000 double]
XResolution: []
YResolution: []
ResolutionUnit: 'Inch'
Colormap: []
PlanarConfiguration: 'Chunky'
TileWidth: []
TileLength: []
TileOffsets: []
TileByteCounts: []
Orientation: 1
FillOrder: 1
GrayResponseUnit: 0.0100
MaxSampleValue: [254 254 254 254 254 254 254 254 254 254 254 254]
MinSampleValue: [5 5 5 5 5 5 5 5 5 5 5 5]
Thresholding: 1
Offset: 48016624
ExtraSamples: [0 0 0 0 0 0 0 0 0 0 0]
SampleFormat: {1×12 cell}
ModelPixelScaleTag: [30 30 0]
ModelTiepointTag: [0 0 0 410000 3759000 0]
GeoKeyDirectoryTag: [1×60 double]
GeoDoubleParamsTag: [6.3782e+06 294.9787 0]
GeoAsciiParamsTag: 'UTM Zone 11, Northern Hemisphere|GCS Name = Clarke 1866|Datum = unknown|Ellipsoid = clrk66|Primem = Greenwich||'
% select three specific channels to form an RGB image
outpict = inpict(:,:,[4 3 2]);
imshow(outpict)
You can tell imread() which image in the file you want to retrieve. I guess it does them all if you don't specify and then you can just show the ones you want, like you did.

Sign in to comment.

More Answers (1)

Image Analyst
Image Analyst on 15 Apr 2023
Edited: Image Analyst on 15 Apr 2023
Possibly some of your parameters are wrong. But you forgot to attach your image so no one can check.
Since the image is a multi-page TIFF format, I suggest you use the imread to read in the different pages (band images).

Categories

Find more on Convert Image Type in Help Center and File Exchange

Products

Release

R2023a

Community Treasure Hunt

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

Start Hunting!