September 2023
Gradient Magnitude image formula:
Dx = $\begin{bmatrix}
1 & -1
\end{bmatrix}$
Dy = $\begin{bmatrix}
1\\
-1
\end{bmatrix}$
Dx_im = Dx * image
Dy_im = Dy * image
Gradient Magnitude = $\sqrt{Dx\_im ^2 + Dy\_im
^2}$
To calculate the partial derivative in x and y, I convolved the image
with finite difference operators Dx and Dy. The Dx operator will do a
basic slope calculation between the im[y, x] and im[y, x+1]. The Dy
operator will do the same but in the y-axis. Important to note that the
Dx will find vertical edges and the Dy will find horizontal edges. The
gradient magnitude represents how we want the average of these changes
therefore we just do the L_2 Norm of Dx_im and Dy_in. There are many
edges in the image, but we want just the prominent ones and not the
noisy ones. To find the real edges without noise, I binarized the
gradient magnitude by choosing an appropriate threshold.
Differences between 1.1 and 1.2 (Gaussian blurring): In the blurred image, the edges are more prominent and there is less noise in the image. Since the high frequencies have been removed, the threshold value can be reduced since only the most prominent edges remain. In this case it went from 0.25 to 0.03.
The graphs "Blur then Derivative Convolve" and "Single Convolution" look basically the same with the prominent edges showing up in both of them.
This was really cool. I’ve played around with photoshop before, but I never knew it was using a bunch of math. The hard part was finding images that would align correctly.