What does rgb palette mean?
Show older comments
Hi,
Could someone explain what exactly "rgb palette" is, and how I can convert it to grayscale? I was trying to use rgb2gray with a .tif image, and I kept getting an error message about the matrix needing to be a "m x 3 array". I used imfinfo with the picture that was giving me trouble and it told me that the photometric interpretation is "rgb palette."
Thanks in advance!
EDIT: my code is what everyone says should work, which is shown as follows:
newpic = rgb2gray('Image008_ch00.tif');
disp(t)
I think it has to do with the image I'm using, as it works for other images. The error message I keep getting is:
??? Error using ==> rgb2gray>parse_inputs at 82
MAP must be a m x 3 array.
Error in ==> rgb2gray at 35
X = parse_inputs(varargin{:});
Error in ==> tester at 1
newpic = rgb2gray('Image008_ch00.tif');
I figured it might have to do with the image itself, so I used imfinfo and got this information
Filename: 'Image008_ch00.tif'
FileModDate: '04-Apr-2013 18:21:40'
FileSize: 1050592
Format: 'tif'
FormatVersion: []
Width: 1024
Height: 1024
BitDepth: 8
ColorType: 'indexed'
FormatSignature: [73 73 42 0]
ByteOrder: 'little-endian'
NewSubFileType: 0
BitsPerSample: 8
Compression: 'Uncompressed'
PhotometricInterpretation: 'RGB Palette'
StripOffsets: [16x1 double]
SamplesPerPixel: 1
RowsPerStrip: 64
StripByteCounts: [16x1 double]
XResolution: 4.1621e+004
YResolution: 4.1621e+004
ResolutionUnit: 'Centimeter'
Colormap: [256x3 double]
PlanarConfiguration: 'Chunky'
TileWidth: []
TileLength: []
TileOffsets: []
TileByteCounts: []
Orientation: 1
FillOrder: 1
GrayResponseUnit: 0.0100
MaxSampleValue: 255
MinSampleValue: 0
Thresholding: 1
Offset: 1048584
ImageDescription: []
Software: 'TCSNTV '
DateTime: ' 0:00:00 00:00:00 '
Artist: 'Unknown '
HostComputer: 'No. of Processors: 2, Type: 586, Level: 6, Revision 3846 '
1 Comment
Jan
on 11 Jun 2013
Please post a copy of the error message and show us the correcponding code. A rough rephrasing frequently hides important details, most of all if the problem is not clear to the asking user.
Accepted Answer
More Answers (1)
Hugo
on 11 Jun 2013
0 votes
RGB means Red Green Blue, and rgb2gray needs an mx3 matrix because each column in that matrix represents red (first column), green (second column), and blue (third column), while each row represents the amount of each primary colour that is combined to give the final colour you see.
The conversion (formula) from RGB to GRAY used by rgb2gray is shown at the end of the help of rgb2gray.
So, the problem seems to be why you get something that is not mx3! Have you checked that you are following the structure of the examples in the help of rgb2gray? I mean, are you sure you are feeding the right matrix?
I hope this helps. Best regards
Categories
Find more on Images in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!