[Note] grayscale conversion

Source: Internet
Author: User
Tags scale image

1. grayscale
Here we will discuss: RGB spatial images

Color Map defined in RGB space. The color of each pixel is determined by the R, G, and B components. The memory size of each component determines the image depth, that is, the number of bytes occupied by each pixel. In a common 24-Depth Color RGB diagram, each of the three components occupies one byte, so that each component can be 0 ~ 255, so that a pixel can have a color change range of more than 16 million (255*255*255. For such a color image, the gray-scale image corresponding to it is only 8-bit image depth (it can be considered as RGB with three equal components ), this also shows that the amount of computing required for grayscale image processing is indeed small. However, although some color levels are lost, we can see from the overall and local color and brightness level distribution features of the entire image, the grayscale image description is consistent with the color image description.
For the grayscale RGB image, the general point is to calculate the final grayscale value by weighted average of the three RGB components of the image. The most common weighting method is as follows:

1) gray = B; gray = g; gray = r

2) gray = max (B + G + r)

3) gray = (B + G + r)/3

4) gray = 0.072169b + 0.715160G + 0.212671r

5) gray = 0.11b + 0.59G + 0.3r
Among the three methods, the first method is the component method, that is, using a component of RGB three components as the gray value of the point; the second method is the maximum value method, the maximum brightness of a three-part color image is used as the gray value of the grayscale image. The third method is to calculate the average brightness of three parts in the color image to obtain a grayscale image. The latter two are weighted average, and the fourth method is the gray weight used by the opencv Open Library, the fifth type is a kind of weight proposed from the perspective of human physiology (human eyes are most sensitive to green and blue)

  

2. grayscale Histogram

  Grayscale HistogramIt is a tool for statistics on the gray level information of images. The vertical axis represents the gray level, and the vertical axis represents the probability. Generally, histogram operations can be used in image enhancement, image compression, and image segmentation.

Opencv: http://blog.csdn.net/morewindows/article/details/8364656

In addition, there are three types of gray-scale transformations:

Linear transformation: stretch and expand based on linear changes when the gray-scale interval of the source image is small;

Logarithm Transformation: exponential transformation is used to expand the image's high gray level, compress the low gray level. Although idempotent transformations also provide this function, the image contrast is higher after exponential transformation, and the high gray level is extended to a wider range.

Similar to the logarithm transformation, the power transformation maps some gray areas to a wider area. WhenR= 1, the power transformation is converted to linear transformation.

(1) WhenR<0, the transformation function curve is above the proportional function. At this time, the image can be scaled to a lower gray level and compressed to a higher gray level to make the image brighter. This is very similar to the logarithm transformation.

(2) WhenRWhen the value is greater than 0, the transformation function curve is below the proportional function. At this time, the high gray level is expanded, and the image is dimmed by compressing the low gray level.

  

3. histogram equalization

  Histogram equalizationIt is a method that uses the image histogram to adjust the contrast in the image processing field. For images with poor contrast, the histogram of the gray-scale values of the images can be evenly distributed to enhance the contrast of the images.

Opencv: http://blog.csdn.net/morewindows/article/details/8364690

4. Spatial Filtering

An image enhancement method that uses filter processing. Its theoretical basis is spatial convolution. The objective is to improve image quality, including removing high-frequency noise and interference, and enhancing image edge, linear enhancement, and deblurring. It can be divided into low-pass filtering (smoothing), high-pass filtering (sharpening), and band-pass filtering. Processing methods include computer processing (digital filtering) and optical information processing.

Generally, a domain (filter template) is selected, and all vertices in the domain are multiplied by the filter coefficient and the result is filtered.

Based on functions, the airspace filtering technology mainly includes smooth filtering and sharpening filtering.
Smooth filtering can weaken or eliminate the high-frequency components in the image without affecting the low-frequency components. The high-frequency components correspond to the gray-scale values such as the Regional edges in the image with great changes, smooth filtering can filter these components to reduce local gray-scale fluctuations and make the image smoother. It can also be used to eliminate noise, remove small details before extracting a large target, or connect a small intermittent target.
In smooth filtering, mean (linear) filtering may bring about side effects of contour fuzzy, while mean value filtering (non-linear) filtering achieves excellent noise reduction, which is less fuzzy than mean filtering, especially for pulse noise removal, but it may lead to changes in image properties.
Sharpening filtering is the opposite. Sharpening filtering is often used to enhance blurred details or target edges to enhance image details.

 

[Note] grayscale conversion

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.