CN100580694C - A method for fast multi-threshold segmentation of grayscale images - Google Patents

A method for fast multi-threshold segmentation of grayscale images Download PDF

Info

Publication number
CN100580694C
CN100580694C CN200810064059A CN200810064059A CN100580694C CN 100580694 C CN100580694 C CN 100580694C CN 200810064059 A CN200810064059 A CN 200810064059A CN 200810064059 A CN200810064059 A CN 200810064059A CN 100580694 C CN100580694 C CN 100580694C
Authority
CN
China
Prior art keywords
array
peak value
gray scale
histogram
gray
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.)
Expired - Fee Related
Application number
CN200810064059A
Other languages
Chinese (zh)
Other versions
CN101236607A (en
Inventor
卞红雨
朱殿尧
刘东宇
张国恒
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Harbin Engineering University
Original Assignee
Harbin Engineering University
Priority date (The priority date 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 date listed.)
Filing date
Publication date
Application filed by Harbin Engineering University filed Critical Harbin Engineering University
Priority to CN200810064059A priority Critical patent/CN100580694C/en
Publication of CN101236607A publication Critical patent/CN101236607A/en
Application granted granted Critical
Publication of CN100580694C publication Critical patent/CN100580694C/en
Expired - Fee Related legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Landscapes

  • Image Analysis (AREA)
  • Image Processing (AREA)

Abstract

本发明涉及数字图像处理技术领域,公开了一种用于灰度图像快速多阈值分割的方法。本发明先读取灰度图像,并计算其灰度直方图。将得到的直方图进行平滑,得到平滑直方图,在平滑直方图中选取若干最大峰值点,并获取它们对应的灰度值数组。将灰度值数组两端扩展,使扩展后的数组中两相邻元素相加在除以2就得到了多阈值分割所需要的阈值,进而实现多阈值分割。

Figure 200810064059

The invention relates to the technical field of digital image processing, and discloses a method for fast multi-threshold segmentation of grayscale images. The invention firstly reads the grayscale image and calculates its grayscale histogram. Smooth the obtained histogram to obtain a smoothed histogram, select several maximum peak points in the smoothed histogram, and obtain their corresponding gray value arrays. The two ends of the gray value array are extended, so that the addition of two adjacent elements in the extended array and dividing by 2 can obtain the threshold value required for multi-threshold segmentation, and then realize multi-threshold segmentation.

Figure 200810064059

Description

一种用于灰度图像快速多阈值分割的方法 A method for fast multi-threshold segmentation of grayscale images

技术领域 technical field

本发明涉及的是一种数字图像处理技术,具体地说是一种用于灰度图像快速多阈值分割的方法。The invention relates to a digital image processing technology, in particular to a method for fast multi-threshold segmentation of grayscale images.

背景技术 Background technique

分割技术是图像模式识别的基础,具有广泛的用途,在科研、生产当中都是一个热点研究课题。多阈值分割可以用来识别具有不同色彩或灰度的目标或用来识别灰度在很窄范围内变化的目标。如在侧扫声纳目标识别任务中,阴影可以作为目标的一个特征,但是由于海底背景的回波强度与阴影区相近,所以一般情况下,二值分割算法很难将阴影区域提取出来。而目前的众多多阈值分割技术又因为计算量大的原因难以满足实时性要求。Segmentation technology is the basis of image pattern recognition, has a wide range of uses, and is a hot research topic in scientific research and production. Multi-threshold segmentation can be used to identify objects with different colors or gray levels or to identify objects whose gray levels vary within a narrow range. For example, in the side-scan sonar target recognition task, the shadow can be used as a feature of the target, but because the echo intensity of the seabed background is similar to the shadow area, it is generally difficult for the binary segmentation algorithm to extract the shadow area. However, many current multi-threshold segmentation techniques are difficult to meet the real-time requirements because of the large amount of calculation.

发明内容 Contents of the invention

本发明提供一种可以实现灰度图像的多阈值分割,而且易于满足实时性要求的用于灰度图像快速多阈值分割的方法。The invention provides a method for rapid multi-threshold segmentation of gray-scale images, which can realize multi-threshold segmentation of gray-scale images and is easy to meet real-time requirements.

本发明的目的是这样实现的:The purpose of the present invention is achieved like this:

(1)读取待分割的灰度图像,并将其存入一个二维图像数组A中,各像素点的灰度值均在0~255的范围内;(1) Read the grayscale image to be segmented and store it in a two-dimensional image array A, the grayscale value of each pixel is in the range of 0 to 255;

(2)遍历图像数组A,得到图像的灰度直方图;(2) traverse the image array A to obtain the grayscale histogram of the image;

(3)使灰度直方图通过一个低通滤波器,得到平滑直方图;(3) Make the grayscale histogram pass through a low-pass filter to obtain a smooth histogram;

(4)开辟峰值数组和灰度数组两个数组,并将两个数组全部初始化为0,峰值数组和灰度数组分别保存直方图峰值和峰值对应的灰度,峰值数组与灰度数组下标相同的元素是一一对应的;(4) Open up two arrays, the peak value array and the gray scale array, and initialize both arrays to 0. The peak value array and the gray scale array respectively store the peak value of the histogram and the gray scale corresponding to the peak value, and the subscripts of the peak value array and the gray scale array The same elements are in one-to-one correspondence;

(5)遍历平滑直方图,将新得到峰值及峰值对应的灰度分别存入峰值数组和灰度数组的最后,然后将峰值数组和灰度数组排序;(5) Traversing the smooth histogram, storing the newly obtained peak value and the gray value corresponding to the peak value into the end of the peak value array and the gray value array respectively, and then sorting the peak value array and the gray value array;

(6)利用步骤(5)得到的灰度数组确定多阈值分割的各个阈值;(6) utilize the grayscale array that step (5) obtains to determine each threshold of multi-threshold segmentation;

(7)遍历图像数组A,A中各元素与步骤(6)中得到的各阈值比较,得到一个标号,存入二维标号数组B的对应位置处,实现灰度图像的快速多阈值分割。(7) traverse the image array A, each element in A is compared with each threshold obtained in step (6), obtain a label, store in the corresponding position of the two-dimensional label array B, realize the fast multi-threshold segmentation of the grayscale image.

本发明还可以包括这样一些特征:The present invention can also include such features:

1.步骤(4)中所述的峰值数组和灰度数组大小等于预设的阈值个数n。1. The size of the peak array and grayscale array described in step (4) is equal to the preset threshold number n.

2.步骤(5)中所述的排序,峰值数组按直接法排序,灰度数组按照峰值数组的变化而做对应改变,使峰值所对应的灰度值不变。2. In the sorting described in step (5), the peak array is sorted by the direct method, and the grayscale array is changed according to the change of the peak array, so that the grayscale value corresponding to the peak value remains unchanged.

3.步骤(6)中所述的多阈值分割的各个阈值的确定方法为将灰度数组进行降序排列,然后取出灰度数组中的前n-1个元素,将其左右两边进行扩展,左边的扩展元素为0,右边的扩展元素为255,得到一个新的一维数组C,从C的左边第一个元素开始,该元素与其右边相邻元素相加再除以2就得到要求的阈值数组D,这个过程一直持续到数组C的第n个元素,数组D中的各个元素是要求的n个阈值。3. The method for determining each threshold of the multi-threshold segmentation described in step (6) is to arrange the grayscale array in descending order, then take out the first n-1 elements in the grayscale array, and expand the left and right sides of the grayscale array. The extended element of is 0, the extended element on the right is 255, and a new one-dimensional array C is obtained. Starting from the first element on the left of C, the element is added to the adjacent element on the right and divided by 2 to obtain the required threshold. Array D, this process continues until the nth element of array C, and each element in array D is the required n thresholds.

本发明是基于灰度直方图的多阈值分割。由于多目标的存在,灰度直方图是具有多峰的,因此相邻两峰之中点所对应的灰度作为阈值是一个比较合理的估计,这也正是该灰度图像快速多阈值分割方法的核心思想。The present invention is based on the multi-threshold segmentation of the gray histogram. Due to the existence of multiple targets, the grayscale histogram has multiple peaks, so the grayscale corresponding to the midpoint of two adjacent peaks is a reasonable estimate as the threshold value, which is exactly the method for fast multi-threshold segmentation of grayscale images. core idea.

实验表明,对于一幅尺寸为330×244的灰度图像,在一台CPU为AMD1600+,操作系统为Windows2000,编程环境为VC6.0的条件下,同时执行2阈值分割、3阈值分割、4阈值分割和5阈值分割共耗时10毫秒,完全可以达到实时性要求。而目前其它多阈值算法没有提供算法的执行时间方面的数据。Experiments show that, for a grayscale image with a size of 330×244, under the condition that a CPU is AMD1600+, the operating system is Windows2000, and the programming environment is VC6.0, 2-threshold segmentation, 3-threshold segmentation, 4-threshold Segmentation and 5-threshold segmentation take 10 milliseconds in total, which can fully meet the real-time requirements. At present, other multi-threshold algorithms do not provide data on the execution time of the algorithm.

附图说明 Description of drawings

图1是本发明的流程框图。Fig. 1 is a flowchart of the present invention.

图2是本发明步骤6中所述的数组C。Fig. 2 is the array C described in step 6 of the present invention.

图3是本发明步骤6中所述的数组D。Fig. 3 is the array D described in step 6 of the present invention.

图4是一幅待分割的尺寸为330×244的灰度图像。Figure 4 is a grayscale image with a size of 330×244 to be segmented.

图5是用Otsu法对图4的二值分割结果。Fig. 5 is the binary segmentation result of Fig. 4 by Otsu method.

图6是利用本发明对图4的四阈值分割结果。Fig. 6 is the segmentation result of the four thresholds in Fig. 4 by using the present invention.

具体实施方式 Detailed ways

下面结合附图举例对本发明作进一步说明。The present invention will be further described below with examples in conjunction with the accompanying drawings.

1.读取待分割的灰度图像(图4),并将其存入一个二维图像数组A中,各像素点的灰度值均在0~255的范围内。1. Read the grayscale image to be segmented (Figure 4), and store it in a two-dimensional image array A, the grayscale value of each pixel is in the range of 0-255.

2.遍历图像数组A,得到图像的灰度直方图。2. Traverse the image array A to get the grayscale histogram of the image.

3.使灰度直方图通过一个低通滤波器,得到平滑直方图。3. Pass the grayscale histogram through a low-pass filter to obtain a smooth histogram.

4.开辟两个数组——峰值数组和灰度数组,并将两个数组全部初始化为0。峰值数组和灰度数组分别保存直方图峰值和峰值对应的灰度,峰值数组与灰度数组下标相同的元素是一一对应的,峰值数组和灰度数组大小应等于预设的阈值个数n。4. Create two arrays—the peak array and the grayscale array, and initialize both arrays to 0. The peak value array and the gray level array respectively store the peak value of the histogram and the gray level corresponding to the peak value. The elements with the same subscript of the peak value array and the gray level array are in one-to-one correspondence. The size of the peak value array and the gray level array should be equal to the preset threshold number n.

5.遍历平滑直方图,将新得到峰值及峰值对应的灰度分别存入峰值数组和灰度数组的最后,然后将峰值数组和灰度数组排序。峰值数组按直接法排序,灰度数组按照峰值数组的变化而做对应改变,使峰值所对应的灰度值不变。5. Traversing the smoothing histogram, storing the newly obtained peak value and the corresponding gray value to the end of the peak value array and the gray value array respectively, and then sorting the peak value array and the gray value array. The peak array is sorted by the direct method, and the grayscale array is changed according to the change of the peak array, so that the grayscale value corresponding to the peak value remains unchanged.

6.将灰度数组进行降序排列,然后取出灰度数组中的前n-1个元素,将这n-1个元素左右两边进行扩展,左边的扩展元素为0,右边的扩展元素为255,得到一个新的一维数组C(如图2所示),该数组包含n+1个元素,从左边第一个元素开始,该元素与其右边相邻元素相加再除以2就得到了要求的阈值数组D(如图3所示),这个过程一直持续到数组C的第n个元素。数组D中共包含n个元素,这n个元素就是要求的n个阈值。6. Arrange the grayscale array in descending order, then take out the first n-1 elements in the grayscale array, and expand the left and right sides of the n-1 elements, the left expansion element is 0, and the right expansion element is 255, Get a new one-dimensional array C (as shown in Figure 2), which contains n+1 elements, starting from the first element on the left, adding the element to the adjacent element on the right and dividing by 2 to obtain the requirement The threshold array D (as shown in Figure 3), this process continues until the nth element of the array C. The array D contains n elements in total, and these n elements are the required n thresholds.

7.遍历图像数组A,A中各元素与D中的各阈值比较,得到一个标号,存入二维标号数组B的对应位置处,从而实现了灰度图像的快速多阈值分割。其中,D中各元素为D[0],……D[n-1],当A中的元素小于等于D[k]时(k=0,1……n-1),则在B中对应位置赋予标号k,当A中元素大于D[n-1]时,则在B中对应位置赋予标号n,从而实现对图像的多阈值分割。7. The image array A is traversed, and each element in A is compared with each threshold in D to obtain a label, which is stored in the corresponding position of the two-dimensional label array B, thereby realizing fast multi-threshold segmentation of grayscale images. Among them, each element in D is D[0],...D[n-1], when the element in A is less than or equal to D[k] (k=0, 1...n-1), then in B The corresponding position is given the label k, and when the element in A is greater than D[n-1], the corresponding position in B is given the label n, so as to realize the multi-threshold segmentation of the image.

Claims (3)

1. one kind is used for the method that the gray level image rapid multi-threshold value is cut apart, and it is characterized in that comprising the steps:
(1) read gray level image to be split, and it is deposited among the two dimensional image array A, each gray values of pixel points is all in 0~255 scope;
(2) traversing graph obtains the grey level histogram of image as array A;
(3) make grey level histogram pass through a low-pass filter, obtain smoothed histogram;
(4) open up two arrays of peak value array and gray scale array, and two arrays all are initialized as 0, peak value array and grey group are preserved the gray scale of histogram peak and peak value correspondence respectively, and the element that the peak value array is identical with the gray scale array index is one to one;
(5) traversal smoothed histogram deposits the gray scale that newly obtains peak value and peak value correspondence in peak value array and gray scale array last respectively, then with peak value array and gray scale array sort;
(6) the gray scale array is carried out descending sort, take out preceding n-1 element in the gray scale array then, this n-1 element the right and left expanded, the extensible element on the left side is 0, the extensible element on the right is 255, obtain a new one-dimension array C, this array comprises n+1 element, from the first left element, the adjacent element addition of this element and its right just obtains the threshold value array D that requires divided by 2 again, this process lasts till n the element of array C always, comprises n element among the array D altogether, and this n element is exactly a n threshold value of requirement;
(7) traversing graph is as array A, and each threshold ratio that obtains in each element and the step (6) among the A obtains a label, deposits the corresponding position of two-dimentional label array B in, realizes that the rapid multi-threshold value of gray level image is cut apart.
2. according to claim 1ly be used for the method that the gray level image rapid multi-threshold value is cut apart, it is characterized in that: peak value array described in the step (4) and gray scale array size equal the preset threshold value number n.
3. according to claim 1 and 2ly be used for the method that the gray level image rapid multi-threshold value is cut apart, it is characterized in that: the ordering described in the step (5), the peak value array is by the direct method ordering, and the gray scale array is made corresponding the change according to the variation of peak value array, make peak value corresponding gray scale value constant.
CN200810064059A 2008-03-03 2008-03-03 A method for fast multi-threshold segmentation of grayscale images Expired - Fee Related CN100580694C (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN200810064059A CN100580694C (en) 2008-03-03 2008-03-03 A method for fast multi-threshold segmentation of grayscale images

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN200810064059A CN100580694C (en) 2008-03-03 2008-03-03 A method for fast multi-threshold segmentation of grayscale images

Publications (2)

Publication Number Publication Date
CN101236607A CN101236607A (en) 2008-08-06
CN100580694C true CN100580694C (en) 2010-01-13

Family

ID=39920212

Family Applications (1)

Application Number Title Priority Date Filing Date
CN200810064059A Expired - Fee Related CN100580694C (en) 2008-03-03 2008-03-03 A method for fast multi-threshold segmentation of grayscale images

Country Status (1)

Country Link
CN (1) CN100580694C (en)

Families Citing this family (11)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101887584B (en) * 2010-07-07 2012-03-28 清华大学 A Multi-Threshold Image Segmentation Method Based on Moderate Random Search Behavior
CN102663390B (en) * 2012-04-28 2014-04-30 长春迪瑞医疗科技股份有限公司 Flow-cytometry microscopic image binaryzation method
CN102819841B (en) * 2012-07-30 2015-01-28 中国科学院自动化研究所 Global threshold partitioning method for partitioning target image
CN102843492A (en) * 2012-08-10 2012-12-26 北京航空航天大学 Overlap scanning and image separating method based on transmission scanning
CN102915538B (en) * 2012-09-18 2016-05-18 成都金盘电子科大多媒体技术有限公司 A kind of bianry image automatic Selection of Image Threshold based on biological vision
CN103295226B (en) * 2013-04-25 2016-05-04 哈尔滨工程大学 A kind of non-supervisory sonar image dividing method based on MRF model
CN104243820B (en) * 2014-09-03 2018-02-16 奇瑞汽车股份有限公司 A kind of method and device for determining image boundary
CN104318575B (en) * 2014-11-04 2017-02-15 江西理工大学 Multi-threshold image segmentation method based on comprehensive learning differential evolution algorithm
CN105701807B (en) * 2016-01-12 2019-05-10 西北工业大学 An Image Segmentation Method Based on Voting Strategy
CN106327497A (en) * 2016-08-29 2017-01-11 湖南文理学院 Gray-scale image threshold segmentation method based on super-extensive entropy
CN111145130B (en) * 2019-12-06 2023-05-30 Oppo广东移动通信有限公司 Image processing method and device and storage medium

Non-Patent Citations (4)

* Cited by examiner, † Cited by third party
Title
几种阈值分割法在工程图自动识别中的应用. 赖有华,叶海建.江西理工大学学报,第27卷第4期. 2006
几种阈值分割法在工程图自动识别中的应用. 赖有华,叶海建.江西理工大学学报,第27卷第4期. 2006 *
基于过渡区提取的多阈值图像分割. 闫成新,桑农,张天序.华中科技大学学报(自然科学版),第33卷第1期. 2005
基于过渡区提取的多阈值图像分割. 闫成新,桑农,张天序.华中科技大学学报(自然科学版),第33卷第1期. 2005 *

Also Published As

Publication number Publication date
CN101236607A (en) 2008-08-06

Similar Documents

Publication Publication Date Title
CN100580694C (en) A method for fast multi-threshold segmentation of grayscale images
CN109767439B (en) Target detection method for multi-scale difference and bilateral filtering of self-adaptive window
Singh et al. Textural identification of basaltic rock mass using image processing and neural network
Vincent Granulometries and opening trees
CN109800615A (en) The detection localization method and system of two-dimension code area
US8983199B2 (en) Apparatus and method for generating image feature data
WO2020009806A1 (en) Object detection using multiple sensors and reduced complexity neural networks
US9251418B2 (en) Method of detection of points of interest in a digital image
CN111127533B (en) Multi-feature fusion grinding wheel grinding performance prediction method based on neural network
CN105976385B (en) An Image Segmentation Method Based on Image Data Field
Shekar et al. Kirsch directional derivatives based shot boundary detection: an efficient and accurate method
CN109003247B (en) A Method of Removing Mixed Noise in Color Image
Devi et al. Analysis of segmentation scheme for diseased rice leaves
CN103336963B (en) A kind of method of image characteristics extraction and device
US10115195B2 (en) Method and apparatus for processing block to be processed of urine sediment image
Quweider et al. Grey level reduction for segmentation, threshholding and binarisation of images based on optimal partitioning on an interval
Cuisenaire et al. Fast Euclidean morphological operators using local distance transformation by propagation, and applications
CA2992930A1 (en) Method for choosing a compression algorithm depending on the image type
Shang et al. An improved OTSU method based on Genetic Algorithm
Choi et al. Fast super-resolution algorithm using ELBP classifier
Zhongming et al. The image segmentation algorithm of region growing and wavelet transform modulus maximum
CN114119658A (en) Following algorithm for multi-feature self-adaptive fusion
Myakal et al. Reversible data hiding technique using multi-layer perceptron based prediction and adaptive histogram bin shifting
Sun et al. Metallographical image segmentation and compression
Ding et al. Fast morphology algorithm with parallel processing structures

Legal Events

Date Code Title Description
C06 Publication
PB01 Publication
C10 Entry into substantive examination
SE01 Entry into force of request for substantive examination
C14 Grant of patent or utility model
GR01 Patent grant
C17 Cessation of patent right
CF01 Termination of patent right due to non-payment of annual fee

Granted publication date: 20100113

Termination date: 20120303