"Digital image processing principle and practice (MATLAB version)" A book Code PART5

Source: Internet
Author: User

"Digital image processing principle and practice (MATLAB version)" A book Code PART5

This article is the "Digital image processing principle and practice (MATLAB version)" A book Code series PART5. The code for the No. 225 to No. 280 pages of the book (the order in which the code is published should be adjusted for some of the reader's needs – see the link to the article below) for the reader to download the study for use. Code running results Please refer to the original book map, recommended to download the code before reading the following:

About the principle and practice of Digital Image processing (MATLAB version) of the code published in the description

http://blog.csdn.net/baimafujinji/article/details/40987807

P245

I = Imread (' lena.png ');
FCOEF=FFT2 (double (I)); %fft Transform
TMP1 =log (1+abs (FCOEF));
Spectrum = Fftshift (FCOEF); % Adjustment Center
TMP2 = log (1+abs (spectrum));
Ifcoef = ifft2 (FCOEF); % Inverse transform

Figure% Show processing results
Subplot (2,2,1), Imshow (I), title (' Source image ');
Subplot (2,2,2), Imshow (tmp1,[]), title (' FFT image ');
Subplot (2,2,3), Imshow (tmp2,[]), title (' Shift FFT image ');
Subplot (2,2,4), Imshow (ifcoef,[]), title (' IFFT image ');

P251

J= double (imread (' lena.bmp '));
K = Dct2 (J);
Figure, Imshow (k,[0 255])

P252-1

J= double (imread (' lena.bmp '));
K = Dct2 (J);
Figure, Imshow (k,[0 255]);
K_i = Idct2 (K);
Figure, Imshow (k_i,[0 255])

P252-2

J= double (imread (' lena.bmp '));
A = J (1:8,1:8);
D = DCTMTX (8);
dct_1 = D*a;
dct_2 = D ' *dct_1;

P252-3

J= double (imread (' lena.bmp '));
A = J (1:8,1:8);
D = DCTMTX (8);
dct_1 = D*a*d ';
Dct_2 = Dct2 (A);

P253

I = Imread (' cameraman.tif ');
i = im2double (i);
T = DCTMTX (8);
DCT = @ (block_struct) T * block_struct.data * t ';
B = Blockproc (i,[8 8],dct);
mask = [1 1 1 1 0 0 0 0
1 1 1 0 0 0 0 0
1 1 0 0 0 0 0 0
1 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0];
B2 = Blockproc (b,[8 8],@ (block_struct) mask. * Block_struct.data);
INVDCT = @ (block_struct) T ' * block_struct.data * t;
I2 = Blockproc (b2,[8 8],invdct);
Imshow (I), figure, Imshow (I2)

P262

A = [0 0 1 1 0 0 1 1];
b = FWHT (a);

P263

I = Imread (' baboon.bmp ');
I1 = double (I);
T = Hadamard (8);
MYFUN1 = @ (block_struct) t*block_struct.data*t/64;
H = Blockproc (I1, [8 8], MYFUN1);
H (ABS (h) <3.5) = 0;
MyFun2 = @ (block_struct) t*block_struct.data*t;
I2 = Blockproc (H, [8 8], myFun2);
Subplot (121), Imshow (i1,[]), title (' original image ');
Subplot (122), Imshow (i2,[]), title (' zipped image ');

P264

I = Imread (' baboon.bmp ');
I1 = double (I);
[M N] =size (I);
Sizi = 8;
num = 16;
Discrete Walsh transformations with% tiles
T = Hadamard (Sizi);
MYFUN1 = @ (block_struct) t*block_struct.data*t/(sizi.^2);
Hdcoe = Blockproc (I1, [Sizi, Sizi], myFun1);
% again permutation factor
Coe = Im2col (Hdcoe, [Sizi, Sizi], ' distinct ');
coe_t = ABS (COE);
[Y, Ind] = sort (coe_t);
% off absolute value smaller coefficient
[M_c, N_c] = size (COE);
For i = 1:n_c
Coe (Ind (1:num, I), i) = 0;
End
% rebuild Image
Re_hdcoe = Col2im (Coe, [Sizi, Sizi], [M, N], ' distinct ');
MyFun2 = @ (block_struct) t*block_struct.data*t;
re_s = Blockproc (Re_hdcoe, [Sizi, Sizi], myFun2);
Subplot (121), Imshow (i1,[]), title (' original image ');
Subplot (122), Imshow (re_s,[]), title (' Compressed image ');

P268

DIM1 = [1 1 1 2 2 2 3 3 3];
DIM2 = [1 2 3 1 2 3 1 2 3];
DIM3 = [63 75 78 50 56 65 70 71 80];

Sum ((Dim1-mean (DIM1)). * (Dim2-mean (DIM2))/(9-1)% 0
Sum ((Dim1-mean (DIM1)). * (Dim3-mean (DIM3))/(9-1)% 0.625
Sum ((Dim2-mean (DIM2)). * (Dim3-mean (DIM3))/(9-1)% 5

STD (DIM1) ^2% 0.75
STD (dim2) ^2% 0.75
STD (dim3) ^2% 100.7778

P274

X = [2 2; 2 3; 3 4; 4 3; 5 4; 5 5];
[Coeff,score,latent,tsquare] = Princomp (X);

P275-1

X0=x-repmat (Mean (X), 6, 1);
Score_1 = X0*coeff;

P275-2

X = [2 2; 2 3; 3 4; 4 3; 5 4; 5 5];
V = CoV (X);
[Coeff,latent] = Pcacov (V)

P277

I = Imread (' baboon.bmp ');
x = Double (I)/255;
[M,n]=size (x);
Y =[];
% Disassembly image
For i = 1:M/8;
for j = 1:N/8;
II = (i-1) *8+1;
JJ = (j-1) *8+1;
Y_app = Reshape (x (ii:ii+7,jj:jj+7), 1,64);
Y=[y;y_app];
End
End

%kl Transform
[Coeff,score,latent] = Princomp (y);
KL = y * Coeff;

KL1 = KL;
KL2 = KL;
KL3 = KL;

% 0 Compression Process
KL1 (:, 33:64) = 0;
KL2 (:, 17:64) = 0;
KL3 (:, 9:64) = 0;

%kl Inverse transformation
Kl_i = Kl*coeff ';
Kl1_i = Kl1*coeff ';
Kl2_i = Kl2*coeff ';
Kl3_i = Kl3*coeff ';

Image = Ones (256,256);
Image1 = ones (256,256);
Image2 = ones (256,256);
Image3 = ones (256,256);

I=s;
% recombinant image
For i = 1:M/8;
for j = 1:N/8;

y = Reshape (kl_i (k, 1:64), 8,8);
Y1 = Reshape (kl1_i (k, 1:64), 8,8);
y2 = Reshape (kl2_i (k, 1:64), 8,8);
Y3 = Reshape (kl3_i (k, 1:64), 8,8);

II = (i-1) *8+1;
JJ = (j-1) *8+1;

Image (ii:ii+7,jj:jj+7) = y;
Image1 (ii:ii+7,jj:jj+7) = y1;
Image2 (ii:ii+7,jj:jj+7) = y2;
Image3 (ii:ii+7,jj:jj+7) = Y3;

k=k+1;
End
End

(The code is not finished, please wait ... )

"Digital image processing principle and practice (MATLAB version)" A book Code PART5

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.