Line 1: Line 1:
 
  
 
=Code:Discrete_Time_Interpolation=
 
=Code:Discrete_Time_Interpolation=
  
  
 +
close all;
 +
clear all;
 +
 +
clc;
 +
t = cputime;
 +
 +
img = imread('C:\Users\Dhruv\Pictures\chicago\DSC07983.JPG');
 +
 +
 +
% imshow(a);
 +
% img_double = double(img);
 +
% clear img;
 +
 +
 +
% r = img(:,:,1);
 +
g = img(:,:,2);
 +
% b = img(:,:,3);
 +
clear img;
 +
figure;
 +
 +
imshow(g);
 +
 +
 +
% % % % % % % % % %        DOWNSAMPLER                % % % % % % % % % %
 +
% % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % %
 +
% % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % %
 +
% % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % %
 +
i = 0;
 +
j = 0;
 +
m = 1;
 +
n = 1;
 +
 +
D = 3;                                    %%DOWNSAMPLING FACTOR
 +
 +
[x,y]=size(g);
 +
x=x-mod(x,D);
 +
y=y-mod(y,D);
 +
 +
while i < x;
 +
    n=1;
 +
    j=0;
 +
    while j < y;
 +
    g_decimated(m,n) = g(i+D,j+D);  %#ok<AGROW>
 +
    j=j+D;
 +
    n=n+1;
 +
    end
 +
    i=i+D;
 +
    m=m+1;
 +
end
 +
% % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % %
 +
% % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % %
 +
figure;
 +
 +
 +
imshow(g_decimated);
 +
 +
 +
% % % % % % % % % %        UPSAMPLER                % % % % % % % % % %
 +
% % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % %
 +
% % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % %
 +
% % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % %
 +
 +
[X_D,Y_D] = size(g_decimated);
 +
 +
 +
 +
i=1;
 +
 +
g_up = zeros(1,Y_D + y-D);
 +
 +
while i < X_D
 +
    row = g_decimated(i,:);
 +
    new_row = zero_fill(row,D);
 +
    g_up = [g_up;new_row];
 +
    temp = zeros(D,length(new_row));
 +
    g_up = [g_up;temp];
 +
    i=i+1;
 +
end
 +
figure;
 +
imshow(g_up);
 +
 +
lpf = firpm(500,[0 1e-75/D 2e-75/D .5]*2,[1 1 0 0]);
 +
 +
g_final = filter2(lpf,g_up);
 +
g_final = D*g_final;
 +
figure;
 +
imshow(g_final);
  
Put your content here . . .
+
   
 +
   
 +
disp(cputime - t);   
 +
  
  

Revision as of 21:42, 1 October 2009

Code:Discrete_Time_Interpolation

close all; clear all;

clc; t = cputime;

img = imread('C:\Users\Dhruv\Pictures\chicago\DSC07983.JPG');


% imshow(a); % img_double = double(img); % clear img;


% r = img(:,:,1); g = img(:,:,2); % b = img(:,:,3); clear img; figure;

imshow(g);


% % % % % % % % % % DOWNSAMPLER  % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % i = 0; j = 0; m = 1; n = 1;

D = 3;  %%DOWNSAMPLING FACTOR

[x,y]=size(g); x=x-mod(x,D); y=y-mod(y,D);

while i < x;

   n=1;
   j=0;
   while j < y;
   g_decimated(m,n) = g(i+D,j+D);  %#ok<AGROW>
   j=j+D;
   n=n+1;
   end
   i=i+D;
   m=m+1;

end % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % figure;


imshow(g_decimated);


% % % % % % % % % % UPSAMPLER  % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % %

[X_D,Y_D] = size(g_decimated);


i=1;

g_up = zeros(1,Y_D + y-D);

while i < X_D

   row = g_decimated(i,:);
   new_row = zero_fill(row,D);
   g_up = [g_up;new_row];
   temp = zeros(D,length(new_row));
   g_up = [g_up;temp];
   i=i+1;

end figure; imshow(g_up);

lpf = firpm(500,[0 1e-75/D 2e-75/D .5]*2,[1 1 0 0]);

g_final = filter2(lpf,g_up); g_final = D*g_final; figure; imshow(g_final);


disp(cputime - t);



Back to Discrete Time Interpolation:Waving the math wand

Alumni Liaison

Ph.D. on Applied Mathematics in Aug 2007. Involved on applications of image super-resolution to electron microscopy

Francisco Blanco-Silva