imagesc make all negatives values black
7 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
I have the following code which is part of a subplot series. I want to change it so that all negative values become a certain colour (preferably black). I am stuck as to how to achieve this.
figure(3)
subplot(3,3,1)
imagesc(coeffA40)
title ('A40 Coefficients')
caxis([minCoeff, maxCoeff])
myColorMap = hsv(256);
myColorMap(1,:) = 1;
colormap(myColorMap);
grid on
ax = gca
ax.LineWidth = .75
ax.GridColor = 'k'
ax.GridAlpha = .2
ax.XTick = [10 20 30 40];
ax.YTick = [10 20 30];
ax.XTickLabel = {'', '', '', ''};
ax.YTickLabel = {'','',''};
ax.TickLength =[0.0 0.0]
ax.XTickLabelRotation = 45
Thank you in advance for any help!
0 Kommentare
Antworten (1)
Image Analyst
am 29 Mär. 2016
Several ways. One is to create a temporary image
displayedImage = coeffA40; % Initialize
displayedImage(displayedImage <=0) = 0;
cmap = jet(256);
cmap(1,:) = 0; % Lowest gray level appears black.
imshow(displayedImage);
colormap(cmap);
colorbar;
Another might be to alter the colormap so that it applies between 0 and the max.
cmap = jet(256);
cmap(1,:) = 0; % Lowest gray level appears black.
imshow(coeffA40);
colormap(cmap);
colorbar;
caxis([0, max(coeffA40(:))]);
(Both of these are untested - just off the top of my head.)
3 Kommentare
Image Analyst
am 29 Mär. 2016
Set the nans to the max value (or the white value) before display, something like:
displayedImage(isnan(displayedImage)) = max(displayedImage(:));
Walter Roberson
am 29 Mär. 2016
image(coeffA40, 'AlphaData', double(~isnan(coeffA40)) )
Siehe auch
Kategorien
Mehr zu Blue finden Sie in Help Center und File Exchange
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!