Digital Image Processing: Image of gradation conversion (realization of Matlab)

(1) linear transformation:
adjusting the establishment of the source image by mapping grayscale gradation.

k> 1 enhanced image contrast; k = 1 to adjust image brightness by changing the purpose of adjusting the brightness value of d reached; 0

i = imread('theatre.jpg');
i = im2double(rgb2gray(i));
[m,n]=size(i);
%增加对比度
Fa = 1.25; Fb = 0;
O = Fa.*i + Fb/255;
figure(1), subplot(221), imshow(O);
title('Fa = 1.25, Fb = 0, contrast increasing');
figure(2),subplot(221), [H,x]=imhist(O, 64);
stem(x, (H/m/n), '.');
title('Fa = 1.25, Fb = 0, contrast increasing');
%减小对比度
Fa =0.5; Fb = 0;
O = Fa.*i + Fb/255;
figure(1), subplot(222),imshow(O);
title('Fa = 0.5, Fb = 0, contrast decreasing');
figure(2), subplot(222), [H,x] = imhist(O, 64);
stem(x, (H/m/n), '.');
title('Fa = 0.5, Fb = 0, contrast decreasing');
%线性亮度增加
Fa = 0.5;Fb = 50;
. O = Fa of the * I + Fb / 255;
Figure (. 1), the subplot (223), imshow (O);
title ( 'Fa of the = 0.5, Fb = 50, Brightness Control');
Figure (2), the subplot (223 ), [H, X] = imhist (O, 64);
STEM (X, (H / m / n-),) '.';
title ( 'Fa of the = 0.5, Fb = 50, Brightness Control');
% trans phase display
Fa of the = -1; Fb = 255;
. * Fa of the O = I + Fb / 255;
Figure (. 1), the subplot (224), imshow (O);
title ( 'Fa of the = -1, Fb = 255, REVERSAL Processing ');
Figure (2), the subplot (224), [H, X] = imhist (O, 64);
. STEM (X, (H / m / n-),' ');
title (' Fa of the = - . 1, Fb = 255, REVERSAL Processing ');

(2) a logarithmic transformation:
enhanced low gray, reduced high gradation value.

i = imread('theatre.jpg');


i = rgb2gray(i);
i = double(i);

= log OUT1 of (. 1 + I) /0.065;
OUT2 of the = log (I +. 1) /0.035;
OUT1 of (Find (OUT1 of> 255)) = 255;
OUT2 of the (Find (OUT2 of the> 255)) = 255;
OUT1 of uint8 = ( OUT1 of);
OUT2 of the uint8 = (OUT2 of the);

(. 3) - power conversion:
the number is less than 1, enhanced low gradation, reduced high gray; enhanced frequency and high gradation is greater than 1, the low gray weakened.

rgb2gray = I (imread ( 'theatre.jpg'));
I = Double (I);
Y1 = 255 * (I / 255) ^ 2.5;.
. 255 * Y2 = (I / 255) ^ 0.4;
Y1 = uint8 (Y1);
Y2 = uint8 (Y2);

(. 4) exponential transformation:
enhanced high gray level, low gray weakened.

i = imread('theatre.jpg');
i = rgb2gray(i);
i = double(i);

. for 1.5 ^ Y1 = (0.070 * I) -1;
. ^ for 1.5 Y2 = (0.050 * I) -1;
Y1 (Find (Y1> 255)) = 255;
Y2 (Find (Y2> 255)) = 255;
uint8 = Y1 (Y1);
Y2 = uint8 (Y2);

(. 5) gray stretch:
sometimes concentrated in a small image area gradation, it is necessary to change image contrast.

imread = I ( 'theatre.jpg');
I = rgb2gray (I);
L = imadjust (I, [], [50/255; 150/255]);
J = imadjust (L, [50/255; 150 / 255], [20/255; 230/255]);

(6) gray balance:
I = rgb2gray (imread ( 'theatre.jpg'));
the LC imadjust = (I, [], [50/255; 150/255]);
HE1 = histeq (the LC);% equalizer function

(7) histogram specification:
grayscale local equilibrium.

= rgb2gray IMG (imread ( 'theatre.jpg'));
img_ref = rgb2gray (imread ( 'rpic.jpg')); Referring to FIG%, according to the predetermined histogram of
[hgram, x] = imhist ( img_ref );
J = histeq (IMG, hgram);

Guess you like

Origin www.cnblogs.com/geeksongs/p/11037415.html