I wanted to plot the histogram of the attached data with number of bins = 42
When i use
figure, imhist(HRGB,42)
I get just 2 vertical lines at 0 and 1.
Instead, how can i get histogram with number of bins 42, or is the below code correct?
h = histogram(HRGB,42);
Or is there a better way to plot the histogram of the attached data?

댓글 수: 3

KSSV
KSSV 2022년 6월 2일
What is your necessity?
Elysi Cochin
Elysi Cochin 2022년 6월 2일
Appearance of the plot
Star Strider
Star Strider 2022년 6월 2일
If the image is a binary created by imbinarize or im2bw, there are only two values, 0 and 1.

댓글을 달려면 로그인하십시오.

 채택된 답변

Chunru
Chunru 2022년 6월 2일

1 개 추천

load Xdata
% whos
figure; imshow(Xdata);
unique(Xdata(:))'
ans = 1×19
0 1 4 16 17 20 21 22 24 25 26 32 33 36 37 38 40 41 42
imhist assumes Xdata in the range of [0,1]. Therefore you have only two bins for 0 & 1 with your data
figure;
imhist(Xdata, 42)
You can rescale the data:
figure;
imhist(rescale(Xdata), 42);
Or you can use hist
figure
hist(Xdata(:), 42)

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Histograms에 대해 자세히 알아보기

태그

질문:

2022년 6월 2일

댓글:

2022년 6월 2일

Community Treasure Hunt

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

Start Hunting!

Translated by