Filter löschen
Filter löschen

determining color image format :

7 Ansichten (letzte 30 Tage)
sidharth mahotra
sidharth mahotra am 12 Sep. 2011
hi, we can use "imfinfo" to get information about the color image files and subsequently read using "imread".however, if the file is say "tiff" and the type is RGB, the imfinfo tells that file format is RGB. but, can we know if the file format is BGR using imfinfo, that is would imfinfo work if the file format was BGR? similarly, would imread store the image as BGR if the input image as BGR? also, can we know if the format is Planar or interleaved?
for example, in the code below, I would extract red image if the format was RGB, but if the actual format was BGR but imfinfo still shows this as RGB and imread also does the same, I would actually extract Blue image using I_rgb(:,:,1)
I_info= imfinfo(strcat(pth,'pic1.tif'));
file_format = I_info.PhotometricInterpretation;
I_rgb= imread(strcat(pth,'pic1.tif'),'tiff');
%***get individual components*****
I_R= I_rgb(:,:,1);
  1 Kommentar
Ashish Uthama
Ashish Uthama am 12 Sep. 2011
I am curious to know the source of these BGR images. I believe the ordering RGB is fixed for the Tiff file. If a writer conceptually changed the order, then unless they signal this in some additional meta-data in the file, there is no way any reader could differentiate it from a regular RGB file.

Melden Sie sich an, um zu kommentieren.

Antworten (1)

John
John am 12 Sep. 2011
If the photometric interpretation tag in the TIFF file says RGB, then IMFINFO will report just that. IMREAD and the Tiff class will hand off the image data to you with what is presumed to be the red channel in the first layer, the green channel in the 2nd layer, and the blue channel in the 3rd layer.
If the samples in the file aren't actually stored as "RGBRGBRGB..." then you would have to reinterpret the image data yourself.
Take a look at the 'PlanarConfiguration' field to see if the TIFF is planar or interleaved.
  2 Kommentare
sidharth mahotra
sidharth mahotra am 12 Sep. 2011
hi, so you mean first check the file (say in Irfanview) to know
correct sequence and then extract individual planes in matlab accordingly?
sedy
Ashish Uthama
Ashish Uthama am 12 Sep. 2011
You could view it in MATLAB as well (image/imshow). The format itself does not have any means of flagging a non-standard color ordering, so this information is 'external' to the file.

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu Read, Write, and Modify Image finden Sie in Help 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