作者:楼外蔷薇花开 | 来源:互联网 | 2023-10-13 15:37
用matlab实现一种灰度变换增强图像。clearY1imread('lena2.jpg');Y1rgb2gray(Y1);figureimshow(uint8
clear
Y1=imread('lena2.jpg');
Y1=rgb2gray(Y1);
figure
imshow(uint8(Y1));
vmax=max(max(Y1));
vmin=min(min(Y1));
C1=255/double(vmax-vmin);
Y2=C1*(Y1-vmin);
Y2=round(Y2);
figure
imshow(uint8(Y2));
- 用 matlab 做出图像的直方图(注意:不能直接调用 Matlab 中的直方图生成函数 imhist)。
clear
X=imread('lena.jpg');
X=rgb2gray(X);
[m,n]=size(X);
N=zeros(1,256);
for i=1:m
for j=1:n
k=X(i,j);
N(k+1)=N(k+1)+1;
end
end
figure;
subplot(1,2,1);
imshow(uint8(X));
subplot(1,2,2);
bar(N);
axis tight;