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

2 ビュー (過去 30 日間)
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 件のコメント
jawad ashraf
jawad ashraf 2018 年 9 月 4 日
編集済み: jawad ashraf 2018 年 9 月 4 日
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 2018 年 9 月 7 日
New post link
https://www.mathworks.com/matlabcentral/answers/418072-how-to-display-indexed-images-from-mat-file-using-colormap

サインインしてコメントする。

回答 (1 件)

Benjamin Kraus
Benjamin Kraus 2018 年 9 月 4 日
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 件のコメント
jawad ashraf
jawad ashraf 2018 年 9 月 6 日
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 2018 年 9 月 6 日
"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."

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeColormaps についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by