# https://blog.csdn.net/zhoufan900428/article/details/12709361

Matlab Code:

f = 0:0.01:1;
v1 = 1;
y1 = log2(1 + v1*f)/log2(v1+1);
v2 = 10;
y2 = log2(1 + v2*f)/log2(v2+1);
v3 = 50;
y3 = log2(1 + v3*f)/log2(v3+1);
v4 = 100;
y4 = log2(1 + v4*f)/log2(v4+1);
v5 = 200;
y5 = log2(1 + v5*f)/log2(v5+1);
plot(f,y1,'g',f,y2,'r',f,y3,'b',f,y4,'c',f,y5,'y');
xlabel('Input gray level');
ylabel('Output gray level');
title('Log transformation: g = log(1+v*r)/log(1+v)');

lgd = legend('Log(v=1)','Log(v=10)','Log(v=50)','Log(v=100)','Log(v=200)');
legend('Location','southeast');
title(lgd,'The Legend Title')

Figure:

f = imread('2.jpg');
I=rgb2gray(f);
f = mat2gray(I);% 原代码中的[0 255] 可以去掉，因为f中最大最小值等于0， 255

v = 10;
g_1 = log2(1 + v*f)/log2(v+1);

v = 30;
g_2 = log2(1 + v*f)/log2(v+1);

v = 200;
g_3 = log2(1 + v*f)/log2(v+1);

figure(); %这里改成了四个子图，会更加直观
subplot(2,2,1);
imshow(f,[0 1]);
xlabel('a).Original Image');
subplot(2,2,2);
imshow(g_1,[0 1]);
xlabel('b).Log Transformations v=10');

subplot(2,2,3);
imshow(g_2,[0 1]);
xlabel('c).Log Transformations v=100');

subplot(2,2,4);
imshow(g_3,[0 1]);
xlabel('d).Log Transformations v=200');  

figure:

06-27 5208
05-01 8万+
03-21 2万+
06-13 1万+
07-16 3374
05-11
05-07 3832
05-08 5070
04-12 3229
05-11 70
05-23 5461
06-13 6979
05-07 1537
11-21
03-01 1万+
06-27
11-19 3918