A locally adaptive zooming algorithm for digital images

1 view (last 30 days)
I am trying to implement 'A locally adaptive zooming algorithm for digital image' this paper in MATLAB 2017. But I am not getting good result. And the PSNR value is 21.07 for peppers.png image. Here I am attaching my code. Please help me Is any problem in my code or any extra thing I have to do to get better result like in the paper.
clc;
clear all;
close all;
imIn=imread('peppers.png');%%384*512*3%%
im=imresize(imIn,0.5,'bicubic');%%192*256*3%%
[r,c,d]=size(im);%%192,256,3%%
%[n,m]=size(I);
n=2*r;%%384%%
m=2*c;%%512%%
im1=im(:,:,1);%%192*256%%
im2=im(:,:,2);
B11=imresize(im2,2,'bicubic');
im3=im(:,:,3);
B22=imresize(im3,2,'bicubic');
A(1:2:n,1:2:m)=im1;%%383*511%%
B=A;
%%%for fill uping even even index%%%
for i=4:2:n-4
for j=4:2:m-4
% [B(i,j),B(i-1,j),B(i+1,j),B(i,j-1),B(i,j+1)]=inter(A(i-1,j-1),A(i-1,j+1),A(i+1,j-1),A(i+1,j+1));
[B1 B2 B3 B4 B5] =inter(A(i-1,j-1),A(i-1,j+1),A(i+1,j-1),A(i+1,j+1));
B(i,j)=B1;
B(i-1,j)=B2;
B(i+1,j)=B3;
B(i,j-1)=B4;
B(i,j+1)=B5;
end
end
%%%for fill uping even odd index%%%
for i=4:2:n-4
for j=5:2:m-5
C1= intereveod(B(i-1,j),B(i+1,j),B(i,j+1),B(i,j-1));
B(i,j)=C1;
end
end
%%%for fill uping odd even index%%%
for i=5:2:n-5
for j=4:2:m-4
C2=interodeve(B(i-1,j),B(i+1,j),B(i,j-1),B(i,j+1));
B(i,j)=C2;
end
end
%%%%%%%%%%%%second step to fill rest of pixel in even even index %%%%
for i=4:2:n-4
for j=4:2:m-4
if B(i,j)==0
meee=[B(i-1,j-1),B(i-1,j+1),B(i+1,j-1),B(i+1,j+1)];
aaa=median(meee);
B(i,j)=aaa;
else
B(i,j)=B(i,j);
end
end
end
%%%%%%%%%%%%%second step to fill rest of pixel in even odd index %%%%%%
for i=4:2:n-4
for j=5:2:m-5
if B(i,j)==0
C11= [B(i-1,j),B(i+1,j),B(i,j+1),B(i,j-1)];
C12=median(C11);
B(i,j)=C12;
else
B(i,j)=B(i,j);
end
end
end
%%%%%%%%%% second step to fill rest of pixel in odd even index %%%%%%
for i=5:2:n-5
for j=4:2:m-4
if B(i,j)==0
C21=[B(i-1,j),B(i+1,j),B(i,j-1),B(i,j+1)];
C22=median(C21);
B(i,j)=C22;
else
B(i,j)=B(i,j);
end
end
end
Here I functions
  1. inter.m
function [op1 oph1 oph2 opv1 opv2] = inter(p1,p2,p3,p4);
T1=7;T2=6;
if abs(p1)<T1 & abs(p2)<T1 & abs(p3)<T1 & abs(p4)<T1
op1=(p1+p2+p3+p4)/4;
oph1=0;
oph2=0;
opv1=0;
opv2=0;
elseif abs(p1-p4)>T2 & abs(p1-p4)> abs(p2-p3)
op1=(p2+p3)/2;
oph1=0;
oph2=0;
opv1=0;
opv2=0;
elseif abs(p2-p3)>T2 & abs(p2-p3)>abs(p1-p4)
op1=(p1+p4)/2;
oph1=0;
oph2=0;
opv1=0;
opv2=0;
elseif abs(p1-p4)>T1 & abs(p2-p3)>T1 & abs((p1-p4)*(p2-p3))>0
op1=0;
oph1=(p1+p2)/2;
oph2=(p3+p4)/2;
opv1=0;
opv2=0;
elseif abs(p1-p4)>T1 & abs(p2-p3)>T1 & abs((p1-p4)*(p2-p3))<0
op1=0;
oph1=0;
oph2=0;
opv1=(p1+p3)/2;
opv2=(p2+p4)/2;
else
op1=0;
oph1=0;
oph2=0;
opv1=0;
opv2=0;
end
end
2. intereveod.m
function op = intereveod(a,b,x1,x2)
T1=7;
T2=6;
if (abs(x1)==0 | abs(x2)==0) & abs(a-b)<T1
op =(a+b)/2;
% end
elseif abs(a-b)>T2 & abs(a-b)>abs(x1-x2)
op =(x1+x2)/2;
elseif abs(x1-x2) > T2 & abs(x1-x2) > abs(a-b)
op =(a+b)/2;
else
op = 0;
end
end
3. interodeve.m
function oo1= interodeve(x1,x2,a,b)
T1=7; T2=6;
if (x1==0 | x2==0) & abs(a-b)< T1
oo1=(a+b)/2;
%end
elseif abs(a-b)>T2 & abs(a-b)>abs(x1-x2)
oo1=abs(x1+x2)/2;
elseif abs(x1-x2)>T2 & abs(x1-x2)>abs(a-b)
oo1=abs(a+b)/2;
else
oo1=0;
end
end
  2 Comments
KALYAN ACHARJYA
KALYAN ACHARJYA on 19 May 2019
And the PSNR value is 21.07
What value you are expecting? Any Justification?
hena sharma
hena sharma on 20 May 2019
Sir,
According to algorithm I am excepting 29-32dB PSNR value for standard images.

Sign in to comment.

Answers (0)

Categories

Find more on Image Processing Toolbox in Help Center and File Exchange

Products


Release

R2017a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!