Can anyone combined these operations for a gray scale image?

  1. Step1-A grayscale image--->DWT
  2. Step2-Grayscale Image--->Apply Canny Edge Detector
  3. Step3-Combined step2 & step1 to make a Defocus Image

6 Commenti

@Haseeb Hassan: what have you tried so far?
 (1) 2D wavelet transformation  to get binary image
 (2) Canny edge detection to get  binary image.
 (3)Perform logic AND for the images to produce defocus image.
 The Following Code is here i have so far used:
clear all ; close all
lx = imread('C:\Users\Haseeb\Desktop\images\capture.jpg');
%figure; imshow(lx);
x = rgb2gray(lx);
figure
imshow(x)
%% Applying Low Pass and High Pass Filter on the Gray Scale Image
[xar,xhr,xvr,xdr] = dwt2(x,'haar');
xa= xar ; 
xh= xhr ; 
xv= xvr ; 
xd= xdr ;
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,'haar');
xaa= xaar ; 
xhh= xhhr ;
xvv= xvvr ; 
xdd= xddr ;
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 ])
%% Applying Canny Edge Detector
BW1 = edge(x,'Canny');
imshow(BW1)
Your final image is a binary image, clarify yes/no?
Yes my final image will be a binary image.
%%Apply DWT
dwt_image=dwt2(x,'haar');
dwt_im2=imresize(dwt_image,[rows colm]);
gray_im=im2bw(dwt_im2);
figure ;imshow(gray_im);
%%Applying Canny Edge Detector
BW1=edge(x,'Canny');
result=and(gray_im,BW1);
As from your code after getting wavelet transform you assigned this matrix to gray_im matrix and then you concatenated these two matrices by AND operator and on other side we just apply simple canny edge detector to our input image but in both cases the result image is same. The first question is why you convert the wavelet transform matrix to binary image and if you applied after comparison with our output image (by applying simple canny edge detector) are same.
Just for comparison purpose only. I followed the steps as per your questions.

Accedi per commentare.

 Risposta accettata

%I tried as per your statement flow-here it is, but did not find any sense of defocus.
%Result is binary image.
lx=imread('1.jpg');
x=rgb2gray(lx);
[rows colm]=size(x);
%%Apply DWT
dwt_image=dwt2(x,'haar');
dwt_im2=imresize(dwt_image,[rows colm]);
gray_im=im2bw(dwt_im2);
%%Applying Canny Edge Detector
BW1=edge(x,'Canny');
result=and(gray_im,BW1);
%%Display
binaryImage=uint8(255 * result);
result1=[lx,cat(3, binaryImage, binaryImage, binaryImage)];
imshow(result1);

1 Commento

Okay Sir can you explain me this by code . "2D wavelet transformation of the input image with a specific threshold to produce a binary image". I am confused about the specific threshold where we can use or how we can use the specific threshold in DWT.

Accedi per commentare.

Più risposte (0)

Community Treasure Hunt

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

Start Hunting!

Translated by