图像增强技术
空域内增强
①灰度变换增强
close all;clear all;clc;
I=imread('E:\Matlab_exercise\图片素材\grayBeauty.jpg');
I=double(I);
J=(I-80)*200/100;
row=size(I,1);
column=size(I,2);
for i=1:row
for j=1:column
if J(i,j)<0;
J(i,j)=0;
end
if J(i,j)>255;
J(i,j)=255;
end
end
end
figure;
subplot(121);imshow(uint8(I));
subplot(122);imshow(uint8(J));
②直方图增强
灰度图像直方图
close all;clear all;clc;
I=imread('E:\Matlab_exercise\图片素材\grayBeauty.jpg');
figure;
subplot(121);imshow(I);
subplot(122);imhist(I);%获取灰度图像直方图
彩色图像直方图:imhist()
close all;clear all;clc;
I=imread('E:\Matlab_exercise\图片素材\lian.jpg');
figure;
subplot(141);imshow(uint8(I));
subplot(142);imhist(I(:,:,1));title('R');
subplot(143);imhist(I(:,:,2));title('G');
subplot(144);imhist(I(:,:,3));title('B');
直方图均衡化:histeq()
close all;clear all;clc;
I=imread('E:\Matlab_exercise\图片素材\grayBeauty.jpg');
J=histeq(I);%直方图均衡化
figure;
subplot(121);imshow(uint8(I));
subplot(122);imshow(uint8