Generate an indexed image
20 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
Claudia Lucia Silva Olvera
il 1 Dic 2021
Commentato: Claudia Lucia Silva Olvera
il 1 Dic 2021
How do I create an indexed image to import into Matlab?. Thanks
0 Commenti
Risposta accettata
Image Analyst
il 1 Dic 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';
0 Commenti
Più risposte (1)
Benjamin Kraus
il 1 Dic 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 Commenti
Benjamin Kraus
il 1 Dic 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?
Vedere anche
Prodotti
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!