Generate an indexed image
21 ビュー (過去 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!