%reads the image in name.tif into I
%creats a new figure window
直方图均衡化:
%histgram regulization clc;
%clear command window
I=imread('00911.tif');
subplot(2,2,1);
imshow(I);
%displays the intensity image I with 256 gray levels title(' 处 理 前 的 图 像 ');
subplot(2,2,2);
imhist(I);
title('图像处理前的直方图');
%displays a histogram for the intensity image I
J=histeq(I,64);
% transforms the
discreate levels
subplot(2,2,3);
imshow(J);
title('均衡化后的图像');
subplot(2,2,4);
imhist(J);
title('均衡化后图像的直方图');
intensity image I,returning in J intensity
image with 64
灰度拉伸
clc;
close all;
I=imread('lena.bmp');
y=imadjust(I,stretchlim(I),[0 1]); %灰度拉伸
subplot(121);
imshow(I);
title('原始图像');
subplot(122);
imshow(y);
title('灰度拉伸后的图像');
中值滤波
clear all;
I=imread('04209.tif');
subplot(1,2,1);
imshow(I);
title('原始图像');
K1=medfilt2(I,[3,3]);
subplot(1,2,2);
imshow(K1);
title('3*3 中值滤波后的结果');
同态滤波
clear all;
I = imread('00911.tif');
[M N] = size(I);
subplot(1,2,1);
imshow(I);
title('处理前的图像');
T = double(I);
L = log(T);
F = fft2(L);
for i = 1:M
for j = 1:N
D(i,j) = ((i-M/2)^2+(j-N/2)^2);
end
end
c = 1.05;
Do = max(M,N);
H = (2.0-0.5)*(1 - exp(c*(-D/(Do^2)))) + 0.5;
F = F .* H;
F = ifft2(F);
Y = exp(F);
subplot(1,2,2);
imshow(uint8(Y));
title('同态滤波处理后的图像');