We can calculate a discrete derivative by taking the difference of two pixels in x and y directions.
This can be expressed as a 2d convolution and implemented with scipy.signal.convolve2d
.
This shows us sharp features in x and y directions, as seen below.
We can also combine the 2 derivates into a gradient and use its magnitude (= (∂x2 + ∂y2)1/2) for edge detection.
We can then add a threshold to visualize edges while filtering out noise.
After applying Gaussian filter:
The edges are thicker and smoother due to Gaussian blurr.
There is less noise in the gradient magnitude and thresholded images.
The DoG filters:
Convolving the images against the DoG filters produces the same images as convolving against the derivative filter and then the gaussian filter (or in the other order).
With unsharp masking:
We can test out unsharp masking quality by taking an image, blurring it, and then attempting to sharpen it.
The two images above are blurred and then resharpened using unsharp mask.
The album cover has high frequencies on the right side of the middle. After blurring, the waves look blurry but still present.
Unsharp mask sharpens the waves on the right side of the face; however, does not eliminate the blurriness in the waves.
Furthermore, unsharp mask cannot restore details in people or architecture in the catherdral; however, makes the people higher contrast.
More examples:
Circular Mask:
Elephant head mask:
Humans perceive separate frequencies within images differently. In order to blend images, the mask's gradient needs to be around the same order of magnitude as the feature.
This means that high frequencies should be blended quickly while small frequencies should be blended smoothly.
Laplacian stack allows us to break an image down into separate frequencies. Then, we can blurr two laplacian stacks by using bigger masks on smaller frequencies.
Images can be interpreted in the frequency space to achieve visual and structural effects.