How to use colormap() for a vector of images X in order to display indexed images from vector X?

1 visualización (últimos 30 días)
I have made a Neural network for clothes color matching. It uses indexed images of clothes stored in a vector X. when I try to display these indexed images they appear to be pale instead of colored. I am using a custom function displayData for display. Although Neural network with indexed images is working correctly (with reasonable accuracy) but it displays to user only pale images in beginning and during testing. I came to know that somewhere I should use colormap() function. I called colormap() right after calling displayData but it does not work
fprintf('Loading cloth Data\n')
load('myclothingdata.mat');
m = size(X, 1);
[sel] = randperm(size(X, 1));
sel = sel(1:100);
displayData(X(sel, :));
% colormap()
fprintf('Press enter for next step.\n');
It calls the following displayData function
the output is as follows, showing indexed images of clothes
  4 comentarios
jawad ashraf
jawad ashraf el 4 de Sept. de 2018
Editada: jawad ashraf el 4 de Sept. de 2018
Now I have attached ClothingNeuralNetwork zip file that comprises complete coding files of project minus myclothingdata.mat which I have attached separately in above comment.
you please include myclothingdata.mat in this parent scripting folder and then run MainFile.m on MATLAB.
jawad ashraf
jawad ashraf el 7 de Sept. de 2018
New post link
https://www.mathworks.com/matlabcentral/answers/418072-how-to-display-indexed-images-from-mat-file-using-colormap

Iniciar sesión para comentar.

Respuestas (1)

Benjamin Kraus
Benjamin Kraus el 4 de Sept. de 2018
The issue you are encountering is that displayData is normalizing the image data so that the maximum value of each image is equal to 1. It is then using imagesc to display the image using the full range of the colormap. Because your image is indexed and using a special map, the map is being lost by normalizing the data.
Unfortunately, I don't think you are going to be able to use displayData unmodified, it just isn't designed to handle indexed images.
However, you could try something potentially better. displayData is relying on -1 being a special value, which it is using to display gray lines. Because you are working with indexed colors, you can just add a gray/black color to the end of your map. Relatively small changes to displayData should allow you to get this working.
For example:
  1. Replace -1 (Setup blank display) with the last color in your map, max(X(:)+1.
  2. Remove the normalization using max_val.
  3. Replace the call to imagesc with just a regular call to image.
  4 comentarios
jawad ashraf
jawad ashraf el 6 de Sept. de 2018
I tried what you suggested but it did not work. You please check it yourself and if you make required changes I will be Obliged to you as this is my first project in MATLAB and I can't understand much things.
Benjamin Kraus
Benjamin Kraus el 6 de Sept. de 2018
"If you can't get it working and want more assistance ... make sure to update the post to describe what new things you have tried and what issue you are running into."

Iniciar sesión para comentar.

Categorías

Más información sobre Colormaps en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by