Can I make an automatic colorbar that ignores zeros?

12 Ansichten (letzte 30 Tage)
Yoav Romach
Yoav Romach am 5 Mär. 2017
Kommentiert: Scott Smith am 19 Aug. 2022
Hey,
I'm doing 2d scanning with matlab, I'm plotting the data using imagesc and I do it after every line scan. The initial value for the matrix is all zeros. This means that if I use "caxis auto" I always get that the lower bound for the picture's colorbar is zero and it only changes after after the whole picture is taken. See attached image.
I'm looking for a way to use the automatic colormap, but make it ignore the zeros in the picture. Is there anyway to do it?
Thanks

Akzeptierte Antwort

Image Analyst
Image Analyst am 5 Mär. 2017
Find the non-zero min of your data
maxValue = max(indexedImage);
minValue = min(indexedImage(indexedImage ~= 0));
caxis([minValue, maxValue]);
  1 Kommentar
Scott Smith
Scott Smith am 19 Aug. 2022
Just answered a question I've had for quite some time. Beautifly simple. Thank you.

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Colormaps 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!

Translated by