CN106127817A - A kind of image binaryzation method based on passage - Google Patents
A kind of image binaryzation method based on passage Download PDFInfo
- Publication number
- CN106127817A CN106127817A CN201610504100.7A CN201610504100A CN106127817A CN 106127817 A CN106127817 A CN 106127817A CN 201610504100 A CN201610504100 A CN 201610504100A CN 106127817 A CN106127817 A CN 106127817A
- Authority
- CN
- China
- Prior art keywords
- row
- pixel
- channel
- image
- value
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Granted
Links
- 238000000034 method Methods 0.000 title claims abstract description 35
- 238000012545 processing Methods 0.000 claims abstract description 34
- 239000011159 matrix material Substances 0.000 claims abstract description 14
- 238000006243 chemical reaction Methods 0.000 claims 3
- 238000005286 illumination Methods 0.000 abstract description 5
- 238000005516 engineering process Methods 0.000 description 9
- 238000002474 experimental method Methods 0.000 description 5
- 238000000605 extraction Methods 0.000 description 4
- 230000000694 effects Effects 0.000 description 3
- 230000009286 beneficial effect Effects 0.000 description 2
- 238000004364 calculation method Methods 0.000 description 2
- 238000012986 modification Methods 0.000 description 2
- 230000004048 modification Effects 0.000 description 2
- 238000007781 pre-processing Methods 0.000 description 2
- 238000003672 processing method Methods 0.000 description 2
- 238000011160 research Methods 0.000 description 2
- 230000003044 adaptive effect Effects 0.000 description 1
- 238000013473 artificial intelligence Methods 0.000 description 1
- 210000004556 brain Anatomy 0.000 description 1
- 230000007423 decrease Effects 0.000 description 1
- 230000007812 deficiency Effects 0.000 description 1
- 238000011161 development Methods 0.000 description 1
- 238000011156 evaluation Methods 0.000 description 1
- 238000001914 filtration Methods 0.000 description 1
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06V—IMAGE OR VIDEO RECOGNITION OR UNDERSTANDING
- G06V10/00—Arrangements for image or video recognition or understanding
- G06V10/20—Image preprocessing
- G06V10/28—Quantising the image, e.g. histogram thresholding for discrimination between background and foreground patterns
Landscapes
- Engineering & Computer Science (AREA)
- Physics & Mathematics (AREA)
- General Physics & Mathematics (AREA)
- Multimedia (AREA)
- Theoretical Computer Science (AREA)
- Facsimile Image Signal Circuits (AREA)
- Image Processing (AREA)
Abstract
本发明公开了一种基于通道的图像二值化方法,包括步骤:对于需要进行二值化处理的图像,将图像视为一个像素矩阵I,图像的宽度记为w,高度记为h;逐行对像素矩阵I进行处理,每次扫描一行的像素点,处理第i行时收集统计像素点I[i][j]的红、蓝、绿三个通道值以及灰度值的信息,并计算第i行像素点中这四个量的平均值;将第i行像素点的各个通道根据对应通道的平均值和阈值对第i行各通道像素值进行统计并进行二值化处理;若i<h‑1,i=i+1;则重复步骤S2‑S3,对下一行像素点进行基于通道的二值化处理。与现有技术相比,本发明可以对光照不均的图像进行快速且准确地二值化处理。
The invention discloses a channel-based image binarization method, comprising steps: for an image that needs to be binarized, the image is regarded as a pixel matrix I, the width of the image is recorded as w, and the height is recorded as h; Each row processes the pixel matrix I, scans the pixels of one row each time, and collects the red, blue and green channel values and gray value information of the statistical pixel I[i][j] when processing the i-th row, and Calculate the average value of these four quantities in the i-th row of pixels; count the pixel values of each channel in the i-th row according to the average value and threshold of the corresponding channel for each channel of the i-th row of pixels; if i<h-1, i=i+1; then repeat step S2-S3 to perform channel-based binarization processing on the next row of pixels. Compared with the prior art, the invention can quickly and accurately binarize images with uneven illumination.
Description
技术领域technical field
本发明涉及数字图像处理技术领域,尤其涉及一种基于通道的图像二值化方法。The invention relates to the technical field of digital image processing, in particular to a channel-based image binarization method.
背景技术Background technique
自20世纪40年代计算机的问世和人工智能技术的提出,计算机就被寄望来替代人类的脑力活动工作,其中图像图形处理在计算机中不断被实践与研究,人们希望计算机能够自动处理图像,最后把处理的结果呈现在人们眼前。从20世纪20年代OCR技术被提出到如今,OCR技术已经达到较高的水平,同时也出现了一批OCR产品,其中最为广泛的为图像车牌识别,即对车牌号码进行拍照取像,再通过图像处理技术进行车牌号码提取。可见图像处理技术在计算机领域中占有一定的地位。在图像处理技术中,图像二值化处理是图像预处理中重要的一步,二值化处理的质量直接决定着后续步骤的难度和准确性。Since the advent of computers and the introduction of artificial intelligence technology in the 1940s, computers have been expected to replace human brain work. Among them, image and graphics processing has been practiced and researched in computers. People hope that computers can automatically process images, and finally Present the results of the processing in front of people. Since the OCR technology was proposed in the 1920s to the present, OCR technology has reached a relatively high level, and a number of OCR products have also appeared, the most extensive of which is image license plate recognition, that is, to take pictures of the license plate number, and then pass Image processing technology for license plate number extraction. It can be seen that image processing technology occupies a certain position in the computer field. In image processing technology, image binarization is an important step in image preprocessing, and the quality of binarization directly determines the difficulty and accuracy of subsequent steps.
虽然目前OCR技术研究已经颇有成效,但还是处于发展阶段,对图像的预处理等技术还需要继续研究与实践。一种好的图像二值化处理方法可以大大提高图像中的字符特征提取与识别的效率和准确度。自IBM公司在20世纪60年代提出汉字识别的方案之后,汉字识别开始被研究。在汉字识别中,需要提取汉字的各个有效特征,并与特征库中的汉字进行匹配。在OCR技术中,由于彩色图像的信息量较大,且在特征提取操作中,需要的是字符本身的结构特征,因此对图像进行二值化处理有利于减少后续操作的复杂性。二值化图像处理是对输入的彩色图像的像素值进行分析,根据特定算法得到的阈值来划分前景和背景。二值化处理将图像的文字区域即前景部分设为黑色,将背景设为白色,突出文字区域,大大方便了特征提取及字符识别的进行。Although the current OCR technology research has been quite effective, it is still in the development stage, and technologies such as image preprocessing still need to continue research and practice. A good image binarization processing method can greatly improve the efficiency and accuracy of character feature extraction and recognition in images. Since IBM proposed the Chinese character recognition scheme in the 1960s, Chinese character recognition has been studied. In Chinese character recognition, each effective feature of Chinese characters needs to be extracted and matched with the Chinese characters in the feature library. In OCR technology, since the color image has a large amount of information, and in the feature extraction operation, the structural features of the character itself are needed, so binarizing the image is beneficial to reduce the complexity of subsequent operations. Binarization image processing is to analyze the pixel value of the input color image, and divide the foreground and background according to the threshold value obtained by a specific algorithm. The binarization process sets the text area of the image, that is, the foreground part, to black, and sets the background to white to highlight the text area, which greatly facilitates feature extraction and character recognition.
二值化处理方法其中主要分为两类:全局处理与局部处理。全局处理即对整个图像采取一个阈值进行评判,计算得出阈值后该阈值将保持不变直到图像处理完成。其中有Kittler算法和基于直方图的全局阈值算法等。局部处理即动态的阈值评判,将图像分为大致均等的若干部分,每一次进行计算得出当前部分的阈值,然后进行二值化处理,直到整个图像处理完成。其中有Wall算法和Wellner自适应滤波阈值算法。在图像处理中,影响图像处理质量因素有很多。不同的二值化算法适用的情况也不尽相同。尽管上述算法能解决大部分问题,但是随着图像的复杂度的提高,处理得出的结果还是多少让人不满意,特别是图像光照不均匀情况下,处理后的出的结果图像模糊或主要部分没有被突显出来等。在文字识别的图像处理中,图像质量的优秀与否直接影响到处理的质量以及识别率。而大部分拍摄图片的时候不能保证很好的图像质量,最常见的就是光照不均匀的情况。Binarization processing methods are mainly divided into two categories: global processing and local processing. In global processing, a threshold is used to judge the entire image. After the threshold is calculated, the threshold will remain unchanged until the image processing is completed. Among them are the Kittler algorithm and the histogram-based global threshold algorithm. Partial processing is dynamic threshold evaluation, which divides the image into roughly equal parts, calculates the threshold value of the current part each time, and then performs binarization processing until the entire image processing is completed. Among them are the Wall algorithm and the Wellner adaptive filtering threshold algorithm. In image processing, there are many factors that affect the quality of image processing. Different binarization algorithms are suitable for different situations. Although the above algorithm can solve most of the problems, as the complexity of the image increases, the processing results are still somewhat unsatisfactory, especially in the case of uneven illumination of the image, the resulting image after processing is blurred or mainly Parts are not highlighted etc. In the image processing of character recognition, the quality of the image directly affects the processing quality and recognition rate. Most of the time when taking pictures, we can't guarantee good image quality, the most common one is uneven lighting.
发明内容Contents of the invention
为克服现有技术的不足,解决因光照不均匀而造成二值化效果不佳的图像处理问题,本发明提出一种基于通道的图像二值化方法。In order to overcome the deficiencies of the prior art and solve the image processing problem of poor binarization effect due to uneven illumination, the present invention proposes a channel-based image binarization method.
本发明的技术方案是这样的:一种基于通道的图像二值化方法,包括以下步骤:The technical scheme of the present invention is such: a kind of channel-based image binarization method comprises the following steps:
S1:对于需要进行二值化处理的图像,将图像视为一个像素矩阵I,图像的宽度记为w,高度记为h;S1: For an image that needs to be binarized, the image is regarded as a pixel matrix I, the width of the image is recorded as w, and the height is recorded as h;
S2:逐行对像素矩阵I进行处理,每次扫描一行的像素点,处理第i行时收集统计像素点I[i][j]的红、蓝、绿三个通道值以及灰度值的信息,分别记为Rij、Gij、Bij和GREYij,其中GREYij是灰度值,GREYij=(Rij+Gij+Bij)/3,并计算第i行像素点中这四个量的平均值,即:S2: Process the pixel matrix I line by line, scan the pixels of one line at a time, and collect the red, blue, green channel values and gray value of the statistical pixel point I[i][j] when processing the i-th line Information, respectively recorded as R ij , G ij , B ij and GREY ij , where GREY ij is the gray value, GREY ij = (R ij +G ij +B ij )/3, and calculate this The average of the four quantities, namely:
redAvgi=(∑0≤j<wRij)/w,redAvg i = (∑ 0≤j <w R ij )/w,
greenAvgi=(∑0≤j<wGij)/w,greenAvg i = (∑ 0≤j <w G ij )/w,
blueAvgi=(∑0≤j<wBij)/w,blueAvg i = (∑ 0≤j <w Bij)/w,
greyAvgi=(∑0≤j<wGREYij)/w;greyAvg i = (∑ 0≤j <w GREY ij )/w;
S3:将第i行像素点的各个通道根据对应通道的平均值和阈值对第i行各通道像素值进行统计并进行二值化处理:S3: Count the pixel values of each channel in the i-th row according to the average value and threshold of the corresponding channel for each channel of the pixel point in the i-th row and perform binarization processing:
S31:将像素点的红色、绿色、蓝色各通道值总和以及灰度值总和分别记为redSumi,greenSumi,blueSumi,greySumi;符合要求的红色、绿色、蓝色、灰度值的像素点个数分别记为redCounti,greenCounti,blueCounti,greyCounti;将其全部初始化为0;S31: record the sum of the red, green and blue channel values and the sum of the gray value of the pixel as redSum i , greenSum i , blueSum i , greySum i respectively; The number of pixels is respectively recorded as redCount i , greenCount i , blueCount i , grayCount i ; all of them are initialized to 0;
S32:对红色通道Ri进行处理,采用redAvgi+α作为分界值,遍历第i行像素点,若Rij<redAvgi+α,则认为I[i][j]为红色像素点,将红色通道值累加到总和redSumi,将redCounti加1;采用相同的方法对Gi、Bi和GREYi进行处理,得到greenSumi、greenCounti、blueSumi、blueCounti、greySumi、,greyCounti,其中α是图像标准方差的十分之一;S32: Process the red channel R i , use redAvg i + α as the boundary value, traverse the i-th row of pixels, if R ij <redAvg i + α, then consider I[i][j] to be a red pixel, and set Add the red channel value to the sum redSum i , add 1 to redCount i ; use the same method to process G i , B i and GREY i to get greenSum i , greenCount i , blueSum i , blueCount i , graySum i , grayCount i , where α is one-tenth of the standard deviation of the image;
S33:若redCounti为0,将第i行像素点全设为白色;若redCounti不为0,使redAvgi等于所有红色像素点的平均值,即redAvgi=redSumi/redCounti;遍历整行像素点,若Rij<redAvgi+β,则设置I[i][j]为黑色;其中β为图像标准方差的十分之一;S33: If redCount i is 0, set the i-th row of pixels as white; if redCount i is not 0, make redAvg i equal to the average value of all red pixels, i.e. redAvg i =redSum i /redCount i ; traverse the entire row pixels, if R ij <redAvg i +β, then set I[i][j] to black; where β is one-tenth of the standard deviation of the image;
S34:将红色通道Ri分别替换为Gij、Bij、GREYij通道信息,重复步骤S32-S33,修正二值化结果,与红色通道不同的是,只将原先白色像素值修正为黑色;S34: replace the red channel R i with G ij , B ij , and GREY ij channel information respectively, repeat steps S32-S33, and correct the binarization result. Unlike the red channel, only the original white pixel value is corrected to black;
S4:若i<h-1,i=i+1;则重复步骤S2-S3,对下一行像素点进行基于通道的二值化处理。S4: If i<h-1, i=i+1; repeat steps S2-S3, and perform channel-based binarization processing on the next row of pixels.
进一步地,步骤S2为从上到下逐行对所述像素矩阵进行扫描。Further, step S2 is to scan the pixel matrix line by line from top to bottom.
进一步地,步骤S32为从左到右对第i行像素点进行遍历。Further, step S32 is to traverse the i-th row of pixels from left to right.
本发明的有益效果在于,与现有技术相比,本发明可以对光照不均的图像进行快速且准确地二值化处理。The beneficial effect of the present invention is that, compared with the prior art, the present invention can quickly and accurately binarize images with uneven illumination.
附图说明Description of drawings
图1是本发明基于通道的图像二值化方法流程图。FIG. 1 is a flowchart of the channel-based image binarization method of the present invention.
图2是图1中的步骤S3详细步骤流程图。FIG. 2 is a detailed flow chart of step S3 in FIG. 1 .
图3是未二值化前的小票图片。Figure 3 is the receipt image before binarization.
图4是图3中的小票图片经过本发明的方法处理后的二值化结果。Fig. 4 is the binarization result of the receipt picture in Fig. 3 after being processed by the method of the present invention.
具体实施方式detailed description
下面将结合本发明实施例中的附图,对本发明实施例中的技术方案进行清楚、完整地描述,显然,所描述的实施例仅仅是本发明一部分实施例,而不是全部的实施例。基于本发明中的实施例,本领域普通技术人员在没有作出创造性劳动前提下所获得的所有其他实施例,都属于本发明保护的范围。The following will clearly and completely describe the technical solutions in the embodiments of the present invention with reference to the accompanying drawings in the embodiments of the present invention. Obviously, the described embodiments are only some, not all, embodiments of the present invention. Based on the embodiments of the present invention, all other embodiments obtained by persons of ordinary skill in the art without creative efforts fall within the protection scope of the present invention.
请参见图1和图2,本发明一种基于通道的图像二值化方法,包括以下步骤:Referring to Fig. 1 and Fig. 2, a kind of channel-based image binarization method of the present invention comprises the following steps:
对于需要进行二值化处理的图像,将图像视为一个像素矩阵I,图像的宽度记为w,高度记为h。每个像素点即矩阵中每个元素I[i][j],其中i∈[0,h),j∈[0,w),均包含r、g、b三个通道的信息。For an image that needs to be binarized, the image is regarded as a pixel matrix I, the width of the image is recorded as w, and the height is recorded as h. Each pixel, that is, each element I[i][j] in the matrix, where i∈[0,h), j∈[0,w), contains the information of the three channels of r, g, and b.
从上到下逐行对像素矩阵I进行处理,每次扫描一行的像素点。处理第i行时(i∈[0,h)),收集统计I[i][j]的红、蓝、绿三个通道值以及灰度值的信息,分别记为Rij、Gij、Bij和GREYij,其中GREYij是灰度值,这里采用GREYij=(Rij+Gij+Bij)/3,计算第i行像素点中这四个量的平均值,即:The pixel matrix I is processed row by row from top to bottom, scanning one row of pixels each time. When processing the i-th row (i∈[0,h)), collect statistics on the red, blue and green channel values and gray value information of I[i][j], which are recorded as R ij , G ij , B ij and GREY ij , where GREY ij is the gray value, here adopt GREY ij =(R ij +G ij +B ij )/3 to calculate the average value of these four quantities in the i-th row of pixels, namely:
redAvgi=(∑0≤j<wRij)/w,redAvg i = (∑ 0≤j <w R ij )/w,
greenAvgi=(∑0≤j<wGij)/w,greenAvg i = (∑ 0≤j <w G ij )/w,
blueAvgi=(∑0≤j<wBij)/w,blueAvg i = (∑ 0≤j <w Bij)/w,
greyAvgi=(∑0≤j<wGREYij)/w。greyAvg i =(∑ 0 ≦j<w GREY ij )/w.
将第i行像素点的各个通道根据对应通道的平均值和阈值对第i行各通道像素值进行处理并统计:Process and count the pixel values of each channel in the i-th row according to the average value and threshold of the corresponding channel for each channel of the i-th row of pixels:
将像素点的红色、绿色、蓝色各通道值总和以及灰度值总和分别记为redSumi,greenSumi,blueSumi,greySumi;符合要求的红色、绿色、蓝色、灰度值的像素点个数分别记为redCounti,greenCounti,blueCounti,greyCounti;将其全部初始化为0。Record the sum of the red, green, and blue channel values and the sum of the gray value of the pixel as redSum i , greenSum i , blueSum i , and greySum i ; pixels with red, green, blue, and gray values that meet the requirements The numbers are respectively recorded as redCount i , greenCount i , blueCount i , grayCount i ; all of them are initialized to 0.
对红色通道Ri进行处理,采用redAvgi+α作为分界值,从左到右遍历第i行像素点,若Rij<redAvgi+α,则认为I[i][j]为红色像素点,将红色通道值累加到总和redSumi,将redCounti加1;采用相同的方法对Gi、Bi和GREYi进行处理,得到greenSumi、greenCounti、blueSumi、blueCounti、greySumi、greyCounti,其中α是实验得出的分界效果最佳的值,一般取为图像标准方差的十分之一。Process the red channel R i , use redAvg i + α as the boundary value, traverse the i-th row of pixels from left to right, if R ij <redAvg i + α, then consider I[i][j] to be a red pixel , add the red channel value to the sum redSum i , add 1 to redCount i ; use the same method to process G i , B i and GREY i to get greenSum i , greenCount i , blueSum i , blueCount i , graySum i , grayCount i , where α is the value with the best demarcation effect obtained from experiments, which is generally taken as one-tenth of the standard deviation of the image.
根据上述步骤的计算结果修正I[i][j]的二值化结果:Correct the binarization result of I[i][j] according to the calculation results of the above steps:
若redCounti为0,将第i行像素全设为白色(255);若redCounti不为0,使redAvgi等于所有红色像素点的平均值,即redAvgi=redSumi/redCounti;遍历整行像素,若Rij<redAvgi+β,则设置I[i][j]为黑色(0);其中β是实验得出调节效果最佳的值,一般地,β为图像标准方差的十分之一。If redCount i is 0, all the i-th row pixels are set to white (255); if redCount i is not 0, make redAvg i equal to the average value of all red pixels, i.e. redAvg i =redSum i /redCount i ; traverse the entire If R ij <redAvg i +β, then set I[i][j] to be black (0); where β is the value with the best adjustment effect obtained from the experiment, generally, β is ten times the standard deviation of the image one-third.
然后根据Gij、Bij、GREYij通道信息继续修正二值化结果,与r通道不同的是,只将原先白色像素点修正为黑色。Then continue to modify the binarization results according to the G ij , B ij , and GREY ij channel information. Unlike the r channel, only the original white pixels are corrected to black.
若i<h-1,i=i+1;则继续对下一行像素点进行基于通道的二值化处理。If i<h-1, i=i+1; continue to perform channel-based binarization on the next row of pixels.
下面将以超市小票图像为例,对本发明流程进行进一步阐述。In the following, the process of the present invention will be further elaborated by taking the supermarket receipt image as an example.
图3是未经处理的打印(光照)不均匀的超市小票,可以看出小票图像明暗程度不均,随着位置往下,其亮度也逐渐减小。实验获得处理红色通道的实验值α取值为-20,处理绿色通道的实验值α取值为-25,处理蓝色通道的实验值α取值为-23,处理灰度值的实验值α取值为-20。调节设置黑白像素值的实验值β取值情况分别为,调节红色通道实验值β取值为18,调节绿色通道实验值β取值为9,调节蓝色通道实验值β取值为8,调节灰度实验值β取值为8。Figure 3 is an unprocessed supermarket receipt with uneven printing (illumination). It can be seen that the image of the receipt is uneven in brightness, and its brightness gradually decreases as the position goes down. The experimental value α for processing the red channel is -20, the experimental value α for the green channel is -25, the experimental value α for the blue channel is -23, and the experimental value α for the gray value is obtained from the experiment. The value is -20. Adjust and set the experimental value β of the black and white pixel values as follows: adjust the experimental value β of the red channel to 18, adjust the experimental value β of the green channel to 9, adjust the experimental value β of the blue channel to 8, adjust The grayscale experimental value β is set to 8.
步骤二,将图3视为一个像素矩阵I,图像的宽度记为w=350,高度记为h=500。每个像素点即矩阵中每个元素I[i][j],其中i∈[0,500),j∈[0,350),均包含r、g、b三个通道的信息。Step 2, consider Fig. 3 as a pixel matrix I, the width of the image is recorded as w=350, and the height is recorded as h=500. Each pixel, that is, each element I[i][j] in the matrix, where i∈[0,500), j∈[0,350), contains the information of the three channels of r, g, and b.
步骤三,从0到500逐行对像素矩阵I进行处理,每次扫描一行的像素点。处理第i行时(i∈[0,500)),收集统计I[i][j]的红、蓝、绿三个通道以及灰度值的信息,分别记为Rij、Gij、Bij和GREYij(注:GREYij是灰度值,这里采用GREYij=(Rij+Gij+Bij)/3),计算第i行像素点中这四个量的平均值,即:Step 3, process the pixel matrix I line by line from 0 to 500, and scan the pixels of one line at a time. When processing the i-th row (i∈[0,500)), collect statistics on the red, blue and green channels of I[i][j] and the gray value information, which are recorded as R ij , G ij , B ij and GREY ij (Note: GREY ij is the gray value, here adopt GREY ij = (R ij +G ij +B ij )/3), calculate the average value of these four quantities in the i-th row of pixels, namely:
redAvgi=(∑0≤j<350Rij)/350,redAvg i = (∑ 0≤j <350 R ij )/350,
greenAvgi=(∑0≤j<350Gij)/350,greenAvg i = (∑ 0≤j <350 G ij )/350,
blueAvgi=(∑0≤j<350Bij)/350,blueAvg i = (∑ 0≤j <350 B ij )/350,
greyAvgi=(∑0≤j<350GREYij)/350。greyAvg i =(∑ 0 ≦j<350 GREY ij )/350.
将第i行像素的各个通道根据对应通道的平均值和阈值对第i行各通道像素值进行处理并统计:Each channel of the i-th row of pixels is processed and counted according to the average value and threshold value of the corresponding channel:
1)将像素点的红色、绿色、蓝色各通道值总和以及灰度值总和分别记为redSumi,greenSumi,blueSumi,greySumi;符合要求的红色、绿色、蓝色、灰度值的像素点个数分别记为redCounti,greenCounti,blueCounti,greyCounti;将其全部初始化为0。1) Record the sum of the red, green, and blue channel values and the sum of the gray value of the pixel as redSum i , greenSum i , blueSum i , and greySum i respectively; red, green, blue, and gray values that meet the requirements The number of pixels is respectively recorded as redCount i , greenCount i , blueCount i , grayCount i ; all of them are initialized to 0.
2)对红色通道Ri进行处理,采用redAvgi–20作为分界值,从左到右遍历第i行像素,若Rij<redAvgi–20,则认为I[i][j]为红色像素点,将红色通道值累加到总和redSumi,将redCounti加1;采用相同的方法对Gi、Bi和GREYi进行处理,得到greenSumi、greenCounti、blueSumi、blueCounti、greySumi、,greyCounti。2) Process the red channel R i , use redAvg i -20 as the boundary value, traverse the i-th row of pixels from left to right, if R ij <redAvg i -20, then consider I[i][j] to be a red pixel point, add the red channel value to the sum redSum i , and add 1 to redCount i ; use the same method to process G i , B i and GREY i to get greenSum i , greenCount i , blueSum i , blueCount i , graySum i , , greyCount i .
例如i=200时,统计第200行时实验得出几个平均值的量为redAvg200=138,greenAvg200=168,blueAvg200=148,greyAvg200=151。For example, when i=200, when counting the 200th row, the experimentally obtained several average values are redAvg 200 =138, greenAvg 200 =168, blueAvg 200 =148, and grayAvg 200 =151.
接下来收集统计第200行中红色、绿色、蓝色和灰度等各类像素点,即分别为符合条件:R200,j<138–20、G200,j<168–25、B200,j<148–23、GREY200,j<151–20的点,并且计算各类像素点对应的总和sum和个数count。实验得出,当i=200时,redSum200=6343,redCount200=77,greenSum200=7757,greenCount200=72,blueSum200=6763,blueCount200=74,greySum200=7286,greyCount200=77。Next, collect and count various pixel points such as red, green, blue, and gray in the 200th line, that is, they meet the conditions: R 200, j <138–20, G 200, j <168–25, B 200, j <148–23, GREY 200, j <151–20, and calculate the sum and count of each type of pixel. Experiments show that when i=200, redSum 200 =6343, redCount 200 =77, greenSum 200 =7757, greenCount 200 =72, blueSum 200 =6763, blueCount 200 =74, graySum 200 =7286, grayCount 200 =77.
步骤四,根据步骤三的计算结果修正I[i][j]的二值化结果:Step 4, correct the binarization result of I[i][j] according to the calculation result of step 3:
1)若redCounti为0,将第i行像素全设为白色(255);若redCounti不为0,使redAvgi等于所有红色像素点的平均值,即redAvgi=redSumi/redCounti;遍历整行像素,若Rij<redAvgi+β,则设置I[i][j]为黑色(0);1) If redCount i is 0, set the i-th row of pixels as white (255); if redCount i is not 0, make redAvgi equal to the average value of all red pixels, that is, redAvg i = redSum i /redCount i ; traverse The entire row of pixels, if R ij <redAvg i +β, then set I[i][j] to black (0);
2)根据Gij、Bij、GREYij通道信息继续修正二值化结果,与r通道不同的是,只将原先白色像素值修正为黑色。2) Continue to modify the binarization result according to the G ij , B ij , and GREY ij channel information. Unlike the r channel, only the original white pixel value is corrected to black.
例如i=200时,由步骤三得出的像素统计数据可以对第200行的像素点进行二值化,即设置像素值为黑(0)或者白(255)。For example, when i=200, the pixel statistical data obtained in step 3 can be used to binarize the pixel points in the 200th row, that is, set the pixel value to black (0) or white (255).
实验得出红色像素平均值redAvg200=82,绿色像素平均值greenAvg200=107,蓝色像素平均值blueAvg200=91,灰度像素平均值greyAvg200=94。Experiments show that the average value of red pixels redAvg 200 =82, the average value of green pixels greenAvg 200 =107, the average value of blue pixels blueAvg 200 =91, and the average value of gray pixels greyAvg 200 =94.
由红色通道信息,将R200,j<82+18的像素点认为是前景,设置其像素为黑色,否则设置为白色;According to the red channel information, consider the pixel point of R 200,j <82+18 as the foreground, set its pixel to black, otherwise set it to white;
根据绿色、蓝色、灰度值等信息,对第200行像素进行三次修正。将分别满足G200,j<107+9、B200,j<91+8、G200,j<94+8的白色像素点设置为黑色,逐渐修正第一次二值化的误差。According to the green, blue, gray value and other information, the pixels in the 200th row are corrected three times. Set the white pixels that satisfy G 200, j <107+9, B 200, j <91+8, G 200, j <94+8 to black, and gradually correct the error of the first binarization.
步骤五,若i<499,i=i+1;返回步骤2,对下一行像素点进行基于通道的二值化处理。比如i=200时,则需返回步骤2进行下一行的二值化处理;若i=499,则说明整个图像二值化处理完毕。图像4经二值化处理后的图像如图4所示。Step 5, if i<499, i=i+1; return to step 2, and perform channel-based binarization processing on the next row of pixels. For example, when i=200, it is necessary to return to step 2 for the binarization processing of the next line; if i=499, it means that the binarization processing of the entire image is completed. The image of image 4 after binarization processing is shown in Figure 4.
以上所述是本发明的优选实施方式,应当指出,对于本技术领域的普通技术人员来说,在不脱离本发明原理的前提下,还可以做出若干改进和润饰,这些改进和润饰也视为本发明的保护范围。The above description is a preferred embodiment of the present invention, and it should be pointed out that for those skilled in the art, without departing from the principle of the present invention, some improvements and modifications can also be made, and these improvements and modifications are also considered Be the protection scope of the present invention.
Claims (3)
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201610504100.7A CN106127817B (en) | 2016-06-28 | 2016-06-28 | A kind of image binaryzation method based on channel |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201610504100.7A CN106127817B (en) | 2016-06-28 | 2016-06-28 | A kind of image binaryzation method based on channel |
Publications (2)
Publication Number | Publication Date |
---|---|
CN106127817A true CN106127817A (en) | 2016-11-16 |
CN106127817B CN106127817B (en) | 2018-11-06 |
Family
ID=57467597
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN201610504100.7A Expired - Fee Related CN106127817B (en) | 2016-06-28 | 2016-06-28 | A kind of image binaryzation method based on channel |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN106127817B (en) |
Cited By (7)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN106778780A (en) * | 2016-12-14 | 2017-05-31 | 江苏维普光电科技有限公司 | A kind of edge-detected image binarization method based on GPU |
CN110569684A (en) * | 2019-09-19 | 2019-12-13 | 南京全鉴信息技术有限公司 | Image binarization method for small-capacity cache |
CN112257830A (en) * | 2020-10-23 | 2021-01-22 | 上海烟草集团有限责任公司 | Smoke box information identification method and system |
CN112288754A (en) * | 2020-11-09 | 2021-01-29 | 珠海市润鼎智能科技有限公司 | Real-time binarization threshold value selection method for high-speed image |
CN112733834A (en) * | 2021-03-30 | 2021-04-30 | 恒银金融科技股份有限公司 | Character area positioning method based on non-matrix window mode |
CN114155241A (en) * | 2022-01-28 | 2022-03-08 | 浙江华睿科技股份有限公司 | Foreign matter detection method and device and electronic equipment |
CN117649661A (en) * | 2024-01-30 | 2024-03-05 | 青岛超瑞纳米新材料科技有限公司 | Carbon nanotube preparation state image processing method |
Citations (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN101515325A (en) * | 2009-04-08 | 2009-08-26 | 北京邮电大学 | Character extracting method in digital video based on character segmentation and color cluster |
KR20110106261A (en) * | 2011-09-08 | 2011-09-28 | (주)이컴앤드시스템 | Apparatus for Extracting and Decoding 2D Barcode Image with Arbitrary Contrast |
-
2016
- 2016-06-28 CN CN201610504100.7A patent/CN106127817B/en not_active Expired - Fee Related
Patent Citations (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN101515325A (en) * | 2009-04-08 | 2009-08-26 | 北京邮电大学 | Character extracting method in digital video based on character segmentation and color cluster |
KR20110106261A (en) * | 2011-09-08 | 2011-09-28 | (주)이컴앤드시스템 | Apparatus for Extracting and Decoding 2D Barcode Image with Arbitrary Contrast |
Non-Patent Citations (2)
Title |
---|
HUANG JIAN等: "Complex Scene Text Binarization based on Graph Cut", 《2016 IEEE INFORMATION TECHNOLOGY,NETWORKING,ELECTRONIC AND AUTOMATION CONTROL CONFERENCE》 * |
戴美玲等: "单幅彩色条纹投影的不连续物体表面三维形貌测量", 《光学学报》 * |
Cited By (12)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN106778780A (en) * | 2016-12-14 | 2017-05-31 | 江苏维普光电科技有限公司 | A kind of edge-detected image binarization method based on GPU |
CN106778780B (en) * | 2016-12-14 | 2020-05-01 | 江苏维普光电科技有限公司 | GPU-based edge detection image binarization method |
CN110569684A (en) * | 2019-09-19 | 2019-12-13 | 南京全鉴信息技术有限公司 | Image binarization method for small-capacity cache |
CN110569684B (en) * | 2019-09-19 | 2023-05-12 | 南京全鉴信息技术有限公司 | Image binarization method for small-capacity cache |
CN112257830A (en) * | 2020-10-23 | 2021-01-22 | 上海烟草集团有限责任公司 | Smoke box information identification method and system |
CN112288754A (en) * | 2020-11-09 | 2021-01-29 | 珠海市润鼎智能科技有限公司 | Real-time binarization threshold value selection method for high-speed image |
CN112288754B (en) * | 2020-11-09 | 2023-12-05 | 珠海市润鼎智能科技有限公司 | Real-time binarization threshold selection method for high-speed image |
CN112733834A (en) * | 2021-03-30 | 2021-04-30 | 恒银金融科技股份有限公司 | Character area positioning method based on non-matrix window mode |
CN112733834B (en) * | 2021-03-30 | 2021-07-06 | 恒银金融科技股份有限公司 | Character area positioning method based on non-matrix window mode |
CN114155241A (en) * | 2022-01-28 | 2022-03-08 | 浙江华睿科技股份有限公司 | Foreign matter detection method and device and electronic equipment |
CN117649661A (en) * | 2024-01-30 | 2024-03-05 | 青岛超瑞纳米新材料科技有限公司 | Carbon nanotube preparation state image processing method |
CN117649661B (en) * | 2024-01-30 | 2024-04-12 | 青岛超瑞纳米新材料科技有限公司 | Carbon nanotube preparation state image processing method |
Also Published As
Publication number | Publication date |
---|---|
CN106127817B (en) | 2018-11-06 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN106127817B (en) | A kind of image binaryzation method based on channel | |
CN101515325B (en) | Character extracting method in digital video based on character segmentation and color cluster | |
CN102208023B (en) | Method for recognizing and designing video captions based on edge information and distribution entropy | |
CN1312625C (en) | Character extracting method from complecate background color image based on run-length adjacent map | |
CN101170641A (en) | A Method of Image Edge Detection Based on Threshold Segmentation | |
CN104361336A (en) | Character recognition method for underwater video images | |
CN105160691A (en) | Color histogram based vehicle body color identification method | |
CN104657980A (en) | Improved multi-channel image partitioning algorithm based on Meanshift | |
WO2017088479A1 (en) | Method of identifying digital on-screen graphic and device | |
Gattal et al. | Automatic parameter tuning of k-means algorithm for document binarization | |
US8000535B2 (en) | Methods and systems for refining text segmentation results | |
CN112488107A (en) | Video subtitle processing method and processing device | |
Sanketi et al. | Localizing blurry and low-resolution text in natural images | |
Biswas et al. | A global-to-local approach to binarization of degraded document images | |
CN110991440B (en) | Pixel-driven mobile phone operation interface text detection method | |
CN115578741A (en) | Mask R-cnn algorithm and type segmentation based scanned file layout analysis method | |
CN107610132A (en) | A kind of ancient books file and picture greasiness removal method | |
CN107145888A (en) | Method for real-time translation of video subtitles | |
Saini | Document image binarization techniques, developments and related issues: a review | |
CN111080723A (en) | Image element segmentation method based on Unet network | |
Lézoray et al. | Histogram and watershed based segmentation of color images | |
CN106407969A (en) | Robust complex background video text positioning and extracting method | |
CN110807747A (en) | Document image noise reduction method based on foreground mask | |
Gupta et al. | A learning-based approach for automatic image and video colorization | |
Indra | Feature extraction of bisindo alphabets using chain code contour |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
C06 | Publication | ||
PB01 | Publication | ||
C10 | Entry into substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
GR01 | Patent grant | ||
GR01 | Patent grant | ||
CF01 | Termination of patent right due to non-payment of annual fee | ||
CF01 | Termination of patent right due to non-payment of annual fee |
Granted publication date: 20181106 Termination date: 20190628 |