Generate an indexed image
20 次查看(过去 30 天)
显示 更早的评论
Claudia Lucia Silva Olvera
2021-12-1
评论: Claudia Lucia Silva Olvera
2021-12-1
How do I create an indexed image to import into Matlab?. Thanks
0 个评论
采纳的回答
Image Analyst
2021-12-1
Try this:
% Demo by Image Analyst
clc; % Clear the command window.
close all; % Close all figures (except those of imtool.)
clear; % Erase all existing variables. Or clearvars if you want.
workspace; % Make sure the workspace panel is showing.
format long g;
format compact;
fontSize = 20;
markerSize = 40;
% Read in original RGB image and display it.
originalImage = imread('peppers.png');
subplot(2, 1, 1);
imshow(originalImage);
impixelinfo;
title('Original Image', 'FontSize', fontSize)
% Create indexed image with 6 colors.
numColors = 6;
[indexedImage, cmap] = rgb2ind(originalImage, numColors);
% Save it to disk.
imwrite(indexedImage, cmap, 'indexedImage.png');
% Read indexed image back in from disk.
[recalledImage, storedColorMap] = imread('indexedImage.png');
% Display it.
subplot(2, 1, 2);
imshow(recalledImage, 'Colormap', storedColorMap);
caption = sprintf('Indexed Image with %d Colors', numColors);
title(caption, 'FontSize', fontSize)
% Display color bar and adjust range from 0-255 to 0-numColors.
colorbar;
caxis([0, numColors])
impixelinfo;
% Maximize figure window.
g = gcf;
g.WindowState = 'maximized';
0 个评论
更多回答(1 个)
Benjamin Kraus
2021-12-1
Are you trying to create an indexed image in MATLAB? Or are you asking what programs (aside from MATLAB) can be used to create indexed image?
Some resources that may help:
If those links don't help, I think you are going to need to add a lot more detail to your question to get a helpful answer.
3 个评论
Benjamin Kraus
2021-12-1
Aside from using MATLAB itself to read in an image and transform it into an indexed image (MATLAB can read and write indexed and non-indexed images), I'm not familiar with what other image editing programs can be used to do that.
Why do you need to transform an image into an indexed image before reading it into MATLAB? Why not just read it directly into MATLAB?
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!