hist.m

来自「Image enhancement in spatial domain, the」· M 代码 · 共 25 行

M
25
字号
% Program to compute the histogram of an Image
clear all 
clc
a=imread('Hills.bmp');
a=double(a);
[row col]=size(a);
h=zeros(1,300);
for n=1:1:row
for m=1:1:col
    if a(n,m)==0           %% To ensure that the values of a are not zero
           a(n,m)=1;
    end
end
end
for n=1:1:row
    for m=1:1:col
        t=a(n,m);          %% Takes the value of the Pixel
        h(t)=h(t)+1;       %% Incrementing each counter
    end
end
figure(1);
imshow(uint8(a));
figure(2);
bar(h)

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?