How to get a defocus image from single image to which already applied wavelet transform and canny edge detector ?

1 view (last 30 days)
Hello everyone. I have a color image, trying to get first the wavelets transform and then apply canny edge detctor
separately on the color image.After getting wavelet transform of an image and edges through canny detector, then
want to get the focus image from the two previous applied operations.The algorthm should be look like this.
1-colar Image--->Wavelet Transform ,
2-color Image-->Canny Edge Detector ,
3- Wavelet Transform Image & canny edges Image----> Defocus Image.
Please see in the image what actually i want to do.
clear all ; close all
x = imread('football.jpg');
figure; imshow(x);
%%Applying db2 for getting Avg Aprroximation,Horizontal,Vertical and Diagonal Details
[xar,xhr,xvr,xdr] = dwt2(x(:,:,1),'db2');
[xag,xhg,xvg,xdg] = dwt2(x(:,:,2),'db2');
[xab,xhb,xvb,xdb] = dwt2(x(:,:,3),'db2');
xa(:,:,1) = xar ; xa(:,:,2) = xag ; xa(:,:,3) = xab ;
xh(:,:,1) = xhr ; xh(:,:,2) = xhg ; xh(:,:,3) = xhb ;
xv(:,:,1) = xvr ; xv(:,:,2) = xvg ; xv(:,:,3) = xvb ;
xd(:,:,1) = xdr ; xd(:,:,2) = xdg ; xd(:,:,3) = xdb ;
%%figure, imshow(xa/255) ;
%%figure, imshow(xh) ;
%%figure, imshow(xv) ;
%%figure, imshow(xd) ;
%%To get the window in standarized Form
X1 = [xa*0.003 log10(xv)*0.3 ; log10(xh)*0.3 log10(xd)*0.3] ;
figure ; imshow(X1)
%%Agian applying db2 to the subsampled Avg Approximationation Image, Vertical,horizontal details and diagonal
details.
[xaar,xhhr,xvvr,xddr] = dwt2(xa(:,:,1),'db2');
[xaag,xhhg,xvvg,xddg] = dwt2(xa(:,:,2),'db2');
[xaab,xhhb,xvvb,xddb] = dwt2(xa(:,:,3),'db2');
xaa(:,:,1) = xaar ; xaa(:,:,2) = xaag ; xaa(:,:,3) = xaab ;
xhh(:,:,1) = xhhr ; xhh(:,:,2) = xhhg ; xhh(:,:,3) = xhhb ;
xvv(:,:,1) = xvvr ; xaa(:,:,2) = xvvg ; xvv(:,:,3) = xvvb ;
xdd(:,:,1) = xddr ; xdd(:,:,2) = xddg ; xdd(:,:,3) = xddb ;
%%figure,imshow(xaa/255);
%%figure,imshow(xhh);
%%figure,imshow(xvv);
%%figure,imshow(xdd);
X11 = [ xaa*0.001 log10(xvv)*0.3 ; log10(xhh)*0.3 log10(xdd)*0.3 ] ;
%%figure; imshow(X11)
[r,c,s] = size(xv);
figure ; imshow([X11(1:r,1:c,:) xv*0.05 ; xh*0.05 xd*0.05 ])
%%Jacobian Edges Applied(https://www.mathworks.com/matlabcentral/fileexchange/28114-fast-edges-of-a-color-image--
actual-color--not-converting-to-grayscale-)
%get color edges and normalize magnitude
C = coloredges(x);
C = C / max(C(:));
%get grayscale edges and normalize magnitude
G_image = single(rgb2gray(x)) / 255;
G = sqrt(imfilter(G_image, fspecial('sobel')').^2 + imfilter(G_image, fspecial('sobel')).^2);
G = G / max(G(:));
%show comparison
figure, imshow(uint8(255 * cat(3, C, G, G)))

Answers (0)

Community Treasure Hunt

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

Start Hunting!