Generate an indexed image

23 vues (au cours des 30 derniers jours)
Claudia Lucia Silva Olvera
How do I create an indexed image to import into Matlab?. Thanks

Réponse acceptée

Image Analyst
Image Analyst le 1 Déc 2021
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';

Plus de réponses (1)

Benjamin Kraus
Benjamin Kraus le 1 Déc 2021
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 commentaires
Benjamin Kraus
Benjamin Kraus le 1 Déc 2021
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?
Claudia Lucia Silva Olvera
Hi Benjamin
The truth did not know that the transformation could be done in MATLAB.
Thanks
Nice day

Connectez-vous pour commenter.

Catégories

En savoir plus sur Images dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by