Image Processing- Background Knowledge (1)
Just some image processing note~
General Idea
In image processing, we use image sensors/ camera sensors, e.g.: CMOS,CCD, to digitize real world signals.
For 2D image:
A projection of the reflected light of the 3D world to a 2D camera sensor.
For 3D image:
Measuring multiple spatial locations and stacking the 2D images to 3D volumes.
Also, we can collect the image (2D, 3D) in different time, combining into video (2D+t, 3D+t)
Representation
Usually, we use grids, so-called 2D: pixel/ 3D: voxel, to represent the relative location of the 2D/3D image, and each grid has their quantization of irradiance.
Typical intensity value range for 2D image:
1. 8 bit (0–255) 2. 16 bit (0–65535) 3. 32 bit (floating point) 4. RGB (3* 8 bit channel )
Typical formats for 2D image:
Tiff, PNG, JPEG, GIF, RAW……etc.
Typical formats for 3D image:
Different 3D image has their unique format, and there is a header to describe how the information is stored.
Neighborhood Relations
If there are multiple pixels/ voxels have common edge/ shared edge, then they are neighbors。
For the 2D image, there are two types of neighborhood:
Type1: 4-Neighborhood
Pixels are connected by shared edge.
Type2: 8-Neighborhood
pixels have shared edge and shared corner.
For the 3D image, there are 3 types of neighborhood:
6-Neighborhood (shared face)、18-Neighborhood (shared face, edge)、26-Neighborhood (shared face, edge, corner)
Intensity transformations
It is a point operation that transform the original intensity values w/o considering the neighborhood, e.g.: Gamma Transformation, Image Complement……etc.
Histogram Processing
With the histograms, we can have information about the contrast in an image.
Implementation
Step1: Accumulating the intensities of each pixel/ voxel as intensity frequency, in other words, how many the same intensity value showed up in the image.
Step2: Put all frequency of intensity into the chart, i.e.: horizontal axis represents intensity, and vertical axis represents the frequency of intensity.
Histogram equalization
We can make the distribution of intensity value equally distribute, and it can help increase the contrast.
Histogram specification/ matching
We can map intensities match a predefined shape.
Example
Take the sky picture as an example. Firstly, we can transform the image into gray scale, then we accumulate the intensities. Therefore, we will obtain the histogram.
.
As you can see on the left, CDF represent the cumulative distribution function.
With the histogram, we can use function of Opencv to make the intensity equally distribute, e.g.: cv2.equalizeHist(imgsrc).
.
.
Because of the Histogram equalization, the contrast of the image has been increased.
Some parts of the cloud is more clear than the original image, and some parts of blue sky become darker.
.
If we want to match the sky with this beautiful grassland, then we need to find each intensity in RGB in both the sky image and the grassland image.
Finally, we will get three histogram of different color channel.
.
With the histogram of each RGB channel in both images, we can match the source(SKY) with the reference(Grassland), you can find the result in the following figure.
Application
We can use histogram for Contrast adjustment, binary threshold, approximating probability distribution of intensity.