Thursday, September 8, 2016

Week 3: Smoothing and Sharpening


This week, we implemented some image smoothing and sharpening techniques using different convolution kernels. Smoothing is used to remove the noise in the image while sharpening is used
to highlight fine details in an image or enhance details that have been blurred.

Mean Filter


As discussed in our lecture class, Mean filter is a low-pass filter that takes the mean of the pixels under the kernel. It is used to smoothen an image by removing the noise.


Now, we'll try these kernels and see what will happen to the image:

Figure 1. Original test image


kernel 1
kernel 2
kernel 3









kernel 4

kernel 5
















Output


Figure 1.1 Output image when kernel 1 is used







Kernel 1

The salt and pepper noise in the test image is smoothed, and the image in turn became blurred.








Figure 1.2 Output image when kernel 2 is used




Kernel 2

Applying kernel 2, I think, is supposed to be a weighted averaging filter because we give more weight to the pixels closest to the pixel of interest which is f(x,y). I am not sure thoough why the image was sharpened when it was supposed to be smoothened because this is a type of mean filter.






Figure 1.3 Output image when kernel 3 is used

Kernel 3 

If you take a closer look, you'll notice that the image is sharpened, however, the brightness became low.

This kernel is a Laplacian mask filter, a high-boost filter (A=1) used for sharpening and brightening images; therefore the weighted sum must be taken, not the weighted average which we are using in our program, in order for it to properly work. This must be why the image became darker.






Figure 1.4 Output image when kernel 4 is used

Kernel 4 

Instead of a smoothened image, the output produced is the outline of the image or the edges. (Because the image has a lot of noise, it produced many false positives.)

The sum of the values of the kernel is 0; therefore, it is a high-pass filter used for sharpening images. However, in high-pass filter, the weighted sum is taken instead of the weighted average (which we are currently using in our mean filter program). 




Figure 1.5 Output image when kernel 5 is used



Kernel 5 

Applying kernel 5 for filtering, it produced an image of low brightness.


Week 2: Adorable photos transformed using intensity transform functions


For our second exercise, we were asked to gather 4 images: an image with low contrast, high contrast, an image taken at night and a normal one, taken with natural light.

Naturally, I picked my pets as subjects of these images because who doesn't love cats or dogs?

Image 1. (Low Contrast)
This is Tenten (short for Kitten), my adorable cat.
This picture was taken in natural light but I used an
image editing app to tweak the contrast setting.
Image 2. (High Contrast)
This hilarious photo of MiHo sleeping was taken
in daylight and again, I adjusted the contrast
using an image editing app.


Image 3. (Night Time)
This picture is a puppy named Taiga (Tiger),
taken at night, under a fluorescent light.
Image 4. (Normal)
This is a picture of my neighbor's cat,
which will remain unnamed, taken at daylight.


These images will then be read using a program (image_trans.cpp) in OpenCV provided in the laboratory class and will produce 12 outputs in total.

image_trans.cpp


Basically, the program obtains the pixel values of the image and then manipulates each of them by using some functions.

Function 1

Applying the first function y = 1 - x, returns the maximum pixel value minus the current (channel) pixel value. Let's see what will happen to the images when this function is applied:


Image 1. Original vs. transformed image (using function 1)
Image 2. Original vs. transformed image (using function 1)
Image 3. Original vs. transformed image (using function 1)
Image 4. Original vs. transformed image (using function 1)

 Based on the images produced, it seems the first function gives the image negative. The light parts of the images became dark and the colors are reversed into their respective complementary colors. The dark/light transformation is most apparent in images 2 and 3. Meanwhile, the yellow/orange colors turned into bluish tints in image 1 and 4 because the complimentary of yellow is blue.


Function 2

Next, we'll apply the second function, y = 0.001x^2 - 0.023x (y representing the value returned, x is the current channel/pixel value). These are the output images when function 2 is applied:

Transformed images using function 2: y = 0.001x^2 - 0.023x
The brightness of the images became low.

Function 3

Lastly, applying the third function, y = 0.47x + 120, these are the output images:

Transformed images using function 3: y = 0.47x + 120
The contrast of the images became low. The first image, which is a low contrast image, became even more grayish compared to the other images. Images 3 and 4, which were taken in daylight


Hello World!

(Mandatory intro of a programmer.)