DOC PREVIEW
UT Arlington EE 5355 - Avik_Pal_Project8A

This preview shows page 1-2-3-4-5 out of 16 pages.

Save
View full document
View full document
Premium Document
Do you want full access? Go Premium and unlock all 16 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 16 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 16 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 16 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 16 pages.
Access to all documents
Download any document
Ad free experience
Premium Document
Do you want full access? Go Premium and unlock all 16 pages.
Access to all documents
Download any document
Ad free experience

Unformatted text preview:

AVIK PAl 1001113861 Project 8AQ.1 Implement down sampling 2:1 based on DA (Dugad and Ahuja) and bilinear interpolationProgramming:clc;close all;clear all;X=double(imread('lena512.bmp'));[m n]=size(X); %Obtain the DCT kernel for 8x8 and 4x4N=8;Dct_matrix=dctmtx(N);D=dctmtx(4); % Implementing DA Method%DA_down_sample=zeros(4,4); % Get the 4x4 Matrix of zeroes to build sampling filters% Defining matrix For downsampling 2:1%downsample=zeros(4,4);% Defining matrix For usampling 1:2%upsample=zeros(8,8); for i=1:m/N for j=1:n/N Temp_1=X((i-1)*N+1:i*N,(j-1)*N+1:j*N); J=Dct_matrix*Temp_1*Dct_matrix'; %DA_down_sampling(DCT domain) is of size 256x256 as we have ignored %5:8,5:8 of J% DA_down_sample((i-1)*N/2+1:i*N/2,(j-1)*N/2+1:j*N/2)=J(1:N/2,1:N/2); endend for i=1:m/N for j=1:n/N Temp_1=DA_down_sample((i-1)*N/2+1:i*N/2,(j-1)*N/2+1:j*N/2); downsample((i-1)*N/2+1:i*N/2,(j-1)*N/2+1:j*N/2)=D'*Temp_1*D;%256x256 lena image endendimshow(X,[]); title('original Image');figure, imshow(downsample,[]);title('2:1 downsampling by DA method');% Downsampling by bilinear interpolationbimup=imresize(X,0.5,'bilinear'); MSE_DA=sum(sum((X-upsample).^2))/numel(X);PSNR_DA=20*log10(255*255/(MSE_DA)); imshow(X,[]); title('original Image');figure, imshow(downsample,[]);title('2:1 downsampling by DA method');figure, imshow(upsample,[]);title(sprintf('upsampling by DA method MSE:%f PSNR:%f',MSE_DA,PSNR_DA));figure, 1AVIK PAl 1001113861 Project 8Aimshow(bimup,[]);title('Downsampling by Bilinear interpolation 2:1');Visualization:Downsampling:Based on Interpolation:2AVIK PAl 1001113861 Project 8AObservation:At first,I created the DCT matrix which is 4*4. Then I tried to insert values in DCT_downsampling matrix which is 256*256 in dimension. The matrix value is given below3AVIK PAl 1001113861 Project 8AQ.2 Implement Downsampling (2:1) and upsampling (1:2) as shown in last program:Programming;clc;close all;clear all;X=double(imread('lena512.bmp'));[m n]=size(X); %Obtain the DCT kernel for 8x8 and 4x4N=8;Dct_matrix=dctmtx(N);D=dctmtx(4); % Implementing DA Method%DA_down_sample=zeros(4,4); % Get the 4x4 Matrix of zeroes to build sampling filters% Defining matrix For downsampling 2:1%downsample=zeros(4,4);% Defining matrix For usampling 1:2%upsample=zeros(8,8); for i=1:m/N for j=1:n/N Temp_1=X((i-1)*N+1:i*N,(j-1)*N+1:j*N); J=Dct_matrix*Temp_1*Dct_matrix'; %DA_down_sampling(DCT domain) is of size 256x256 as we have ignored %5:8,5:8 of J% DA_down_sample((i-1)*N/2+1:i*N/2,(j-1)*N/2+1:j*N/2)=J(1:N/2,1:N/2); endend for i=1:m/N for j=1:n/N Temp_1= DA_down_sample((i-1)*N/2+1:i*N/2,(j-1)*N/2+1:j*N/2); Temp_1=[Temp_1 zeros(N/2);zeros(N/2) zeros(N/2)];%attaching zeros to increase size upsample((i-1)*N+1:i*N,(j-1)*N+1:j*N)=Dct_matrix'*Temp_1*Dct_matrix;%upsample is of size 512x512 in data domain endend for i=1:m/N for j=1:n/N Temp_1=DA_down_sample((i-1)*N/2+1:i*N/2,(j-1)*N/2+1:j*N/2); downsample((i-1)*N/2+1:i*N/2,(j-1)*N/2+1:j*N/2)=D'*Temp_1*D;%256x256 lena image endend Visualization:Original Image;4AVIK PAl 1001113861 Project 8ADown sample:Upsample:5AVIK PAl 1001113861 Project 8AObservation:Upsample matrix which is 512*512 in dimension is given below6AVIK PAl 1001113861 Project 8AQ 3. See MM transformation and implement using SB and TR using MM transformationProgramming;Downsampling;%Using MM and SB%Du=dctmtx(2*N);%DCT kernel of size 16%Downsampling and Upsampling by SB methodfor k=1:N for l=1:N c(k,l)=(4*cos(pi*k/(2*N))*cos(pi*l/(2*N))); endend for i=1:m/N for j=1:n/N Temp_2=X((i-1)*N+1:i*N,(j-1)*N+1:j*N); J=Dct_matrix*Temp_2*Dct_matrix'; DA_down_sampling((i-1)*N/2+1:i*N/2,(j-1)*N/2+1:j*N/2)=J(1:N/2,1:N/2)./c(1:N/2,1:N/2); %modifying DA method by dividing it with cos endend for i=1:m/N for j=1:n/N Temp_2=DA_down_sampling((i-1)*N/2+1:i*N/2,(j-1)*N/2+1:j*N/2); imdownSB((i-1)*N/2+1:i*N/2,(j-1)*N/2+1:j*N/2)=D'*Temp_2*D; %256x256 endend for i=1:m/N/2 for j=1:n/N/2 Temp_2=imdownSB((i-1)*N+1:i*N,(j-1)*N+1:j*N); Temp_2=[Dct_matrix*Temp_2*Dct_matrix'.*c zeros(N);zeros(N) zeros(N)];%increasing size after .*c imup((i-1)*2*N+1:i*2*N,(j-1)*2*N+1:j*2*N)=Du'*Temp_2*Du; endend MSE_SB=sum(sum((X-upsample).^2))/numel(X); PSNR_SB=20*log10(255*255/(MSE_SB)); figure;imshow(imup,[]);title(sprintf('upsampling by SB MSE:%f PSNR:%f',MSE_SB,PSNR_SB));figure;imshow(imdownSB,[]);title('2:1 downsampling by SB method');Upsampling by SB method:%-------------------------------------------------------------------------%Upsampling by TR methodfor i=1:m/N/2 for j=1:n/N/2 Temp_3=downsample((i-1)*N+1:i*N,(j-1)*N+1:j*N); %starting with DA downsamp7AVIK PAl 1001113861 Project 8A Temp_3=[Dct_matrix*Temp_3*Dct_matrix' zeros(N);zeros(N) zeros(N)];%size is 16x16 imup((i-1)*2*N+1:i*2*N,(j-1)*2*N+1:j*2*N)=Du'*Temp_3*Du; endend MSE_TR=sum(sum((X-imup).^2))/numel(X); PSNR_TR=20*log10(255/(MSE_TR)); figure; imshow(imup,[]);title('1:2 upsampling by TR');title(sprintf('upsampling by TR MSE:%f PSNR:%f',MSE_TR,PSNR_TR));Visualization:Downsample by SB method:Upsample by SB method:8AVIK PAl 1001113861 Project 8AUpsample by TR methodObservation:DA _Downsampling matrix is given below which is 256*256 in dimension.9AVIK PAl 1001113861 Project 8AIn case of Upsampling method, the matrix is given as which is 16*16 in dimensionMSE for Upsampling in SB method is;10AVIK PAl 1001113861 Project 8A>> disp (MSE_SB) 21.9303And the PSNR in SB method is>> disp(PSNR_SB) 69.4407In case of TR methodUpsampling matrix which is 16*16 is given belowAnd MSE for this method is>> disp (MSE_TR) 20.3709PSNR for this TR method>> disp (PSNR_TR) 21.9506Q.5 Calculate using CR method described in CLProgramming:%CR method upsampling11AVIK PAl 1001113861 Project 8Axll=zeros(N*N,N*N); %64x64xhl=zeros(4*N*N-N*N,N*N);%192x64%Dd16=zeros(N/2,N/2);%4x4 for i=1:m/N/2 for j=1:n/N/2 Temp_4=Du*X((i-1)*N*2+1:i*N*2,(j-1)*N*2+1:j*N*2)*Du';%16x16 [r c]=size(Temp_4); Dd16((i-1)*N+1:i*N,(j-1)*N+1:j*N)= Temp_4(1:r/2,1:c/2); L=reshape(Temp_4(1:r/2,1:c/2),r*c/4,1); H=[reshape(Temp_4(1:r/2,1+c/2:c),r*c/4,1);reshape(Temp_4(1+r/2:r,1:c/2),r*c/4,1);reshape(Temp_4(1+r/2:r,1+c/2:c),r*c/4,1)]; xll=xll+L*L'; xhl=xhl+H*L'; endendxll=xll/(m/N/2)^2;xhl=xhl/(m/N/2)^2;A=xhl*xll^-1; A=A/max(max(A)); for i=1:m/N/2 for j=1:n/N/2 Temp_4=Dd16((i-1)*N+1:i*N,(j-1)*N+1:j*N); Temp_4=reshape(Temp_4,N*N,1); Temp4=A*Temp_4; Temp5=[Dd16((i-1)*N+1:i*N,(j-1)*N+1:j*N) reshape(Temp4(1:N*N),N,N); reshape(Temp4(N*N+1:2*N*N),N,N) reshape(Temp4(2*N*N+1:3*N*N),N,N)];


View Full Document
Download Avik_Pal_Project8A
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view Avik_Pal_Project8A and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view Avik_Pal_Project8A 2 2 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?