## 伽马变换

	close all;clc;clear all;
subplot(1,3,1);imshow(I);title('原始图像');
c=cat(3,gamma(I(:,:,1),2),gamma(I(:,:,2),2),gamma(I(:,:,3),2));
subplot(1,3,2);imshow(c);title('伽马变换，gamma=2');
c=cat(3,gamma(I(:,:,1),0.5),gamma(I(:,:,2),0.5),gamma(I(:,:,3),0.5));
subplot(1,3,3);imshow(c);title('伽马变换，gamma=0.5');
function J=gamma(I,g)
c = 255^(1-g);
J = c * double(I).^g;
J = mat2gray(J);
end


## PROJECT 03-02 [Multiple Uses] Histogram Equalization

1. Write a computer program for computing the histogram of an image.
2. Implement the histogram equalization technique discussed in Section 3.3.1.

As a minimum, your report should include the original image, a plot of its histogram, a plot of the histogram-equalization transformation function, the enhanced image, and a plot of its histogram. Use this information to explain why the resulting image was enhanced as it was.

	I=imread('MizunoAi.jpg');
subplot(2,3,1);imshow(I);title('原始图像');subplot(2,3,4);imhist(I);
c=histeq(I);
subplot(2,3,2);imshow(c);title('直方均衡化·调库');subplot(2,3,5);imhist(c);
c=cat(3,histogram(I(:,:,1)),histogram(I(:,:,2)),histogram(I(:,:,3)));
subplot(2,3,3);imshow(c);title('直方均衡化');subplot(2,3,6);imhist(c);
function J=histogram(I)
J=I;
[n,m]=size(I);
a=zeros(1,256);
b=zeros(1,256);
for i=1:n
for j=1:m
a(1,I(i,j)+1)=a(1,I(i,j)+1)+1;
end
end
sum=0;
for i=1:256
sum=sum+a(1,i);
b(1,i)=255*sum/(m*n);
end
for i=1:n
for j=1:m
d=J(i,j)+1;
J(i,j)=b(1,d);
end
end
end


## PROJECT 03-05 Enhancement Using the Laplacian

1. Use the programs developed in Projects 03-03 and 03-04 to implement the Laplacian enhancement technique described in connection with Eq. (3.7-5). Use the mask shown in Fig. 3.39(d).
2. Duplicate the results in Fig. 3.40. You will need to download Fig. 3.40(a).

### 原理

1. 当拉普拉斯算子中心系数为正的时候，有$g(x,y)=f(x,y)+\triangledown^2f$
2. 当拉普拉斯算子中心系数为正的时候，有$g(x,y)=f(x,y)-\triangledown^2f$

### 源代码

close all;clc;
I=im2double(I);
J=zeros(size(I));
[M,N]=size(I);
for x=2:M-1
for y=2:N-1
J(x,y)=9*I(x,y);
for dx=-1:1
for dy=-1:1
J(x,y)=J(x,y)-I(x+dx,y+dy);
end
end
end
end
subplot(1,3,1);imshow(im2uint8(I));
subplot(1,3,2);imshow(im2uint8(J));
subplot(1,3,3);imshow(im2uint8(I+J));


### 运行结果

1. Use the programs developed in Projects 03-03 and 03-04 to implement highboost filtering, as given in Eq. (3.7-8). The averaging part of the process should be done using the mask in Fig. 3.34(a).
2. Download Fig. 3.43(a) and enhance it using the program you developed in (a). Your objective is to choose constant A so that your result visually approximates Fig. 3.43(d).

### 原理

1. 当拉普拉斯算子中心系数为正的时候，有$f_{hb}(x,y)=Af(x,y)+\triangledown^2f$
2. 当拉普拉斯算子中心系数为正的时候，有$f_{hb}(x,y)=Af(x,y)-\triangledown^2f$

### 源代码

close all;clc;
I=im2double(I);
J=zeros(size(I));
[M,N]=size(I);
for x=2:M-1
for y=2:N-1
J(x,y)=9*I(x,y);
for dx=-1:1
for dy=-1:1
J(x,y)=J(x,y)-I(x+dx,y+dy);
end
end
end
end
subplot(1,3,1);imshow(im2uint8(I+J));
subplot(1,3,2);imshow(im2uint8(1.5*I+J));
subplot(1,3,3);imshow(im2uint8(2*I+J));