Computer Vision: Image Filtering
Image filtering is Transforming an image from one iteration to another one that is easier to extract from.
A lot of image processing happens before an image actually displays.
First, mathematically define a function.
An image is 2 coordinates x and y. f(x, y) represents the image intensity at coordinates (x,y).
In Montreal, circa 2014. (x,y) determines the image intensity,
not the color.
f is a continuous function; however, computer vision uses digital images.
1. Sample the 2D Array space at a discrete pixel location
2. Quantize each space, and then subsequently round to the nearest integer.
In ideal theory, images are continuous and infinite, but in practice, they are discrete.
For example, here is a 1D function snapped to some discrete values. Digital images can also be written as matrices.
The blue line is continuous here, whereas the red lines are discrete.
The amount of rounding that one needs to do is fully dependent on the number of bits in this particular matrix.
To darken an image, subtract from pixel values.
To brighten an image, add to pixel values.
To invert a pixel, subtract the pixel values to the maximum values (for 8 bits, this is 255 - f).
To have low contrast, divide the pixels by a constant.
To have high contrast, multiply the pixels by a constant.
For a grayscale image, perform the following equation:
(0.3 * (red value) + 0.6 * (green value) + 0.1 * (blue value))
Remember, the value of the pixel in the output image depends only on the intensity of the same pixel on the original image.
Original Image
Image filtering has many properties:
It helps to enhance images, extract information from images, and detect patterns in images.
In image filtering, a local neighborhood of pixels determines the pixel's intensity.
Image filtering is definitely still a linear transformation.
A linear filter is the weighted sum of certain other filters.
In the following equation, m and n are x and y points; respectively. K is the magnitude in the X direction, whereas L is the magnitude in the y direction. The equation is as follows:
A filter is a small array of numbers, and to apply the filter, fill in the image one pixel at a time. Multiply a filter with a underlying image and take the underlying image. This is very similar to the dot product in an underlying image.
An example of a filter, with colors representing the magnitudes.
A box filter, which helps greatly in blurring images and getting important averages.
However, for boundary locations, the filter moves outside of these boundaries.
There are 3 solutions to deal with boundaries.
1. Ignore the border of the image.
2. Pad the boundaries of an image with a constant value.
3. Pad the boundary of the image with the reflection. This means, to flip the image.
Applying a filter with a matrix with only the center value as 1 results in the same image.
Having a matrix all the way on the left side of the image will simply just perform image shifting on the image. The entire image gets shifted to the bottom right.
Taking a weighted
sum of an image will brighten the image. To keep the same intensity, average the values, make sure that the sum of all the filtered weights should be 1.
a box filter can be used to smoothen an image/blur, in order to remove the computational complexity of the image.
image, with box filter applied.
original image
One fuzzy filter would be a gaussian filter which follows the corresponding visualization:
The neighbors closer to the center get a higher weight. The resulting image is much smoother. With a larger wider Gaussian, the image is blurred out.
One interesting property about a Gaussian filter is it is separable. I can write a 2d Gaussian Filter as a combination of 2 1D Gaussian Filters.
A 2D Gaussian takes K^2 multiplications and K^2 - 1 Additions. In contrast 2 1D Gaussian filters takes only 2K Multiplications and 2(K - 1) additions!
Another application of filtering is to reduce image noise, after applying a Gaussian filter. The reason why noise is not completely removed is because noise is in the form of grains, but their intensities are VERY different from its neighbors.
Another idea is to design a filter based on a median. it works as follows.
1. Sort the K^2 values in the window centered along the pixel, and assign the median value of these pixels.
The tradeoff is that the median filter is slower due to the time required for mergesort.
In convolution, we flip the filter horizontally and vertically before correlation is performed. Another tradeoff is that this filter can blur the image more and start removing all of the details.
Note: that small number is 1/9.
This filter surprisingly sharpens an image.
Another example is called template matching, where the goal is to find a small image template in a larger image.
The next idea is to try to minimize the difference.'
The problem with cross-correlation is that it needs to be normalized.
This ensures the image regions with larger intensities do not have an unfair advantage. The location where there is a peak in the final resulting image, is the location of the image in the template.Original image. By using the decomposition, we can extract a small part such as:
Thank you for reading.

















Comments
Post a Comment