Image processing (Chapter 9 color image processing, color model, RGB, HSI, YCbCr, pseudo-color processing, full-color image processing, histogram, smoothing, sharpening, segmentation, red-eye removal)

Chapter nine

9.1 Color basics

9.1.1 Basics of colorimetry (just understand)

White light can be broken down into a series of continuous spectra ranging from purple to red.

(1) Absorption characteristics of the
human eye The cone cells of the human eye are sensors responsible for color vision. The cone cells of the human eye can be divided into three main sensory categories.

Approximately 65% ​​of cone cells are sensitive to red light, 33% are sensitive to green light, and only 2% are sensitive to blue light.

Due to the absorption characteristics of the human eye, the colors seen are various combinations of the so-called primary colors red (R, red), green (G, green) and blue (B, blue).

(2) The principle of three primary colors
Any color can be obtained by mixing 3 different basic colors in different proportions.

The three primary colors of red, green and blue can be mixed in proportion to obtain various colors. The color matching equation is:
Insert picture description here
(3) Color to grayscale conversion
of the three primary colors of the same brightness. The human eye feels that the brightness of green light is the brightest, and the red light is second. Blue light is the weakest.
If Y is used to represent white light, that is, the brightness (gray scale) of the light, the relationship is as follows:
Y=0.299R+0.587G+0.114B

9.2 Color model

In order to quantitatively describe and use color scientifically, various color models have been proposed. The commonly used color models can be divided into three categories according to their purposes:
①Calculated color models are
used for theoretical research on colors. Common RGB models, CIE XYZ models, Lab models, etc. belong to this type.

②Visual color model
refers to a model similar to the human eye's visual model of color perception. It is mainly used for color comprehension. The common ones are HSI model, HSV model and HSL model.

③Industrial color model
focuses on practical applications, including color display systems, color transmission systems, and television transmission systems. Such as the CMYK model used in printing, the YUV model used in TV systems, and the YCbCr model used in color image compression.

9.2.1RGB color model (just understand it)

Insert picture description here

The different colors are on or inside the cube and can be defined by a vector distributed from the origin. And assuming that all color values ​​are normalized, the cube shown in the figure above is a unit cube, that is, all RGB values ​​are within the range of [0,1].

9.2.2 CIE XYZ model (just understand)

Visible light F, there are: F=x⋅X+y⋅Y+z⋅Z
Insert picture description here

9.2.3Lab color model (just understand)

The two chrominance components a and b of L brightness or brightness component a
in the positive direction means more red, and the larger value in the negative direction means greener; the
larger the value of b in the positive direction means more yellow. The larger the value in the negative direction, the more blue it is.

9.2.4 HSI color model (emphasis)

(1) Why is the hsi model widely used in image processing and recognition (emphasis)

① The I (luminance) component has nothing to do with the color information of the image;
② The H (hue) and S (saturation) components are closely related to the way people perceive colors. These characteristics make the HSI model very suitable for color characteristic detection and analysis.
Insert picture description here
(2) Features
Insert picture description here

9.2.5 CMY color model (just understand it)

The primary colors are: cyan (Cyan), magenta (Magenta), yellow (Yellow)

In practical applications, due to the large amount of black, black ink is often used directly to produce black in printing, thereby saving the amount of cyan, magenta, and yellow inks. Therefore, CMYK is often used to represent the CMY model.

9.2.6 YUV TV signal color coordinate system (just understand it)

When the color TV signal is transmitted, RGB is changed into a luminance signal and a chrominance signal. The PAL system transforms the RGB three-color signals into a YUV signal, where the Y signal represents brightness, and the U and V signals represent color difference.

9.2.7YCbCr model (just understand)

It is composed of brightness Y, color difference Cb, and color difference Cr. Different from the YUV model, the different importance of the three components of R, G, and B in visual perception is fully considered when constructing the color difference signal.

9.3 Pseudo-color processing

Pseudo-color processing is also called false-color processing
(1) Definition
refers to the conversion of a grayscale image into a color image, or a monochrome image into an image with a given color distribution.

(2) Purpose
In order to improve the human eye's ability to distinguish the details of the image to achieve the purpose of image enhancement.

(3) Basic principles
Match each gray level of a gray image or a monochrome image to a point in the color space, so that the monochrome image is mapped into a color image.

Although pseudo-color processing can convert grayscale to color, this color is not really the original color of the image, but only a pseudo-color that is easy to identify.

(4) Methods The
pseudo-color processing methods mainly include intensity stratification and gray-scale to color conversion.

9.3.1 Strength stratification

Code

I=imread('i_peppers_gray.bmp'); 

GS8=grayslice(I,8);%将原图的灰度分成8层
GS64=grayslice(I,64); %分成64subplot(1,3,1), imshow(I), title('原始灰度图像');
subplot(1,3,2), subimage(GS8,hot(8)), title('分成8层伪彩色');
subplot(1,3,3), subimage(GS64,hot(64)), title('分成64层伪彩色');	

Insert picture description here

9.3.2 Grayscale to color conversion

256 gray levels, output R, G, B in proportion in segments, and transform into color
Insert picture description here
Insert picture description here

9.4 Full-color image processing

Full-color image processing research is divided into two categories.
①The first category: process each component image separately, and then form a composite color image from the separately processed component images.

②The second category: directly process color pixels

9.4.1 Basics of Full Color Image Processing

Because a full-color image has at least 3 components, a color pixel is actually a vector.

In order to make each color component processing and vector-based processing equivalent, two conditions must be met:
first, the processing must be available to both vectors and scalars, and
second, the operations on each component of the vector must be independent of other components.

9.4.2 Color image histogram processing

Uniformly expand the color intensity, and keep the color itself (that is, hue and saturation) unchanged, that is, use the HSI model. Histogram equalization is performed on I (intensity).
(Ps: HSI model application)
Insert picture description here

9.4.3 Color image smoothing

RGB 3 component smoothing filter or HSI I component smoothing filter

Use spatial filtering method-neighborhood average to smooth and filter color images.

其主要Matlab程序实现如下:
    rgb=imread('flower608.jpg');
    fR=rgb(:,:,1);
    fG=rgb(:,:,2);
    fB=rgb(:,:,3);
    w=fspecial('average');%算子
    fR_filtered=imfilter(fR,w);
    fG_filtered=imfilter(fG,w);
    fB_filtered=imfilter(fB,w);
    rgb_filtered=cat(3,fR_filtered,fG_filtered,fB_filtered);

Insert picture description here

9.4.4 Color image sharpening

The main purpose of sharpening is to highlight the details (edges) of the image.

使用经典的Laplacian滤波模板分别对每个分量图像进行锐化。
其主要Matlab程序实现如下:
    rgb=imread('flower608.jpg');
    fR=rgb(:,:,1);
    fG=rgb(:,:,2);
    fB=rgb(:,:,3);
    lapMatrix=[1 1 1;1 -8 1;1 1 1];%锐化的算各元素和为0
    fR_tmp=imfilter(fR,lapMatrix,'replicate');
    fG_tmp=imfilter(fG,lapMatrix,'replicate');
    fB_tmp=imfilter(fB,lapMatrix,'replicate');
    rgb_tmp=cat(3,fR_tmp,fG_tmp,fB_tmp);
    rgb_sharped=imsubtract(rgb,rgb_tmp);

Insert picture description here

9.5 Color image segmentation

Image segmentation is the technique and process of dividing an image into regions with characteristics and extracting objects of interest.
Insert picture description here

9.5.1 HSI color space segmentation

Insert picture description here
Chroma is used to describe colors in images .

At saturation as a template image, from the tone image separating the interest feature area .

Since intensity does not carry color information, color image segmentation generally does not use intensity images.
Insert picture description here
Insert picture description here
Use saturation as a template image: select a threshold value equal to 30% of the maximum saturation in the saturation image, assign 1 (white) to any pixel value larger than the threshold, and assign 0 (black) to others.

Separate the feature area of ​​interest from the hue image: use the saturation binary template to act on the hue image to produce the result of red flower segmentation.

其主要Matlab程序如下:
S1=(S>0.3*(max(max(S))));%S>最大饱和度的30%max(max(s))是因为s是二维的max一次是行一次是列
F=S1.*H;

Insert picture description here

9.5.2 RGB color space segmentation

Although the color image in HSI space is more intuitive.
RGB color vector is usually used for segmentation

The goal of segmentation is to classify each RGB pixel in a given image. This requires a similarity measure.

Let z represent any point in the RGB space, if the distance between them is less than a certain threshold D 0 , we say that z and a are similar.
One of the simplest measures is the Euclidean distance

9.5.3 Color edge detection (just understand)

Edge detection is an important tool for image segmentation.
Comparison:
(1) Calculate the edge based on each individual color component image
(2) Calculate the edge directly in the color space.

Compare two kinds of color image edge detection:
(1) detect the edge by the mixture of the gradient of each color component image
(2) detect the edge with the vector gradient of the color space.

9.6 Other applications of color image processing

9.6.1 Red eye removal

(1) Causes of red eye (emphasis)

When shooting portraits with a camera, red eyes may sometimes appear. Because when shooting in a low-light environment, the flash of the flash will make the pupils of the human eye instantaneously dilate, and the blood vessels on the retina are reflected on the film, resulting in red-eye phenomenon.

(2) Processing The
commonly used color models for red-eye removal technology are: RGB model, CIE Lab model, and HSI model. Common HSI models

9.6.2 Skin color detection

Commonly used YCbCr

Guess you like

Origin blog.csdn.net/weixin_44575911/article/details/112711365