www.pudn.com > fractional-differential.rar > Enhance_contrast2.m, change:2013-09-09,size:2673b

```%%  对比两种不同的使用八个方向分别进行分数阶微分
close all
clear all
clc
figure(1),imshow(img);
title('原图像');
% img = im2double(img);
[H L] = size(img);

%%
v = 0.2;
a0 = 1;
a1 = -v;
a2 = (v)*(v-1)/2;
% a3 = -(v)*(v-1)*(v-2)/6;
% a4 = (v)*(v-1)*(v-2)*(v-3)/24;

F_0_pos = [0 0 0 0 0; 0 0 0 0 0; 0 0 a0 a1 a2; 0 0 0 0 0; 0 0 0 0 0 ];%  0°正方向(postive)
F_0_neg = [0 0 0 0 0; 0 0 0 0 0; a2 a1 a0 0 0; 0 0 0 0 0; 0 0 0 0 0 ];%  0°负方向(negetive)
F_90_pos = [0 0 a2 0 0; 0 0 a1 0 0; 0 0 a0 0 0; 0 0 0 0 0; 0 0 0 0 0 ];%  90°正方向
F_90_neg = [0 0 0 0 0; 0 0 0 0 0; 0 0 a0 0 0; 0 0 a1 0 0; 0 0 a2 0 0 ];%  90°负方向
F_45_pos = [0 0 0 0 a2; 0 0 0 a1 0; 0 0 a0 0 0; 0 0 0 0 0; 0 0 0 0 0 ];%  45°正方向
F_45_neg = [0 0 0 0 0; 0 0 0 0 0; 0 0 a0 0 0; 0 a1 0 0 0; a2 0 0 0 0 ];%  45°负方向
F_135_pos = [a2 0 0 0 0; 0 a1 0 0 0; 0 0 a0 0 0; 0 0 0 0 0; 0 0 0 0 0 ];%  135°正方向
F_135_neg = [0 0 0 0 0; 0 0 0 0 0; 0 0 a0 0 0; 0 0 0 a1 0; 0 0 0 0 a2 ];%  135°负方向

Im_0_pos = imfilter(img,F_0_pos,'conv');
Im_0_neg = imfilter(img,F_0_neg,'conv');
Im_90_pos = imfilter(img,F_90_pos,'conv');
Im_90_neg = imfilter(img,F_90_neg,'conv');
Im_45_pos = imfilter(img,F_45_pos,'conv');
Im_45_neg = imfilter(img,F_45_neg,'conv');
Im_135_pos = imfilter(img,F_135_pos,'conv');
Im_135_neg = imfilter(img,F_135_neg,'conv');

Im_1 = zeros(H,L);
Im_2 = zeros(H,L);

%%
%  Methods of the article "Adaptive image enhancement"
for i=1:H
for j=1:L
Im_1(i,j) = max(max(max(Im_0_pos(i,j),Im_0_neg(i,j)),max(Im_90_pos(i,j),Im_90_neg(i,j)))...
,max(max(Im_45_pos(i,j),Im_45_neg(i,j)),max(Im_135_pos(i,j),Im_135_neg(i,j))));
end
end
figure(2),imshow(Im_1,[]);
%%
% Methods of the article "非整数步长的图像增强"
sum_I = zeros(H,L);
for i=1:H
for j=1:L
%         sum_I(i,j) = sum(sum(sum(Im_0_pos(i,j),Im_0_neg(i,j)),sum(Im_90_pos(i,j),Im_90_neg(i,j)))...
%             ,sum(sum(Im_45_pos(i,j),Im_45_neg(i,j)),sum(Im_135_pos(i,j),Im_135_neg(i,j))));

Im_2(i,j) = Im_0_pos(i,j)*Im_0_pos(i,j)/sum_I(i,j)+Im_0_neg(i,j)*Im_0_neg(i,j)/sum_I(i,j)+...
Im_90_pos(i,j)*Im_90_pos(i,j)/sum_I(i,j)+Im_90_neg(i,j)*Im_90_neg(i,j)/sum_I(i,j)+...
Im_45_pos(i,j)*Im_45_pos(i,j)/sum_I(i,j)+Im_45_neg(i,j)*Im_45_neg(i,j)/sum_I(i,j)+...
Im_135_pos(i,j)*Im_135_pos(i,j)/sum_I(i,j)+Im_135_neg(i,j)*Im_135_neg(i,j)/sum_I(i,j);
end
end
figure(3);imshow(Im_2*10);

```