How do I get a colormap for my image?
When I import my image using the imread function, I get a map with only zeros (map = []). I want the RGB components of the image, but cannot get them since this requires the picture’s colormap (which is empty). This is the code I’m using:
filename = uigetfile(‘*.*’);
[X, map] = imread(filename);
info = imfinfo(filename)
width = getfield(imfinfo(filename),’Width’)
height = getfield(imfinfo(filename),’Height’)
figure(‘Name’,’Display imported image’,’NumberTitle’,’off’);
image(X);
rgb = ind2rgb(X,map);
The info of the image is:
info =
Filename: ’11-11-11 (30).JPG’
FileModDate: ’11-Nov-2011 21:07:46′
FileSize: 4549123
Format: ‘jpg’
FormatVersion: ”
Width: 4320
Height: 2432
BitDepth: 24
ColorType: ‘truecolor’
FormatSignature: ”
NumberOfSamples: 3
CodingMethod: ‘Huffman’
CodingProcess: ‘Sequential’
Comment: {}
ImageDescription: ‘ ‘
Make: ‘SONY ‘
Model: ‘DSC-W350 ‘
Orientation: 1
XResolution: 72
YResolution: 72
ResolutionUnit: ‘Inch’
DateTime: ‘2011:11:11 21:07:46 ‘
YCbCrPositioning: ‘Co-sited’
DigitalCamera: [1×1 struct]
UnknownTags: [1×1 struct]
ExifThumbnail: [1×1 struct]
And then I get this error message:
??? Index exceeds matrix dimensions.
Error in ==> ind2rgb at 27
r = zeros(size(a)); r(:) = cm(a,1);
Error in ==> DSP_LCK at 24
rgb = ind2rgb(X,map);
Some advice please?When I import my image using the imread function, I get a map with only zeros (map = []). I want the RGB components of the image, but cannot get them since this requires the picture’s colormap (which is empty). This is the code I’m using:
filename = uigetfile(‘*.*’);
[X, map] = imread(filename);
info = imfinfo(filename)
width = getfield(imfinfo(filename),’Width’)
height = getfield(imfinfo(filename),’Height’)
figure(‘Name’,’Display imported image’,’NumberTitle’,’off’);
image(X);
rgb = ind2rgb(X,map);
The info of the image is:
info =
Filename: ’11-11-11 (30).JPG’
FileModDate: ’11-Nov-2011 21:07:46′
FileSize: 4549123
Format: ‘jpg’
FormatVersion: ”
Width: 4320
Height: 2432
BitDepth: 24
ColorType: ‘truecolor’
FormatSignature: ”
NumberOfSamples: 3
CodingMethod: ‘Huffman’
CodingProcess: ‘Sequential’
Comment: {}
ImageDescription: ‘ ‘
Make: ‘SONY ‘
Model: ‘DSC-W350 ‘
Orientation: 1
XResolution: 72
YResolution: 72
ResolutionUnit: ‘Inch’
DateTime: ‘2011:11:11 21:07:46 ‘
YCbCrPositioning: ‘Co-sited’
DigitalCamera: [1×1 struct]
UnknownTags: [1×1 struct]
ExifThumbnail: [1×1 struct]
And then I get this error message:
??? Index exceeds matrix dimensions.
Error in ==> ind2rgb at 27
r = zeros(size(a)); r(:) = cm(a,1);
Error in ==> DSP_LCK at 24
rgb = ind2rgb(X,map);
Some advice please? When I import my image using the imread function, I get a map with only zeros (map = []). I want the RGB components of the image, but cannot get them since this requires the picture’s colormap (which is empty). This is the code I’m using:
filename = uigetfile(‘*.*’);
[X, map] = imread(filename);
info = imfinfo(filename)
width = getfield(imfinfo(filename),’Width’)
height = getfield(imfinfo(filename),’Height’)
figure(‘Name’,’Display imported image’,’NumberTitle’,’off’);
image(X);
rgb = ind2rgb(X,map);
The info of the image is:
info =
Filename: ’11-11-11 (30).JPG’
FileModDate: ’11-Nov-2011 21:07:46′
FileSize: 4549123
Format: ‘jpg’
FormatVersion: ”
Width: 4320
Height: 2432
BitDepth: 24
ColorType: ‘truecolor’
FormatSignature: ”
NumberOfSamples: 3
CodingMethod: ‘Huffman’
CodingProcess: ‘Sequential’
Comment: {}
ImageDescription: ‘ ‘
Make: ‘SONY ‘
Model: ‘DSC-W350 ‘
Orientation: 1
XResolution: 72
YResolution: 72
ResolutionUnit: ‘Inch’
DateTime: ‘2011:11:11 21:07:46 ‘
YCbCrPositioning: ‘Co-sited’
DigitalCamera: [1×1 struct]
UnknownTags: [1×1 struct]
ExifThumbnail: [1×1 struct]
And then I get this error message:
??? Index exceeds matrix dimensions.
Error in ==> ind2rgb at 27
r = zeros(size(a)); r(:) = cm(a,1);
Error in ==> DSP_LCK at 24
rgb = ind2rgb(X,map);
Some advice please? digital image processing, rgb MATLAB Answers — New Questions