How to display indexed images from .mat file using colormap?

3 vues (au cours des 30 derniers jours)
jawad ashraf
jawad ashraf le 7 Sep 2018
Commenté : Walter Roberson le 11 Sep 2018
I have a vector matrix 'X' which contains 700 indexed images. I want to display some of images on grid. For displaying purpose I am using a function displayData which is meant for grayscale images. How can I display indexed images ? I am using following displayData function. https://github.com/aptiva0985/MachineLearning-Andrew-Ng-Coursera-/blob/master/ML003/mlclass-ex3/displayData.m

Réponses (2)

Image Analyst
Image Analyst le 7 Sep 2018
Try using imshow() and colormap().
What is X? A vector matrix sounds contradictory. Do have a 1-D array of 700 cells, where inside each cell is one indexed image?
By the way, a gray scale image can be considered an indexed image - you just apply a colormap to it just like you do to any indexed image.
  19 commentaires
Walter Roberson
Walter Roberson le 11 Sep 2018
You can use up to uint64 for indexed images. However rgb2ind is limited to 65536 colours.
Walter Roberson
Walter Roberson le 11 Sep 2018
It would be completely valid for rgb2ind to return different color indices for any given color for two images that are exactly the same except one is the upside down of the other. There is no inherent ordering of the colors. For the same image in different rotations then the same colors should be found, but the index order is not fixed by the algorithm.

Connectez-vous pour commenter.


Guillaume
Guillaume le 10 Sep 2018
Having looked at the code for your displayData, it is not possible to use it with indexed images with different colour maps without a major rewrite. That function builds a single matrix out of all the images so whatever colour map you'd use would always apply to all images.
The simplest way to do what you want would be to use subplot and imshow to let matlab build the grid of images. The one downside with that is that by default matlab leaves a lot of spacing between the subplots. The code to be a 5x10 array of images would be something like:
%inputs:
%clothingimages: a cell array of images
%colourmaps: a cell array of colourmaps
imgindex = 1;
figure;
for row = 1:5
for col = 1:10
subplot(5, 10, imgindex);
imshow(clothingimages{imgindex}, colourmaps{imgindex});
imgindex = imgindex + 1;
end
end

Catégories

En savoir plus sur Modify Image Colors 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