MATLAB: How to remove the black line from the bottom of histogram plotting

histogramImage Processing Toolboxplotting

My code is as below:
f=imread('D:\001_1.bmp');
figure(1)
imshow(f,[]);
figure(2)
imhist(f);axis([0 255 0 140]);

Best Answer

Try this:
fontSize = 20;
grayImage=imread('cameraman.tif');
subplot(1,2,1)
imshow(grayImage,[]);
axis on
subplot(1,2,2)
[counts, bins] = histcounts(grayImage, 256);
bar(bins(1:end-1), counts, 'BarWidth', 1);
title('Histogram', 'FontSize', fontSize);
xlabel('Gray Level', 'FontSize', fontSize);
ylabel('PixelCount', 'FontSize', fontSize);
grid on;
xlim([0,256])
% Set up figure properties:
% Enlarge figure to full screen.
set(gcf, 'Units', 'Normalized', 'OuterPosition', [0 0 1 1]);
% Get rid of tool bar and pulldown menus that are along top of figure.
set(gcf, 'Toolbar', 'none', 'Menu', 'none');
% Give a name to the title bar.
set(gcf, 'Name', 'Demo by ImageAnalyst', 'NumberTitle', 'Off')
Related Question