MATLAB: Convert it into index type homeworkMATLAB I have this two Question : 1)Read the image (‘flage.png’)? 2)Convert it into index type and display it ? I solved the first one : image_mat = imread('flage.png'); But How can i solve the second one ? Best Answer [image_mat, cmap] = imread('flage.png'); if isempty(cmap) if ndims(image_mat) > 2 image_rgb = image_mat; else image_rgb = repmat(image_mat, [1 1 3]); end else image_rgb = ind2rgb(image_mat, cmap); end imshow(image_rgb) Related SolutionsMATLAB: Grayimage back to green blackImage = zeros(size(grayImage), 'uint8');rgbImage = cat(3, blackImage, grayImage, blackImage);Or you can use ind2rgb():cmap = [zeros(256,1), (0:255)', zeros(256,1)]rgbImage = uint8(ind2rgb(grayImage, cmap)); MATLAB: Loaded Image Doesn’t Retain Separate Colors Tryfig = figure;ax = axes('Parent', fig);[im, cmap] = imread('US.png');if isempty(cmap) im = im2double(im); cmap = summer;endimage(im, 'Parent', ax);colormap(cmap); Related QuestionFind local differences in a matrixFind summation of all the element in the matrixHow to export .png image made by “imagesc” with specific size of 32*32 pixels
Best Answer