Hi every body.
I have an image of size 512*512 in .tif format. when i use imread to import it in matlab, the output is 512*512*4. what does that 4 mean? how can i convert it to 512*512?

 Akzeptierte Antwort

John D'Errico
John D'Errico am 20 Jun. 2020

0 Stimmen

This is a 4 channel image. For example, typically we think of an image as represented by {R,G,B} code values for each pixel location. In that case, you will see a 512x512x3 array. That represents a standard COLOR image.
If you want only a 512x512 array, then you will lose all color information. This can be done using a tool like rgb2gray, IF you were starting with an RGB image. The result will be a grayscale image, so only one channel.
But you have a 4 channel image. This can means several things. Does it represent perhaps CMYK code values? Those could be essentially printer drive values, used by many color printers. Or is this a hyper-spectral image of some ilk, thus sampling 4 different wavelengths of light? So if you have a 512x512x4 array, you need to know what the numbers represent. And only you know what they mean.

4 Kommentare

Shiv srikakolum
Shiv srikakolum am 24 Nov. 2021
I have an Image 1512x2016X3 if i want to convert it to 512x512x3 then what command should i use
@Shiv srikakolum, I'd use imresize()
resizedImage = imresize(originalImage, [512, 512]);
Walter Roberson
Walter Roberson am 24 Nov. 2021
The most common 512 x 512 x 4 .tiff representations would probably be: RGBA (RGB + alpha), CMYK (better for printers), and RGBNr where Nr here refers to Near-Infrared.
CYMK can be determined by the colorspace information in the TIFF headers.
RGBA can be determined by examine of the information about alpha values in the TIFF headers.
RGBNr is more difficult to determine: it is stored as RGB together with "additional data", but there is no particular header to examine to determine what the "additional data" means (RGBA also has the alpha stored as "additional data", but can be picked out by careful reading of some of the standard headers, if I recall correctly.)
Shiv srikakolum
Shiv srikakolum am 25 Nov. 2021
@Image Analyst Thank You

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Convert Image Type finden Sie in Hilfe-Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by