Image Enhancement using DWT and IDWT

6 次查看(过去 30 天)
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 个评论
Sumathi K
Sumathi K 2013-1-29
How is it posssible to subtarct a time domain Input Image with interpolated Subband which is in frequency domain?
kelvin sako
kelvin sako 2014-11-26
can i have the codes of interpolation of wavelet domain please..

请先登录,再进行评论。

回答(1 个)

ramin ranjbar
ramin ranjbar 2017-2-15
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');

类别

Help CenterFile Exchange 中查找有关 Discrete Multiresolution Analysis 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by