why i get this error

1 次查看(过去 30 天)
sk ibrar ahmed
sk ibrar ahmed 2020-9-19
回答: KSSV 2020-9-19
i=imread('leaf_Pic_small.jpg');
s=imadjust(i,stretchlim(i,[0.05 0.95]),[]);
subplot(2,2,1), imshow(i), title('original');
subplot(2,2,2), imshow(s), title('stretched');
subplot(2,2,3), imhist(i), title('histogram of original img');
subplot(2,2,4), imhist(s), title('hist of stretched img');
>> leafproj
Error using imhist
Expected input number 1, I or X, to be two-dimensional.
Error in imhist>parse_inputs (line 278)
validateattributes(a,
{'double','uint8','int8','logical','uint16','int16','single','uint32',
'int32'}, ...
Error in imhist (line 60)
[a, n, isScaled, top, map] = parse_inputs(varargin{:});
Error in leafproj (line 5)
subplot(2,2,3), imhist(i), title('histogram of original img');

回答(1 个)

KSSV
KSSV 2020-9-19
Your image seems to be a RGB image. You have to use imhist on a 2D matrix. Not 3D image.
R = i(:,:,1) ;
G = i(:,:,2) ;
B = i(:,:,3) ;
figure
imhist(R)
figure
imhist(B)
figure
imhist(G)

Community Treasure Hunt

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

Start Hunting!

Translated by