Algebraic operations for digital image processing:
(1)
Addition operation:
Clear
A=imread('test.jpg ');
S = size ();
B = double ();
P = size (B)
C (:,:, 1) = B (:,:, 1) + B (:,:, 2); % Add the red component
C (:,:, 2) = B (:,:, 2 );
C (:,:, 3) = B (:,:, 3)-B (:,:, 2); % reduce the blue component
For I = 1: S (1)
For j = 1: S (2)
For k = 1: S (3)
If C (I, j, k) <0
C (I, j, k) = 0;
End
If C (I, j, k)> 255
C (I, j, k) = 255;
End
End
End
End
C = uint8 (C );
Subplot (121); imshow (a); xlabel ('hangzhou' í ~a ');
Subplot (122); imshow (c); xlabel ');
Clear all
A=imread('test1.jpg ');
A1 = imnoise (A, 'gaussian ', 0, 0.006 );
A2 = imnoise (A, 'gaussian ', 0, 0.006 );
A3 = imnoise (A, 'gaussian ', 0, 0.006 );
A4 = imnoise (A, 'gaussian ', 0, 0.006 );
K = imlincomb (0.25, A1, 0.25, A2, 0.25, A3, 0.25, A4 );
Subplot (131); imshow ();
Subplot (132); imshow (A1 );
Subplot (133); imshow (K, []);
(2)
Subtraction:
Clear all
A=imread('test.jpg ');
Subplot (311); imshow ();
Background = imopen (A, strel ('disk', 15 ));
AP = imsubtract (A, background );
Subplot (312); imshow (background );
Subplot (313); imshow (AP );
(3) Multiplication
Clear all
A=imread('image1.jpg ');
B =imread('images.jpg ');
S = size ();
M = S (1 );
N = S (2 );
B1 = imresize (B, [m n]);
Figure (1); imshow ();
A = double ();
C = double (B1 );
% Too many.
D = A. * C/128;
D = uint8 (d );
Figure (2); imshow ();
Figure (3); imshow (B );
Figure (4); imshow (d );
% Too many.
O = imadd (a, c );
O = uint8 (O );
Figure (5); imshow (O );
(4) Division:
Clear all
A=imread('test.jpg ');
Background = imopen (A, strel ('disk', 15); % A perform morphological operations
A1 = imdivide (A, background );
Subplot (131 );
Imshow (background );
Subplot (132)
Imshow ();
Subplot (133)
Imshow (A1, []);