MATLAB filtering Experiment

Source: Internet
Author: User

CLC;
Clear all;
I = imread ('ight. tif ');
% %
% Use the median filter and multi-dimensional filter, and use the Rapp with the center of-4 and-8
% Las filter, Gaussian low-pass filter, Laplace filter for filtering
% %
Figure; % Figure1
Subplot (2, 2, 1 );
Imshow (I );
Title ('original image ');
J = imnoise (I, 'Salt & pepper ', 0.04); % add salt and pepper noise
Title ('prepaid and prepaid noisy ');
Subplot (2, 2 );
Imshow (j );
K = medfilt2 (J, [4, 4]) %;
Subplot (2, 2, 3 );
Imshow (k );
Title ('perform mediainfilter ');
H = ones (3, 3)/9; % multi-dimensional filtering
W = h;
G = imfilter (I, W, 'conv', 'replicate ')
Subplot (2, 2, 4 );
Imshow (g );
Title ('multidimensional filter ');
% Use the Laplace filter with center-4 and-8,
W4 = [1 1 1;
1-4 1;
1 1];
W8 = [1 1 1;
1-8 1;
1 1];
F = im2double (I );
G4 = f-imfilter (F, W4, 'replicate ');
G8 = f-imfilter (F, W8, 'replicate ');
Imshow (f );
Figure; % figure2
Subplot (1, 2 );
Imshow (G4 );
Title ('center-4 Laplace filter ');
Subplot (1, 2 );
Imshow (G8 );
Title ('center-8 Laplace filter ');
H3 = fspecial ('gaussian ', [3, 3], 0.5); % Gaussian low-pass filter
Figure; % figure3
B4 = filter2 (H3, I );
Subplot (1, 2 );
Imshow (B4, []);
Title ('gaussian low-pass filter ');
H4 = fspecial ('laplacian ', 0); % use Laplace Filter
B5 = filter2 (H4, I );
Subplot (1, 2 );
Imshow (B5, []);
Title ('laplace filter ');
% %
% Brightness change from the airspace Angle
% Change the gray level to 10-255
% %
Figure; % figure4
Subplot (2, 2, 1 );
Imshow (I );
Title ('original image ');
J2 = imadjust (I, [], [], 0.5); % enhanced low gray level
Subplot (2, 2 );
Imshow (J2 );
Title ('enhanced low grayscale level ');
J3 = imadjust (I, [], [], 2); % enhanced high gray level
Subplot (2, 2, 3 );
Imshow (J3 );
Title ('enhanced grayscale level ');
A1 = 100/255; % change the gray level to 10-255
A2 = 255/255;
A3 = 10/255;
J2 = imadjust (I, [A3, A1], [A3, a2], []);
Subplot (2, 2, 4 );
Imshow (J2 );
Title ('change the gray level to 10-255 ');
% %
% Brightness conversion from the frequency domain
% Fft2
% Because the energy is mainly concentrated in the low frequency
%. Therefore, low frequency processing can achieve the desired effect.
% %
I = imread ('ight. tif ');
Up = 0.5; % set the processing frequency limit
Down = 0.09% % set lower processing frequency limit
Figure; % figure5
Subplot (421 );
Imshow (I );
Title ('original image ');
F = double (I );
Subplot (4, 2, 3 );
Imshow (log (ABS (f), []);
Title ('unit8 converted to double ');
G = fft2 (f );
G = fftshift (g );
Subplot (4, 2, 5 );
Imshow (log (ABS (g), []);
Title ('fft2 changed image ');
[M, N] = size (g); % convert the Data Matrix
Y1 = max (ABS (G); % find the maximum frequency
Y2 = min (ABS (G); % to find the minimum frequency
Y3 = (y1-y2) * Up + y2; % sets the upper limit of Filtering
Y4 = (y1-y2) * down + y2; % sets the lower limit of Filtering
For I = 1: m
For j = 1: N
If (ABS (G (I, j) <Y4)
G (I, j) = g (I, j) ^ 1.1; % perform grayscale enhancement on the low-frequency part
End
End
End
Result = ifftshift (g );
J2 = ifft2 (result );
J3 = uint8 (ABS (J2 ));
Subplot (427 );
Imshow (J3, []);
Title ('image processed in the frequency domain ');
Subplot (422)
Imhist (I, 64 );
Subplot (424)
Imhist (F, 64 );
Subplot (426)
Imhist (G, 64 );
Subplot (428)
Imhist (J3, 64 );

 

 

 

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.