Image gray scale transformation 2


For beginners in image processing, please correct it if there is any incorrect writing

Binarization and threshold processing

The image after threshold processing becomes a black and white binary image.
Insert picture description here

g ( x , y ) = { 0 f ( x , y ) ≤ T 255 f ( x , y ) > T (0) g(x,y)= \begin{cases} 0&&&&f(x,y)\leq T \\\\ 255&&&&f(x,y)>T \end{cases}\tag{0} g(x,and )=0255f(x,and )Tf(x,and )>T( 0 )
Effect comparison chart
Insert picture description here

Double fixed threshold method

Insert picture description here
g ( x , y ) = { 0 f ( x , y ) ≤ T 1 或 者 f ( x , y ) ≥ T 2 255 T 1 < f ( x , y ) < T 2 (1) g(x,y)= \begin{cases} 0&&&&f(x,y)\leq T_1 或者 f(x,y)\geq T_2 \\\\ 255&&&&T_1<f(x,y)<T_2 \end{cases}\tag{1} g(x,and )=0255f(x,and )T1Or by F ( X ,and )T2T1<f(x,and )<T2(1)
g ( x , y ) = { 255 f ( x , y ) ≤ T 1 或 者 f ( x , y ) ≥ T 2 0 T 1 < f ( x , y ) < T 2 (2) g(x,y)= \begin{cases} 255&&&&f(x,y)\leq T_1 或者 f(x,y)\geq T_2 \\\\ 0&&&&T_1<f(x,y)<T_2 \end{cases}\tag{2} g(x,and )=2550f(x,and )T1Or by F ( X ,and )T2T1<f(x,and )<T2( 2 )
Effect comparison chart
Insert picture description here

Grayscale histogram

Indicates the number of pixels with a certain gray level in the image, reflecting the frequency of each gray level in the image. It is the most basic statistical feature of an image.
Abscissa: Gray level;
Y-axis: The number of occurrences of this gray level.
The histogram of the image contains rich image information, describes the gray-level content of the image, and reflects the gray-level distribution of the image. Image histogram is a very important image analysis tool in image processing, with simple and applicable characteristics. It is mainly used in image segmentation, image gray scale transformation and other processing processes. By counting the gray value of the image, a one-dimensional discrete image gray level statistical histogram function can be obtained.
Mathematically speaking, it counts the number or probability of each gray level in an image;
graphically speaking, it is a two-dimensional graph, the abscissa represents the gray level of each pixel in the image, and the ordinate is each The number or probability of occurrence of image pixels on the gray scale.

Many general characteristics of the image can be seen from the histogram. In the histogram shown in Figure (a), since most of its grayscale is concentrated in the dark area, it presents a rather dark image. In the histogram shown in Figure (b), since most of its pixels have high gray values, the whole picture is very bright. Therefore, the gray histogram describes the general picture of an image, is a means to study the gray distribution of an image, and is a very useful tool in digital image processing. The abscissa of the histogram is gray, use rrr means; the ordinate is the number of gray value pixels, usingP r (r) P_r(r)Pr( r ) means. The ordinate of the histogram can also use the image gray probability density functionP r (r) P_r(r)Pr( r ) means that it is equivalent to havingrrr The ratio of the number of pixels in grayscale to the total number of pixels in the image. For example, the total number of pixels in the image is n, and the number of pixels with r grayscale is n, then the image probability density function

P r ( r ) = ( n r n ) (3) P_r(r)= \left(\frac{n_r}{n} \right)\tag{3} Pr(r)=(nnr)(3)

The application range of gray histogram is very wide, and it provides a powerful auxiliary tool for image processing research. It can be judged by the display of histogram whether an image reasonably utilizes all the allowable gray scale ranges, the gray scale distribution of the image can be understood through the histogram, and the gray density of the image can be modified to selectively highlight the needs. The image features to meet people’s requirements.

Example:
Insert picture description here
Insert picture description here
You can see the gray distribution characteristics of an image from the gray level distribution of the image. (a) Darker; (b) Brighter.

Histogram properties

1) It only reflects the number of times (or frequency) of different gray values ​​in the image, but does not reflect the location of a certain gray value pixel. The location information is missing.
2) There is a many-to-one mapping relationship between the image and the histogram.
3) Since the histogram is obtained by counting the pixels with the same gray value, the sum of the histogram of each sub-area of ​​an image is equal to the histogram of the entire image of the image.

Guess you like

Origin blog.csdn.net/weixin_41045657/article/details/113532993