fix problem for The length of X must match the number of rows of Y. in matlab

Hello, When i using this code , this problem is appered
can you help me
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
im=imread('fig3.tif'); % Read image & store as 'im'
h = rgb2gray(im);
imhist(h,25);
horz=linspace(0,255,25);
stem(horz,h,'fill') ;
axis([0 255 0 60000]) ;
set(gca,'xtick', 0:50:255) ;
set(gca,'ytick',0:20000:60000);

 Accepted Answer

In
stem(horz,h,'fill') ;
your horz has 25 values, but your h is the result of rgb2gray() and so is an array with the same height and width as your original image.
Perhaps you want something like,
[counts, x] = imhist(h,25);
stem(x, counts, 'fill')

More Answers (0)

Community Treasure Hunt

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

Start Hunting!