Tej Bade, [email protected]

1.1 Finite Difference Operator

We are given the following image cameraman.png and want to use the finite difference operator as a filter to compute gradients and reveal an edge image.

cameraman.png

Given $D_x = [1 -1]$ and $D_y=[1 -1]^T$ , we convolve the image with $D_x$ and $D_y$ to get the partial derivatives in the x and y direction, which we call $dx$ and $dy$ respectively. We can calculate the gradient using np.sqrt(dx ** 2 + dy ** 2). Finally we can binarize the gradient by only keeping the gradients that have values over a certain threshold. Using this method on cameraman.png gives us the following images.

            Partial derivative in the x-direction

        Partial derivative in the x-direction

             Partial derivative in the y-direction

         Partial derivative in the y-direction

           Computed gradient of the image

       Computed gradient of the image

      Binarized gradient using a threshold of 0.30

  Binarized gradient using a threshold of 0.30

1.2 Derivative of Gaussian (DoG) Filter

Using the finite difference operator gives us a lot of noise in our results. We can instead convolve the image with a Gaussian filter to blur the image. We use OpenCV’s library to get a 1D Gaussian kernel with parameters ksize and sigma, representing the dimension and standard deviation respectively. We can take the outer product of the kernel with its itself to get a 2D Gaussian kernel. Using the finite difference method on the blurred image gives us the following results. I used ksize = 11 and sigma = 2 for the Gaussian kernel. For all of the convolutions in this section, I used signal.convolve2d with mode='same' and boundary='symm'.

    Partial derivative in the x-direction using DoG

Partial derivative in the x-direction using DoG

      Partial derivative in the y-direction using DoG

  Partial derivative in the y-direction using DoG

                   Gradient image with DoG

               Gradient image with DoG

    Binarized gradient with DoG (threshold is 0.07)

Binarized gradient with DoG (threshold is 0.07)

Compared to the previous images, we can see that in our DoG method the partial derivatives are more visible. The edges in the gradient image are more visible and there is much less noise in the gradient image. The binarized gradient has much less noise even with a much smaller threshold.

Because of the associativity of convolution, we could have first convolved the Gaussian kernel with $D_x$ and $D_y$ to get DoG filters and then convolved the original image with these filters. Doing this with ksize = 11 and sigma = 2 gives us the two filters below.

                 DoG filter in the x-direction

             DoG filter in the x-direction

                 DoG filter in the y-direction

             DoG filter in the y-direction

Convolving the image with these filters gives us the following.

    Partial derivative in the x-direction using DoG

Partial derivative in the x-direction using DoG

    Partial derivative in the y-direction using DoG

Partial derivative in the y-direction using DoG

                   Gradient image with DoG

               Gradient image with DoG

    Binarized gradient with DoG (threshold is 0.07)

Binarized gradient with DoG (threshold is 0.07)

These images are the same as those obtained from convolving the original image with the Gaussian kernel before $D_x$ or $D_y$.