Properly scale histogram in subplot and error handling

Hey there,
when I am trying to subplot an image and its histogram the histogram is stretched too far in vertical space. I am also getting the following error code:
% Error using imageDisplayValidateParams
% Expected input number 1, I, to be one of these types:
% numeric, logical
% Instead its type was matlab.graphics.chart.primitive.Histogram.
The code I am using is the following and this should be reproduceable with any image I think:
IMG = imread('img.tif');
subplot(1,2,1); imshow(IMG);
subplot(1,2,2); imshow(histogram(IMG));
Does someone know how to fix this error and how to properly resize the histogram?
Thank you in advance!

 채택된 답변

KALYAN ACHARJYA
KALYAN ACHARJYA 2019년 12월 6일
IMG = imread('img.tif');
subplot(1,2,1); imshow(IMG);
subplot(1,2,2); histogram(IMG);

댓글 수: 3

Thank you very much, this for startes solves the error that occured.
Is there any way to resize the histogram? When plotted next to each other the histogram is stretched verticaly and it looks kind of odd.
IMG = imread('img.tif');
subplot(2,1,1); imshow(IMG);
subplot(2,1,2); histogram(IMG);
The axes autosize according to the figure width. You can click and drag the figure edge to resize it until the histogram size matches the image size.

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

추가 답변 (0개)

카테고리

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

제품

릴리스

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by