フィルターのクリア

How to limit the colorbar range in using image function ??

20 ビュー (過去 30 日間)
제 허
제 허 2021 年 6 月 30 日
コメント済み: 제 허 2021 年 7 月 1 日
hello
I want to limit the colorbar range in using image function.
caxis([0 10]) comment can limit the range other function (i.e mesh), but can not work at image function.
how I limit the colorbar range??
thank you.

採用された回答

Walter Roberson
Walter Roberson 2021 年 6 月 30 日
caxis works fine with image()
figure
img = imread('cameraman.tif');
image(img)
colormap(hsv)
caxis([0 10])
colorbar
But remember that colorbar() does not reflect RGB objects
figure
img = imread('flamingos.jpg');
image(img)
colormap(hsv)
caxis([0 10])
colorbar
  3 件のコメント
Walter Roberson
Walter Roberson 2021 年 6 月 30 日
I see what you mean; caxis() is not changing the colorbar() limit
Fortunately you can pass in the limits in the colorbar() call.
[R, TH] = ndgrid(complex(1:11, -5:5), linspace(0,2*pi));
[X, Y] = pol2cart(TH, R);
Z = X.^2 - 3.*X.*Y + Y;
figure
surf(real(X), real(Y), real(Z), 'edgecolor', 'none')
figure
surf(imag(X), imag(Y), imag(Z), 'edgecolor', 'none')
figure
RZ = real(Z);
image(RZ)
cb = colorbar('limits', [-50 50]);
cb
cb =
ColorBar with properties: Location: 'eastoutside' Limits: [-50 50] FontSize: 9 Position: [0.8311 0.1109 0.0381 0.8152] Units: 'normalized' Show all properties
제 허
제 허 2021 年 7 月 1 日
Thank you for your answer

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

その他の回答 (0 件)

カテゴリ

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

Community Treasure Hunt

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

Start Hunting!

Translated by