フィルターのクリア

Setting ColorScale to log makes imagesc show wrong colors

8 ビュー (過去 30 日間)
Aurelien Gregor
Aurelien Gregor 2021 年 7 月 26 日
コメント済み: Aurelien Gregor 2021 年 7 月 27 日
Hello all !
I've encountered a discrepancy within my imagesc figure between the value of the Index of a point and the color it is supposed to be according to the colorbar within my code.
I managed to reproduce this "error" using a simple script that you can try :
MyImage = pascal(10);
figure
hold on
im=imagesc(1:10,1:10, MyImage);
set(gca,'ColorScale','log')
h = colorbar;
colormap(hsv(5))
As you'll notice some squares do not have the color that it should have according to the colorbar, for example the point [X,Y]=[3 9] has index 45, which should be Yellow according to the colorbar, yet it is in red. Same with [X,Y]=[7 6] with index 462 appears yellow but should be green. There are several other points that have this discrepancy.
When I remove the "set(gca,'ColorScale','log')" line there doesn't appear to be this issue (even more obvious with my original images) so I suspect the error is related to this.
I'm not sure what I've done wrong, I have spent hours ripping my hair over this so any help is much appreciated.
Many thanks.
  2 件のコメント
Aurelien Gregor
Aurelien Gregor 2021 年 7 月 27 日
I managed to find an interesting answer here https://fr.mathworks.com/matlabcentral/answers/737702-how-to-get-logarithmic-colorbar-in-matlab-r2012a-for-3d-surface-plot which seems relevant to my issue although I am not sure if I understand it correctly.
Any help in applying this method to my code would be greatly appreciated.
Aurelien Gregor
Aurelien Gregor 2021 年 7 月 27 日
If anybody else is interested it seems Jonathan https://fr.mathworks.com/matlabcentral/answers/203697-logarithmic-scale-for-colorbar has found a decent workaround

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

回答 (0 件)

カテゴリ

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

製品


リリース

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by