2: Introduction to Basic Operations
Now that we have covered the numerical representation and colors of digital images, we can move to some basic image processing operations.
We will be using the lena image, a commonly used image for image processing, in this section.
Sampling involves taking the value of the image at regular spatial intervals. The length of the intervals define the spatial resolution of the image. We define N as the number of pixels per side of the image. The larger the N, the denser the points are and the better the resolution.
Here, samples are taken at N equal to 14, 28, 55, 110, and 220. This means that the image with N=14 has 14 unique shades of color only. Furthermore, the size of the image is reduced as well.
This is used practically in analog pictures by cameras by focusing or un-focusing the lens. In essence, it is the resolution of the image.
2. Quantization deals with binning values. Unlike sampling where the values are removed based on the N resulting in smaller (or bigger) images, the size of the image remains the same and values are replaced by the bin value.
In the case of k=2, there are only 2 bins a color can appear in and in this case, the 2 bins are of colors black and red. With more bins, more color options get unlocked.
The intensity values of the image are therefore discretized by k number of bits to represent an intensity value also known as its bit depth.
3. Color Spaces
We have already discussed about colors in digital images in the previous post so we will look at some color manipulations here.
Taking again the lena image, we will explore some functions for color spaces.
First off, we have gray scaling. Since images usually appear in color, and colored images have 3 channels, they can be converted to gray scale with the rgb2gray function. This converts the image to a single layer with values between 0 (black) and 1 (255 white). With values in between this range, the image appears in shades of gray. However, if one wants the image to be strictly black and white, the image needs to be binarized. Here, a threshold is set for what level of gray you want to consider as black or white. A lower threshold makes the image more white and vice versa. A gray image back cannot be converted back to its original colored form but using the gray2rgb restores the shape of the image with 3 channels, although still in gray scale.
Another representation of color spaces can be in the hue-saturation-value (HSV) format. The HSV are now the 3 channels instead of the color channels.
These representations will be useful in later applications where certain colors, tints, or features need to be extracted.