%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%% EE 684 - Spring 2016
%%%% Simple Code for wavelet tranbsform of a sample mammography image 
%%%%
%%%% We can use teh outcome of this transform as input to CAD
%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


clear all
close all

im1= imread('mdb100.pgm');      % sample image - make sure it is in same folder
N= 1024;                        % image size

[c,s]=wavedec2(im1,2,'haar');

[H1,V1,D1] = detcoef2('all',c,s,1);
A1 = appcoef2(c,s,'haar',1);
V1img = wcodemat(V1,255,'mat',1);
H1img = wcodemat(H1,255,'mat',1);
D1img = wcodemat(D1,255,'mat',1);
A1img = wcodemat(A1,255,'mat',1);

[H2,V2,D2] = detcoef2('all',c,s,2);
A2 = appcoef2(c,s,'haar',2);
V2img = wcodemat(V2,255,'mat',1);
H2img = wcodemat(H2,255,'mat',1);
D2img = wcodemat(D2,255,'mat',1);
A2img = wcodemat(A2,255,'mat',1);


figure(1)
im1w1= im1;
im1w1(1:N/2,1:N/2)= A1img;
im1w1(1:N/2,N/2+1:end)= H1img;
im1w1(N/2+1:end,1:N/2)= V1img;
im1w1(N/2+1:end,N/2+1:end)= D1img;
image(im1w1);
colormap(gray);

figure(2)
im1w2= im1w1;
im1w2(1:N/4,1:N/4)= A2img;
im1w2(1:N/4,N/4+1:N/2)= H2img;
im1w2(N/4+1:N/2,1:N/4)= V2img;
im1w2(N/4+1:N/2,N/4+1:N/2)= D2img;
image(im1w2);
colormap(gray);




