automatically scale display range to eliminate outliers

3 ビュー (過去 30 日間)
Emily
Emily 2022 年 4 月 25 日
編集済み: Chunru 2022 年 4 月 26 日
I'm currently using imagesc and imcontrast.
I was curious if it possible to have a script where it will automatically scale display range to eliminate outliers: 2% instead of manually changing the contrast when the figure is up.

採用された回答

Chunru
Chunru 2022 年 4 月 26 日
編集済み: Chunru 2022 年 4 月 26 日
y = randn(50, 50);
y (20, 20) = 1e8; % outlier
subplot(121)
imagesc(y); % outlier removed
colorbar
subplot(122)
imagesc_autoscale(y); % outlier removed
colorbar
function imagesc_autoscale(x)
s = prctile(x, [2 98], 'all');
imagesc(x);
clim(s);
end

その他の回答 (0 件)

Community Treasure Hunt

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

Start Hunting!

Translated by