Image Enhancement using DWT and IDWT

AM not getting the correct output after applying IDWT2 function.. can any one look at the code and help me out
code: % input is a gray image y=imread('c:\working\lena.jpg');
%x=rgb2gray(y); [Lo_D,Hi_D,Lo_R,Hi_R] = wfilters('haar'); [LL,LH,HL,HH]=dwt2(y,Lo_D,Hi_D);
figure(1),imshow(uint8(LL));title(' LL Image'); figure(2),imshow(y);title('INput Image');
dec=[... LL,LH HL,HH ... ]; LLI = imresize(LL,2,'bicubic'); LHI = imresize(LH,2,'bicubic'); HLI = imresize(HL,2,'bicubic'); HHI = imresize(HH,2,'bicubic'); image=double(y);
figure(3),imagesc(image); colormap gray;title('doubled input image');
figure(4),imagesc(LLI); colormap gray;title('iterpolated LL Image');
figure(5),imagesc(LHI); colormap gray;title('iterpolated LH Image');
figure(6),imagesc(HLI); colormap gray;title('iterpolated HL Image');
figure(7),imagesc(HHI); colormap gray;title('iterpolated HH Image');
Diff_Img=imsubtract(image,LLI);
figure(8),imagesc(Diff_Img);colormap gray;title('Difference Image');
[m,n]=size(Diff_Img);
for i=1:m
for j=1:n
ELH(i,j)=(Diff_Img(i,j)+LHI(i,j))/2;
end
end
figure(9),imagesc(ELH);colormap gray;title('Added LH Image');
for i=1:m
for j=1:n
EHL(i,j)=(Diff_Img(i,j)+HLI(i,j))/2;
end
end
figure(10),imagesc(EHL);colormap gray;title('Added HL Image');
for i=1:m
for j=1:n
EHH(i,j)=(Diff_Img(i,j)+HHI(i,j))/2;
end
end
figure(11),imagesc(EHH);colormap gray;title('Added HH Image');
%scale the image by factor of two
scale=2;
LLI2 = imresize(image,scale/2,'bicubic');
figure(12),imagesc(LLI2);colormap gray;title('Resized for IDWT input image');
LHI2 = imresize(ELH,scale/2,'bicubic');
figure(13),imagesc(LHI2);colormap gray;title('Resized LH Image');
HLI2 = imresize(EHL,scale/2,'bicubic');
figure(14),imagesc(HLI2);colormap gray;title('Resized HL Image');
HHI2 = imresize(EHH,scale/2,'bicubic');
figure(15),imagesc(HHI2);colormap gray;title('Resized HH Image');
% image=im2double(image);
out=idwt2(LLI2,LHI2,HLI2,HHI2,'haar');
figure(16),imagesc(out); colormap gray;title('output enhanced image');
%imshow(unit8(out));

7 Comments

Can you please elaborate on what you mean by you're not getting the correct output?
In the final output i.e in figure 16, white color square appears throughout the image(try to maximize the image by clicking maximize button on the top right end corner of the figure 16).Did u tried running this code?
expected output is, input image enhanced by the factor 2(i.e if the size of input image is 512*512, then output image must be 1024*1024 pixels) by using 2D DWT with some intermediate operation (necessary for my work).
Proposed technique used:i am subtracting input image by LL component after applying DWT2 function, so that resultant will be i.e Diff_Img is the high component of the input image, this image is used to estimate the LH HL and HH component by adding Diff_img with Lh HL and LL respectively .
Finally input image ,estimated LH HL HH are intrpolated by scaling factor (scale/2) and then IDWt2 function is applied to get the output resolution enhance image.
problem: white patches appear throughout the output image.
sir please replac line Diff_Img=imsubtract(image,LHI); by Diff_Img=imsubtract(image,LLI); because am suppose to subtract LL component with input image not LH.
am new to mathwork ,so didnt knew edit option. now have edited that Diff_Img=imsubtract(image,LHI),so u can directly run the code without any modificatons..
How is it posssible to subtarct a time domain Input Image with interpolated Subband which is in frequency domain?
can i have the codes of interpolation of wavelet domain please..

Sign in to comment.

Answers (1)

you can use this code instead of former
clc; clear all; close all;
y=imread('7.jpg'); y=rgb2gray(y);
[m,n]=size(y); [Lo_D,Hi_D,Lo_R,Hi_R] = wfilters('haar'); [LL,LH,HL,HH]=dwt2(y,Lo_D,Hi_D); [m1,n1]=size(LL); imshow(y);title('INput Image'); figure; subplot(3,3,2);imshow(uint8(LL));title(' LL Image'); dec=[LL,LH HL,HH]; err=uint8(idwt2(LL,LH,HL,HH,'haar',[m,n]));
LLI = imresize(LL,2,'bicubic'); LHI = imresize(LH,2,'bicubic'); HLI = imresize(HL,2,'bicubic'); HHI = imresize(HH,2,'bicubic'); image=double(y); err2=uint8(idwt2(image,LHI,HLI,HHI,'haar',[2*m,2*n]));
subplot(3,3,3);imshow(uint8(image));title('doubled input image'); subplot(3,3,4);imshow(uint8(LLI));title('iterpolated LL Image'); subplot(3,3,5);imshow(uint8(LHI));title('iterpolated LH Image'); subplot(3,3,6);imshow(uint8(HLI));title('iterpolated HL Image'); subplot(3,3,7);imshow(uint8(HHI));title('iterpolated HH Image'); %Diff_Img=(imsubtract(image,LLI)); Diff_Img=image; subplot(3,3,8);imshow(uint8(Diff_Img));title('Difference Image'); figure;imshow(err);title('reconstructed Image'); figure;imshow(err2);title('reconstructed Image'); [m,n]=size(Diff_Img); b=32; for i=1:m for j=1:n ELH(i,j)=((Diff_Img(i,j)+LHI(i,j))/b);% end end
% figure(9),imshow(ELH);title('Added LH Image');
for i=1:m
for j=1:n
EHL(i,j)=((Diff_Img(i,j)+HLI(i,j))/b);%
end
end
% figure(10),imshow(EHL);title('Added HL Image');
for i=1:m
for j=1:n
EHH(i,j)=((Diff_Img(i,j)+HHI(i,j))/b);%
end
end
% figure(11),imshow(EHH);title('Added HH Image');
%scale the image by factor of two
scale=2;
LLI2 = imresize(image,scale/2,'bicubic');
% figure(12),imshow(LLI2);colormap gray;title('Resized for IDWT input image');
LHI2 = imresize(ELH,scale/2,'bicubic');
% figure(13),imshow(LHI2);colormap gray;title('Resized LH Image');
HLI2 = imresize(EHL,scale/2,'bicubic');
% figure(14),imshow(HLI2);colormap gray;title('Resized HL Image');
HHI2 = imresize(EHH,scale/2,'bicubic');
% figure(15),imshow(HHI2);colormap gray;title('Resized HH Image');
% image=im2double(image);
% out=uint8(idwt2(LLI2,LHI2,HLI2,HHI2,'haar',[m,n]));
out=uint8(idwt2(image,LHI2,HLI2,HHI2,'haar',[2*m,2*n]));
out=imresize(out,.5);
figure(16),imshow(out);title('output enhanced image');

Categories

Products

Asked:

on 11 May 2012

Answered:

on 15 Feb 2017

Community Treasure Hunt

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

Start Hunting!