determining color image format :

조회 수: 2 (최근 30일)
sidharth mahotra
sidharth mahotra 2011년 9월 12일
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
Ashish Uthama
Ashish Uthama 2011년 9월 12일
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.

댓글을 달려면 로그인하십시오.

답변 (1개)

John
John 2011년 9월 12일
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
sidharth mahotra
sidharth mahotra 2011년 9월 12일
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 2011년 9월 12일
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.

댓글을 달려면 로그인하십시오.

Community Treasure Hunt

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

Start Hunting!

Translated by