WO2020135230A1 - Inscribed circle determination method and device - Google Patents

Inscribed circle determination method and device Download PDF

Info

Publication number
WO2020135230A1
WO2020135230A1 PCT/CN2019/126702 CN2019126702W WO2020135230A1 WO 2020135230 A1 WO2020135230 A1 WO 2020135230A1 CN 2019126702 W CN2019126702 W CN 2019126702W WO 2020135230 A1 WO2020135230 A1 WO 2020135230A1
Authority
WO
WIPO (PCT)
Prior art keywords
pixel
value
calculation
weight value
area
Prior art date
Application number
PCT/CN2019/126702
Other languages
French (fr)
Chinese (zh)
Inventor
佟卉斌
Original Assignee
北京金山安全软件有限公司
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 北京金山安全软件有限公司 filed Critical 北京金山安全软件有限公司
Publication of WO2020135230A1 publication Critical patent/WO2020135230A1/en

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T7/00Image analysis
    • G06T7/10Segmentation; Edge detection
    • G06T7/187Segmentation; Edge detection involving region growing; involving region merging; involving connected component labelling
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T7/00Image analysis
    • G06T7/60Analysis of geometric attributes
    • G06T7/62Analysis of geometric attributes of area, perimeter, diameter or volume

Definitions

  • the present application relates to the technical field of image processing, and in particular to a method and device for determining an inscribed circle.
  • the connected domain in an image refers to an image area composed of pixels with the same pixel value and adjacent positions in the image.
  • the recognition of connected domains is widely used in image processing.
  • the recognition of connected domains is applied to image processing such as license plate recognition and contour drawing in puzzle games.
  • a large number of outlines composed of white pixels and black pixels are used.
  • Players fill the connected domains of each white pixel in the outline with different colors, and then will achieve white pixels and black pixels.
  • the outline drawing made up of points becomes the purpose of the color filled drawing.
  • the game maker will add a logo to each connected domain composed of white pixels when making the contour map to mark the different connected domains.
  • the mark used is generally expressed by adding a value within the circle. For example, the mark in the connected domain of number 1 is 1.
  • the logo in each connected domain should be as large as possible. If the mark in the connected domain is expressed by adding a value to the circle, the circle included in the mark when the mark in the connected domain is the largest is the largest inscribed circle of the connected domain. Therefore, how to determine the maximum inscribed circle of the connected domain is an urgent problem to be solved.
  • the purpose of the embodiments of the present application is to provide a method and a device for determining an inscribed circle, so as to realize the determination of the maximum inscribed circle of a connected domain.
  • the specific technical solutions are as follows:
  • an embodiment of the present application provides a method for determining an inscribed circle.
  • the method includes:
  • steps a and b are used for multiple calculations to obtain the weight value of each pixel in the area after multiple calculations until the preset calculation stop condition is met:
  • Step a Calculate the weight value of each pixel inside the area after the first calculation: for each pixel inside the area, determine the number of first target pixels adjacent to the pixel Is the weight value of the pixel after the first calculation, and the first target pixel is a pixel whose pixel value is the first pixel value;
  • Step b Calculate the weight value of each pixel in the area after the mth calculation: for each pixel in the area, calculate the number of second target pixels adjacent to the pixel and The sum of the weight values of the pixel after the m-1th calculation is used as the weight value of the pixel after the mth calculation, the pixel value of the second target pixel is the first pixel value, and After the m-1 calculation, the weight value of the second target pixel is ⁇ (m-1), where ⁇ is the maximum number of adjacent pixels that satisfy the preset adjacent condition, and m is greater than 1;
  • calculation stop condition is:
  • the calculation stop condition is that: the number of calculations reaches a preset threshold.
  • the method further includes:
  • the method further includes:
  • weight value to record the pixel value of each pixel in the image as the weight value of each pixel, and for each pixel inside the area, use the obtained weight value of the pixel after each calculation as The weight value records the pixel value of the pixel in the image.
  • the method further includes:
  • the pixel value of the pixel is determined as the weight value of the pixel whose position is the same as the position of the pixel in the binarized image.
  • an inscribed circle determination device the device including:
  • the first acquisition module is used to acquire a binarized image, the pixel value of the pixels inside the region of the connected domain in the binarized image is the first pixel value, and the pixel value of the pixel at the edge of the region of the connected domain Is the second pixel value;
  • the calculation module is used to perform multiple calculations using the following steps a and b for each pixel in the area to obtain the weight value of each pixel in the area after multiple calculations until the preset value is met
  • Step a Calculate the weight value of each pixel inside the area after the first calculation: for each pixel inside the area, determine the number of first target pixels adjacent to the pixel Is the weight value of the pixel after the first calculation, and the first target pixel is a pixel whose pixel value is the first pixel value;
  • Step b Calculate the weight value of each pixel in the area after the mth calculation: for each pixel in the area, calculate the number of second target pixels adjacent to the pixel and The sum of the weight values of the pixel after the m-1th calculation is used as the weight value of the pixel after the mth calculation, the pixel value of the second target pixel is the first pixel value, and After the m-1 calculation, the weight value of the second target pixel is ⁇ (m-1), where ⁇ is the maximum number of adjacent pixels that satisfy the preset adjacent condition, and m is greater than 1;
  • a first determining module configured to determine the pixel point with the largest weight value after the multiple calculations as the center of the inscribed circle of the connected domain
  • a second determining module configured to obtain the pixel point of the second pixel value closest to the center of the circle from the binarized image, and determine the distance between the obtained pixel point and the center of the circle as the State the radius of the inscribed circle.
  • calculation stop condition is:
  • the calculation stop condition is that: the number of calculations reaches a preset threshold.
  • the device further includes:
  • the judging module is used to judge whether there is a pixel with a weight value of 8*m among the pixels inside the area after the mth calculation; if there is, then calculate each pixel within the area at the (m+ 1) The weight value after the calculation; if it does not exist, it is determined that the calculation stop condition is satisfied.
  • the device further includes:
  • a setting module configured to set the pixel value of the pixels on the edge of the area to 255, set the pixel value of the pixels inside the area to 0, and determine the obtained image as the weight value recording image;
  • the storage module is used to record the pixel value of each pixel in the image with the weight value as the weight value of each pixel, and for each pixel inside the area, calculate the obtained pixel every time
  • the weight value after is used as the weight value to record the pixel value of the pixel in the image.
  • the device further includes:
  • a second obtaining module configured to obtain the stored pixel value of each pixel from the weight value recording image
  • the third determining module is used to determine the pixel value of each pixel as the weight value of the pixel whose position is the same as that of the pixel in the binarized image .
  • an embodiment of the present application provides an electronic device, including a processor, a communication interface, a memory, and a communication bus, where the processor, the communication interface, and the memory complete communication with each other through the communication bus;
  • Memory used to store computer programs
  • the processor when used to execute the program stored in the memory, implements any of the steps of the inscribed circle determination method described above.
  • an embodiment of the present application provides a machine-readable storage medium in which a computer program is stored, and when the computer program is executed by a processor, any inscribed circle described above is implemented Determine method steps.
  • an embodiment of the present application provides a computer program that, when executed by a processor, implements any of the steps of the inscribed circle determination method described above.
  • the number of the first target pixel adjacent to the pixel is determined as the first time
  • the calculated weight value is the sum of the number of the second target pixel point adjacent to the pixel point and the weight value of the pixel point after the m-1th calculation, as the pixel point after the mth calculation Weights.
  • the pixel For the pixels inside the connected domain area, the farther they are from the edge of the area, the greater the number of second target pixels adjacent to the pixel after the m-1th calculation, the pixel’s The larger the weight value. Therefore, the pixel with the larger weight value is closer to the center of the connected domain.
  • the pixel with the largest weight value after multiple calculations is used as the center of the inscribed circle of the connected domain, and then the second closest to the center of the circle is obtained from the binarized image
  • the pixel value of the pixel value, and the distance between the acquired pixel point and the center of the circle is determined as the radius of the inscribed circle.
  • the maximum inscribed circle of the connected domain can be obtained.
  • FIG. 1 is a flowchart of a method for determining an inscribed circle provided by an embodiment of this application;
  • FIG. 2 is a flowchart of a method for determining an inscribed circle provided by an embodiment of the present application
  • 3(1) is a binary image provided by an embodiment of the present application.
  • 3(2) is a schematic diagram after the first calculation of the binary image provided by the embodiment of the present application.
  • FIG. 3(3) is a schematic diagram after the second calculation of the binary image provided by the embodiment of the present application.
  • 3(4) is a schematic diagram after the third calculation of the binary image provided by the embodiment of the present application.
  • FIG. 4 is a schematic structural diagram of a device for determining an inscribed circle provided by an embodiment of the present application.
  • FIG. 5 is a schematic structural diagram of an electronic device provided by an embodiment of the present application.
  • an embodiment of the present application provides a method and a device for determining an inscribed circle, where the method for determining an inscribed circle includes:
  • the pixel value of the pixels inside the area of the connected domain in the binarized image is the first pixel value
  • the pixel value of the pixel points of the edge of the area of the connected domain is the second pixel value
  • steps a and b are used for multiple calculations to obtain the weight value of each pixel in the area after multiple calculations until the preset calculation stop condition is met:
  • Step a Calculate the weight value of each pixel in the area after the first calculation: for each pixel in the area, determine the number of the first target pixel adjacent to the pixel as the pixel The weight value after the first calculation, the first target pixel is the pixel whose pixel value is the first pixel value;
  • Step b Calculate the weight value of each pixel in the area after the mth calculation: for each pixel in the area, calculate the number of the second target pixel adjacent to the pixel and the pixel The sum of the weight values after the m-1th calculation is taken as the weight value of the pixel after the mth calculation, the pixel value of the second target pixel is the first pixel value, and the The weight value of the two target pixels is ⁇ (m-1), m is greater than 1;
  • the pixel point of the second pixel value closest to the center of the circle is obtained, and the distance between the obtained pixel point and the center of the circle is determined as the radius of the inscribed circle.
  • the pixel with the largest weight value after multiple calculations is used as the center of the inscribed circle of the connected domain, and then the second closest to the center of the circle is obtained from the binarized image
  • the pixel value of the pixel value, and the distance between the acquired pixel point and the center of the circle is determined as the radius of the inscribed circle.
  • the maximum inscribed circle of the connected domain can be obtained.
  • the embodiment of the present application provides a method for determining an inscribed circle, as shown in FIG. 1, including the following steps.
  • the above-mentioned binary image may be a user-defined binary image.
  • the image to be processed is itself a binary image.
  • the above-mentioned binarized image may also be an image obtained by binarizing non-binarized images such as color images and grayscale images.
  • the image to be processed is a user-defined non-binary ⁇ image.
  • the region edge may be regarded as the edge or contour of the connected domain.
  • Step a Calculate the weight value of each pixel in the area after the first calculation: for each pixel in the area, determine the number of the first target pixel adjacent to the pixel as the pixel The weight value after the first calculation, the first target pixel is the pixel whose pixel value is the first pixel value;
  • Step b Calculate the weight value of each pixel in the area after the mth calculation: for each pixel in the area, calculate the number of the second target pixel adjacent to the pixel and the pixel The sum of the weight values after the m-1th calculation is taken as the weight value of the pixel after the mth calculation, the pixel value of the second target pixel is the first pixel value, and the The weight value of the two target pixels is ⁇ (m-1), where ⁇ is the maximum number of neighboring pixels that satisfy the preset neighboring conditions, and m is greater than.
  • the preset neighboring conditions can be set according to actual needs.
  • the preset neighboring condition may be left, right, top, bottom, top left, top right, bottom left, bottom right and top adjacent.
  • the preset neighboring conditions may also be left, right, up, down, up and down.
  • 8.
  • 4.
  • the preset adjacent condition is a condition that can also be other forms, which is not specifically limited.
  • the calculation stop condition can be set according to actual needs.
  • the calculation stop condition may be: after the m-1th calculation, there are pixels with a weight value of 8 (m-1) inside the area, and after the mth calculation, there is no weight value within the area of 8*m Pixels.
  • the calculation stop condition may be: the number of calculations reaches a preset number of times threshold.
  • S104 Obtain the pixel point of the second pixel value closest to the center of the circle from the binary image, and determine the distance between the obtained pixel point and the center of the circle as the radius of the inscribed circle.
  • the pixel with the largest weight value after multiple calculations is used as the center of the inscribed circle of the connected domain, and then the second closest to the center of the circle is obtained from the binarized image
  • the pixel value of the pixel value, and the distance between the acquired pixel point and the center of the circle is determined as the radius of the inscribed circle.
  • the maximum inscribed circle of the connected domain can be obtained.
  • the pixel value of the pixel inside the connected domain region in the binarized image may be 0, and the pixel value of the pixel at the edge of the region may be 255, that is, the first pixel value is 0, and the second pixel value is 255.
  • the pixel value of the pixel inside the area in the binarized image may also be 255, and the pixel value of the pixel at the edge of the area may also be 0, that is, the first pixel value is 255 and the second pixel value is 0.
  • 8 as an example to describe an inscribed circle determination method provided by an embodiment of the present application. Based on the above situation, an embodiment of the present application also provides a method for determining an inscribed circle, as shown in FIG. 2, including the following steps.
  • the binary image may be a user-defined image to be processed.
  • the image to be processed is itself a binary image.
  • the binarized image can also be an image obtained by binarizing non-binarized images such as color images and grayscale images.
  • the non-binarized images are user-defined to be processed image.
  • the method for determining the inscribed circle can be applied to any connected domain in the binarized image, that is, to determine the inscribed circle of any connected domain in the binarized image.
  • the embodiments of the present application describe a connected domain in a binarized image. Adjacent pixels with the same pixel value can form a connected domain. The pixels included in the area of a connected domain have the same pixel value. For example, if the connected domain is composed of white pixels, the pixel value of each pixel in the area of the connected domain is 255.
  • the binarized image may include one or more connected domains, and the pixel values in the pixels within the area of one connected domain are the same.
  • acquiring the pixel values of each pixel included in the connected domain in the binarized image is to obtain the binarized image, and one or more connected domains can be determined based on the pixel values of each pixel in the binarized image.
  • step a and step b For each pixel in each pixel, perform step a and step b to perform n calculations to obtain the weight value of each pixel after the nth calculation.
  • the above-mentioned pixels are pixels in the area of the connected domain.
  • the weight value of each pixel in the area is iteratively calculated, n is the number of calculations that satisfy the preset calculation stop condition, and n is a positive integer greater than 1. Therefore, the above step S102 is to perform step a and step b for n times of calculation for each pixel in the area to obtain the weight value of the pixel after multiple calculations until the preset calculation stop condition is satisfied.
  • the i-th calculation represents the calculation of the weight value of the i-th pixel, i is a positive integer.
  • the weight value of the pixel after the i-th calculation is the weight value of the pixel after the i-th calculation.
  • the way to calculate the weight value is the same. Based on this, the calculation method of the weight value provided by the embodiment of the present application is described for one pixel.
  • Step a Calculate the weight value of each pixel in the area after the first calculation. Specifically, for each pixel inside the area, the number of the first target pixel adjacent to the pixel is determined as the weight value of the pixel after the first calculation.
  • the pixel value of the first target pixel is the first pixel value, that is, the first target pixel is the pixel inside the area.
  • Figure 3(1) is a binary image.
  • Each box in Figure 3(1) represents a pixel, where black boxes represent pixels with a pixel value of 0, and white boxes represent Pixels with a pixel value of 255.
  • the area formed by the white frame is inside the area of the connected domain. For a pixel with coordinates (1,1), there are 3 adjacent pixels, and for a pixel with coordinates (2,2), there are 8 adjacent pixels.
  • (1,1) represents the coordinates of the first row and the first column
  • (2,2) represents the coordinates of the second row and the second column
  • the coordinates of the pixel points in the embodiments of the present application can be expressed in this way, and will not be described hereafter.
  • the first pixel value is the pixel value of the pixel inside the area. For example, as shown in FIG. 3(1), the pixel value of the pixels in the area of the connected domain composed of white frames is 255, and the first pixel value is 255. When the interior of the connected domain is composed of black frames, the pixel value of the pixel in the connected domain is 0, and the first pixel value is 0.
  • each pixel in the area of the connected domain after counting the number of the first target pixel adjacent to the pixel, the counted number can be determined as the first calculation of the pixel Weight value. In this way, each pixel in the area corresponds to a weight value after the first calculation.
  • the pixel value of the pixels in the connected domain is 255, that is, the pixels in the area are white pixels, and the first pixel value is 255.
  • the number of pixels with a pixel value of 255 among the pixels adjacent to the pixel is counted, and the counted number is determined to be the pixel at The weight value after the first calculation.
  • the weight value of each pixel obtained with a pixel value of 255 is shown in FIG. 3(2).
  • a pixel with coordinates (1,1) has a weight value of 3
  • a pixel with coordinates (1,2) has a weight value of 5
  • a pixel with coordinates (2,2) has a weight value of 8.
  • Step a is calculated for the first time. After step a is completed, the weight value of each pixel in the area after the first calculation can be obtained.
  • Step b Calculate the weight value of each pixel in the area after the mth calculation. Specifically, for each pixel in the area, the sum of the number of the second target pixel adjacent to the pixel and the weight value of the pixel after the m-1th calculation is used as the pixel The weight value after the mth calculation.
  • the pixel value of the second target pixel is the first pixel value, that is, the second sub-target pixel is the pixel inside the area, and the weight value of the second target pixel after the m-1th calculation is 8 (m-1), m is greater than 1.
  • the second sub-target pixel point and the first sub-target pixel point may be collectively referred to as a first target pixel point.
  • the weight value of each pixel in the area can be updated until the preset The calculation stop condition.
  • the weight value of each pixel in the area after the last calculation is known. Therefore, from the second calculation, for each calculation of the weight value of each pixel inside the area, the weight value of the pixel adjacent to the pixel after the previous calculation can be referred to.
  • the weight value of each pixel in the area after the m-1 calculation is known. You can refer to the weight value of each pixel in the area after the m-1 calculation to calculate the area The weight value of each pixel in the mth calculation.
  • the weight value of each pixel in the area after the first calculation is known, as shown in Figure 3(2), and Figure 3(2) shows the weight value after the first calculation
  • the value in each white frame in FIG. 3(2) is the weight value of the pixel indicated by the white frame. You can refer to the weight value of each pixel in the area after the first calculation, and calculate the weight value of each pixel in the area after the second calculation.
  • the number of second target pixels among the pixels adjacent to the pixel can be determined.
  • FIG. 3(2) shows the weight value of each pixel in the area after the first calculation.
  • the number of pixels with a weight value of 8 after the first calculation among pixels adjacent to each pixel in the area can be determined. For example, after the first calculation, pixels with a weight value of 8 among pixels adjacent to the pixel with coordinates (1,1) have pixels with coordinates (2,2), that is, with coordinates (1 ,1) The number of pixels with a weight value of 8 among the pixels adjacent to the pixel is 1.
  • the pixels with a weight value of 8 among the pixels adjacent to the pixel with coordinates (1,3) have pixels with coordinates (2,2), (2,3), (2,4), that is ,
  • the number of pixels with a weight value of 8 among the pixels adjacent to the pixel with coordinates (1, 3) is 3.
  • the determined number and the weight value of the pixel after the m-1th calculation can be calculated And.
  • the obtained sum corresponding to the pixel is determined as the weight value of the pixel after the mth calculation.
  • the weight value of each pixel in the area is the weight value after the mth calculation.
  • determine the number of pixels with a weight value of 8 among the pixels adjacent to the pixel, and match the determined number with the pixel in the first time The calculated weight values are added, and the obtained sum is the weight value of the pixel after the second calculation.
  • the weight value of each pixel in the area after the second calculation is shown in FIG. 3(3).
  • step b m is greater than 1.
  • the preset calculation stop condition is met, and the next calculation is not performed.
  • the preset calculation stop condition is satisfied, and the calculation of the weight value of each pixel in the area is ended.
  • the calculation stop condition can be customized. After each calculation is completed, you can determine whether the current condition reaches the set calculation stop condition. When it is determined that the calculation stop condition is not reached, the next calculation is entered. When the determination is reached, the calculation is stopped and the process is not performed. Calculate once.
  • the calculation stop condition is: after the m-1th calculation, there are pixels with a weight value of 8 (m-1) in each pixel inside the area, and after the mth calculation, inside the area There is no pixel with a weight value of 8*m in each pixel of.
  • the weight value of each pixel in the area can be obtained, and there is a weight value of 8(m-1) in the obtained weight value.
  • the weight value of each pixel in the area can be obtained, and there is a weight value of 8(m-1) in the obtained weight value.
  • Calculate the number of statistics and the pixel at The sum of the weight values after the m-1th calculation, and the obtained sum is determined as the weight value of the pixel after the mth calculation.
  • the m-1 calculation is the second calculation.
  • the weight value of each pixel in the area after the second calculation is shown in Figure 3(3).
  • the third calculation for each pixel in the area in FIG. 3(3), determine the number of pixels with a weight value of 16 among the pixels adjacent to the pixel, and set the determined number It is added to the weight value of the pixel after the second calculation, and the obtained sum is the weight value of the pixel after the third calculation.
  • the calculation stop condition is that the number of calculations reaches a preset number of thresholds. When the number of calculations reaches the preset number of thresholds, the next calculation is not performed.
  • the preset number of times threshold is n. When the number of calculations reaches n times, the n+1th calculation is no longer performed.
  • the preset number of times threshold can be customized. For example, the preset number of times threshold is 30 times. When m is 30, that is, when the number of calculations reaches 30 times, the 31st calculation is no longer performed.
  • S203 Determine the pixel with the largest weight value after the n-th calculation among the pixels as the center of the inscribed circle of the connected domain.
  • Each pixel in S203 is a pixel within the area. Therefore, S203 can be considered as determining the pixel point with the largest weight value after multiple calculations as the center of the inscribed circle of the connected domain.
  • the weight value of each pixel in the connected domain after multiple calculations can be obtained.
  • a larger weight value of a pixel indicates that there are more pixels with a first pixel value around the pixel.
  • the weight value of the pixel point is 8 indicating that the eight adjacent pixel points of the pixel point are all pixels with the first pixel value.
  • the pixels with the first pixel value around the pixel with the largest weight value have the most pixels. That is, for the pixels within the region, the closer they are to the edge of the region, after multiple calculations, the fewer the pixels of the first pixel value adjacent to the pixel, the smaller the weight value of the pixel. As for the pixels in the area, the farther they are from the edge of the area, the more pixel numbers of the first pixel value adjacent to the pixel after multiple calculations, the greater the weight value of the pixel. Therefore, the pixel with the larger weight value is closer to the center of the connected domain.
  • the pixel with the largest weight value after multiple calculations can be determined as the center of the inscribed circle of the connected domain. After the center of the circle is determined, the maximum inscribed circle of the connected domain can be determined based on the center of the circle.
  • the calculation stop condition is: after the m-1th calculation, there is a pixel with a weight value of 8 (m-1), and after the mth calculation, there is no pixel with a weight of 8*m Point, the pixel point with the largest weight value is determined as the center of the inscribed circle of the connected domain.
  • the inscribed circle based on the center of the circle is the largest inscribed circle of the connected domain.
  • the pixel with the largest weight value can be used as the center of the inscribed circle of the connected domain.
  • one pixel can be arbitrarily selected from the pixels with the largest weight value as the center of the inscribed circle of the connected domain.
  • S204 Obtain the pixel point of the second pixel value closest to the center of the circle from the binarized image, and determine the distance between the obtained pixel point and the center of the circle as the radius of the inscribed circle.
  • the second pixel value is the pixel value of the pixel in the edge of the area of the connected domain. For example, if the area of the connected domain in the binarized image is composed of white pixels, and the edge of the area of the connected domain is composed of black pixels, then the second pixel value is the pixel value of the black pixel, that is, the second pixel value 0.
  • the center of the circle can be used as the starting point, and the pixels are sequentially traversed in the direction of diffusion around until the first pixel of the second pixel value is traversed. It can be considered that the pixel point of the second pixel value traversed for the first time in the binarized image is closest to the center of the circle.
  • the directions of diffusion around left, right, top, bottom, top left, top right, bottom left, bottom right.
  • the center of the circle is a pixel with a weight value of 23.
  • the coordinates of the pixel are (9,7), and the coordinates (9,7) are used as the starting point.
  • the coordinates in the left direction are first traversed as ( 9,6), the coordinate in the right direction is (9,8), the coordinate in the upper direction is (8,7), the coordinate in the lower upward direction is (10,7), the coordinate in the upper left direction is (8,6), the upper right direction Pixels with an upper coordinate of (8,8), a lower left upward coordinate of (10,6), and a lower right upward coordinate of (10,8).
  • the center of the circle can be used as a starting point to sequentially traverse the pixels in the direction of diffusion around. The pixels in each direction are traversed until the pixels with the second pixel value are traversed for the first time in that direction.
  • the directions of diffusion around left, right, top, bottom, top left, top right, bottom left, bottom right.
  • the center of the circle is a pixel with a weight of 23
  • the coordinates of the pixel are (9,7)
  • the coordinates (9,7) are used as starting points, respectively, in the direction of diffusion around Traverse pixels.
  • the pixel value of the pixel is the first pixel value, which is 255, then continue to traverse the coordinates with (9,9 ), and so on, until the pixel point of the second pixel value is traversed for the first time in the right direction, then the pixel point traversal in the right direction is stopped.
  • the pixel point traversed to the second pixel value for the first time in the direction with the least number of traversals is selected as the pixel point of the second pixel value closest to the center of the circle.
  • the distance between the acquired pixel and the center of the circle may be determined as the radius of the inscribed circle in the connected domain. Based on the center and radius, the maximum inscribed circle of the connected domain can be determined.
  • step b after obtaining the weight value of each pixel in the area after the mth calculation, it can be determined whether there is a weight value of 8*m in the pixel inside the area after the mth calculation pixel. If it exists, the weight value of each pixel in the connected domain can be calculated for the (m+1)th time. That is, for each pixel in the area, the sum of the number of the third target pixel adjacent to the pixel and the weight value of the pixel after the mth calculation is calculated as the pixel at the mth The weight value after the +1 calculation, the pixel value of the third target pixel is the first pixel value, and the weight value of the third target pixel after the mth calculation is 8*m.
  • step 203 may be executed to determine the pixel point with the largest weight value after multiple calculations as the center of the inscribed circle of the connected domain in the binarized image.
  • m 3
  • the maximum weight value of the pixels in the area is 23, and the pixel with the weight value of 23 is determined as the center of the inscribed circle of the connected domain.
  • the area of the connected domain in the binarized image is composed of white pixels, and the edge of the area of the connected domain in the binarized image is composed of black pixels, that is, the connected image in the binarized image
  • the pixel value of the pixel in the domain is 255, and the pixel value of the pixel at the edge of the area connected to the domain is 0.
  • the weight value recording image is used for The weight value calculated every time is stored.
  • the pixel value of the pixel at the edge of the area of the connected domain is set to 255
  • the pixel value of the pixel inside the area of the connected domain is set to 0
  • the obtained image is determined as the weight value recording image.
  • each pixel of the image is recorded, and the pixel value of the pixel is the weight value of the pixel at the same position as the pixel in the binary image.
  • the pixel value of each pixel in the image is recorded with the weight value as the weight value of each pixel. That is, the initial weight value of each pixel in the area is 0. For each pixel in the area, the weight value of the pixel obtained after each calculation is stored to the position of the pixel in the weight value recording image.
  • the weight value Since the weight value records the pixel value of each pixel of the image as the weight value of the pixel in the binary image whose position is the same as the position of the pixel, the above calculation will be performed for each pixel within the area every time
  • the weight value of the pixel obtained afterwards is stored to the position of the pixel in the weight value recording image, which can be: for each pixel in the area, the weight value of the pixel obtained after each calculation is used as the weight value Record the pixel value of the pixel in the image.
  • the weight value records the weight value of each pixel in the area of the connected domain of the binarized image in the image, and the weight value records the weight value recorded in the image and the binarized image.
  • the pixels at the same position as the weight value correspond to each other, which is convenient for storing the weight value of each pixel, and obtaining the weight value of each pixel from the weight value recording image.
  • the values in Figure 3(3) are: the weight value of each pixel in the area after the second calculation, then after the second calculation, the weight value of each pixel is stored To the weight value, record the position in the image with the coordinates of the pixel.
  • the weight value 4 of the pixel point with the coordinate (1,1) is stored at the position of the coordinate (1,1) in the weight value recording image, that is, the pixel point with the coordinate (1,1) in the weight value recording image
  • the pixel value of is set to 4
  • the weight value 16 of the pixel point with the coordinate (9,7) is stored at the position of the coordinate (9,7) in the weight value recording image, that is, the coordinate of the weight value recording image is (9, 7)
  • the pixel value of the pixel is set to 16.
  • the weight value record image After performing the mth calculation on the binarized image, the weight value record image stores the weight value of each pixel in the area after the mth calculation. After the m+1th calculation, the weight value of each pixel in the area after the m+1th calculation can be obtained, and when the obtained weight value after the m+1th calculation is stored in the weight value recording image, The overlay weight value records the weight value after the m-th calculation that has been stored in the image.
  • the part of the weight value recording image used to record the weight value is a black pixel area, and the pixel value of the pixels based on this area is 0, which can effectively store the weight value of each pixel in the area to avoid Overflow due to weight value exceeding 255.
  • the stored weight value may be obtained from the weight value recording image, and each obtained weight value may be determined as a pixel point whose position in the binarized image is the same as the storage position of the weight value Weight value.
  • the weight value records the pixel value of each pixel of the image as the weight value of the pixel in the binary image whose position is the same as that of the pixel. Therefore, the above obtains the stored weight value from the weight value recording image, and determines each obtained weight value as the weight value of the pixel in the binary image whose position is the same as the storage position of the weight value, That is: the pixel value of each pixel is obtained from the weight value recording image; for the pixel value of each pixel obtained, the pixel value of the pixel is determined as the position and the pixel in the binary image The weight value of the pixels with the same position.
  • the weight value of each pixel in the area obtained after the last calculation needs to be obtained, and the weight value recorded in the image stores the weight value of each pixel in the area after the last calculation, then The weight value inside the area after the last calculation can be obtained from the weight value recording image.
  • the weight value of each pixel in the area after the second calculation needs to be obtained.
  • the weight value recorded image stores each pixel in the area after the second calculation
  • the weight value of the point can be obtained from the weight value recorded image.
  • the weight value of each pixel in the area after the second calculation, and each weight value obtained is determined as the position and the weight value in the binary image
  • the weight value of the pixels with the same storage location For example, if the weight value stored at the position where the coordinates are (1,1) in the weight value recording image is 4, the weight value 4 is determined as the weight value of the pixel point with the coordinates (1,1) in the binarized image .
  • the number of the first target pixel adjacent to the pixel is determined as the first time
  • the calculated weight value is the sum of the number of the second target pixel point adjacent to the pixel point and the weight value of the pixel point after the m-1th calculation, as the pixel point after the mth calculation Weights.
  • the pixel For the pixels inside the connected domain area, the farther they are from the edge of the area, the greater the number of second target pixels adjacent to the pixel after the m-1th calculation, the pixel’s The larger the weight value. Therefore, the pixel with the larger weight value is closer to the center of the connected domain.
  • the pixel with the largest weight value after multiple calculations is used as the center of the inscribed circle of the connected domain, and then the second closest to the center of the circle is obtained from the binarized image
  • the pixel value of the pixel value, and the distance between the acquired pixel point and the center of the circle is determined as the radius of the inscribed circle.
  • the maximum inscribed circle of the connected domain can be obtained.
  • an embodiment of the present application further provides an apparatus for determining an inscribed circle.
  • the apparatus for determining an inscribed circle includes:
  • the first obtaining module 410 is used to obtain a binarized image.
  • the pixel value of the pixel inside the region of the connected domain is the first pixel value
  • the pixel value of the pixel at the edge of the region of the connected domain is the second.
  • the calculation module 420 is used to perform multiple calculations using the following steps a and b for each pixel in the area to obtain the weight value of each pixel in the area after multiple calculations until the preset calculation stops condition:
  • Step a Calculate the weight value of each pixel in the area after the first calculation: for each pixel in the area, determine the number of the first target pixel adjacent to the pixel as the pixel The weight value after the first calculation, the first target pixel is the pixel whose pixel value is the first pixel value;
  • Step b Calculate the weight value of each pixel in the area after the mth calculation: for each pixel in the area, calculate the number of the second target pixel adjacent to the pixel and the pixel The sum of the weight values after the m-1th calculation is taken as the weight value of the pixel after the mth calculation, the pixel value of the second target pixel is the first pixel value, and the The weight value of the two target pixels is ⁇ (m-1), ⁇ is the maximum number of neighboring pixels that meet the preset neighboring conditions, and m is greater than 1;
  • the first determining module 430 is configured to determine the pixel point with the largest weight value after multiple calculations as the center of the inscribed circle of the connected domain;
  • the second determination module 440 is configured to obtain the pixel point of the second pixel value closest to the center of the circle from the binarized image, and determine the distance between the obtained pixel point and the center of the circle as the radius of the inscribed circle.
  • the calculation stop condition is:
  • the calculation stop condition is: the number of calculations reaches a preset number of thresholds.
  • the inscribed circle determining device may further include:
  • the judgment module is used to judge whether there is a pixel with a weight value of 8*m among the pixels inside the area after the mth calculation; if it exists, each pixel inside the calculation area is calculated at the (m+1)th time After the weight value; if it does not exist, it is determined that the calculation stop condition is satisfied.
  • the device further includes:
  • the setting module is used to set the pixel value of the pixels on the edge of the area to 255, set the pixel value of the pixels inside the area to 0, and determine the obtained image as the weight value recording image;
  • the storage module is used to record the pixel value of each pixel in the image with the weight value as the weight value of each pixel, and for each pixel in the area, the obtained weight value of the pixel after each calculation Record the pixel value of the pixel in the image as a weight value.
  • the inscribed circle determining device may further include:
  • a second obtaining module configured to obtain the stored pixel value of each pixel from the weight value recording image
  • the third determining module is used to determine the pixel value of each pixel as the weight value of the pixel whose position is the same as that of the pixel in the binarized image.
  • the number of the first target pixel adjacent to the pixel is determined as the first time
  • the calculated weight value is the sum of the number of the second target pixel point adjacent to the pixel point and the weight value of the pixel point after the m-1th calculation, as the pixel point after the mth calculation Weights.
  • the pixel For the pixels inside the connected domain area, the farther they are from the edge of the area, the greater the number of second target pixels adjacent to the pixel after the m-1th calculation, the pixel’s The larger the weight value. Therefore, the pixel with the larger weight value is closer to the center of the connected domain.
  • the pixel with the largest weight value after multiple calculations is used as the center of the inscribed circle of the connected domain, and then the second closest to the center of the circle is obtained from the binarized image
  • the pixel value of the pixel value, and the distance between the acquired pixel point and the center of the circle is determined as the radius of the inscribed circle.
  • the maximum inscribed circle of the connected domain can be obtained.
  • an embodiment of the present application further provides an electronic device, as shown in FIG. 5, including a processor 510, a communication interface 520, a memory 530, and a communication bus 540, where the processor 510 The communication interface 520 and the memory 530 complete communication with each other through the communication bus 540;
  • the memory 530 is used to store computer programs
  • the pixel value of the pixels inside the area of the connected domain in the binarized image is the first pixel value
  • the pixel value of the pixel points of the edge of the area of the connected domain is the second pixel value
  • steps a and b are used for multiple calculations to obtain the weight value of each pixel in the area after multiple calculations until the preset calculation stop condition is met:
  • Step a Calculate the weight value of each pixel in the area after the first calculation: for each pixel in the area, determine the number of the first target pixel adjacent to the pixel as the pixel The weight value after the first calculation, the first target pixel is the pixel whose pixel value is the first pixel value;
  • Step b Calculate the weight value of each pixel in the area after the mth calculation: for each pixel in the area, calculate the number of the second target pixel adjacent to the pixel and the pixel The sum of the weight values after the m-1th calculation is the weight value of the pixel after the mth calculation, the pixel value of the second target pixel is the first pixel value, and the The weight value of the two target pixels is ⁇ (m-1), ⁇ is the maximum number of neighboring pixels that meet the preset neighboring conditions, and m is greater than 1;
  • the pixel point of the second pixel value closest to the center of the circle is obtained, and the distance between the obtained pixel point and the center of the circle is determined as the radius of the inscribed circle.
  • the number of the first target pixel adjacent to the pixel is determined as the first time
  • the calculated weight value is the sum of the number of the second target pixel point adjacent to the pixel point and the weight value of the pixel point after the m-1th calculation, as the pixel point after the mth calculation Weights.
  • the pixel For the pixels inside the connected domain area, the farther they are from the edge of the area, the greater the number of second target pixels adjacent to the pixel after the m-1th calculation, the pixel’s The larger the weight value. Therefore, the pixel with the larger weight value is closer to the center of the connected domain.
  • the pixel with the largest weight value after multiple calculations is used as the center of the inscribed circle of the connected domain, and then the second closest to the center of the circle is obtained from the binarized image
  • the pixel value of the pixel value, and the distance between the acquired pixel point and the center of the circle is determined as the radius of the inscribed circle.
  • the maximum inscribed circle of the connected domain can be obtained.
  • the communication bus mentioned in the above electronic equipment may be a peripheral component interconnection standard (Peripheral Component Interconnect, PCI) bus or an extended industry standard structure (Extended Industry Standard Architecture, EISA) bus, etc.
  • PCI peripheral component interconnection standard
  • EISA Extended Industry Standard Architecture
  • the communication bus can be divided into an address bus, a data bus, and a control bus. For ease of representation, only a thick line is used in the figure, but it does not mean that there is only one bus or one type of bus.
  • the communication interface is used for communication between the electronic device and other devices.
  • the memory may include random access memory (Random Access Memory, RAM), or non-volatile memory (Non-Volatile Memory, NVM), for example, at least one disk memory.
  • RAM Random Access Memory
  • NVM Non-Volatile Memory
  • the memory may also be at least one storage device located away from the foregoing processor.
  • the processor can be a general-purpose processor, including a central processor (Central Processing Unit, CPU), a network processor (Network Processor, NP), etc.; it can also be a digital signal processor (Digital Signal Processing, DSP), a dedicated integrated circuit ( Application Specific (Integrated Circuit, ASIC), Field-Programmable Gate Array (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components.
  • CPU Central Processing Unit
  • NP Network Processor
  • DSP Digital Signal Processing
  • ASIC Application Specific
  • FPGA Field-Programmable Gate Array
  • an embodiment of the present application further provides a machine-readable storage medium in which a computer program is stored.
  • the computer program is executed by a processor, any of the above Tangent circle determination method steps.
  • an embodiment of the present application further provides a computer program that implements any of the steps of the method for determining an inscribed circle when the computer program is executed by a processor.

Landscapes

  • Engineering & Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • Computer Vision & Pattern Recognition (AREA)
  • General Physics & Mathematics (AREA)
  • Theoretical Computer Science (AREA)
  • Geometry (AREA)
  • Image Analysis (AREA)

Abstract

An inscribed circle determination method and device. The method comprises: obtaining pixel values of pixel points comprised in a connected domain in a binarized image (S201); for each of the pixel points, performing calculation for n times by using steps a and b to obtain a weight value of each pixel point after the nth calculation (S202); determining, among the pixel points, a pixel point having the maximum weight value after the nth calculation as the center of an inscribed circle of the connected domain (S203); and obtaining a pixel point having a second pixel value closest to the center from the binarized image, and determining the distance between the obtained pixel point and the center as a radius of the inscribed circle (S204). After the center and the radius are determined, a large inscribed circle in the connected domain can be obtained.

Description

一种内切圆确定方法及装置Method and device for determining inscribed circle
本申请要求于2018年12月29日提交中国专利局、申请号为201811636143.6发明名称为“一种内切圆确定方法及装置”的中国专利申请的优先权,其全部内容通过引用结合在本申请中。This application requires the priority of the Chinese patent application filed on December 29, 2018 in the China Patent Office with the application number 201811636143.6 and the invention titled "A method and device for determining an inscribed circle", the entire contents of which are incorporated by reference in this application in.
技术领域Technical field
本申请涉及图像处理技术领域,特别是涉及一种内切圆确定方法及装置。The present application relates to the technical field of image processing, and in particular to a method and device for determining an inscribed circle.
背景技术Background technique
图像中的连通域是指图像中像素值相同且位置相邻的像素点所组成的图像区域。连通域的识别在图像处理中应用较广泛,例如车牌识别、拼图类游戏中轮廓图的绘制等图像处理中均应用了连通域的识别。The connected domain in an image refers to an image area composed of pixels with the same pixel value and adjacent positions in the image. The recognition of connected domains is widely used in image processing. For example, the recognition of connected domains is applied to image processing such as license plate recognition and contour drawing in puzzle games.
尤其在拼图类游戏中,大量使用由白色像素点和黑色像素点组成的轮廓图,玩家将轮廓图中各白色像素点组成的连通域填充上不同的颜色,进而达到将由白色像素点和黑色像素点组成的轮廓图变成彩色填充图的目的。为了便于玩家区分不同连通域,进而为每一连通域填充所需的颜色,游戏制作人员在制作轮廓图时,会在每一白色像素点组成的连通域内添加标识,以标注不同连通域,所采用的标识一般采用圆内加上数值的方式表示,例如,1号连通域内的标识为①。Especially in jigsaw puzzle games, a large number of outlines composed of white pixels and black pixels are used. Players fill the connected domains of each white pixel in the outline with different colors, and then will achieve white pixels and black pixels. The outline drawing made up of points becomes the purpose of the color filled drawing. In order to facilitate players to distinguish between different connected domains, and then fill each connected domain with the required color, the game maker will add a logo to each connected domain composed of white pixels when making the contour map to mark the different connected domains. The mark used is generally expressed by adding a value within the circle. For example, the mark in the connected domain of number 1 is ①.
为了便于玩家更容易找到对应标识,每个连通域内的标识应尽可能大。若连通域内的标识为采用圆内加上数值的方式表示,则连通域内的标识最大时该标识包括的圆为连通域的最大内切圆。因此,如何确定出连通域的最大内切圆是亟待解决的问题。To make it easier for players to find the corresponding logo, the logo in each connected domain should be as large as possible. If the mark in the connected domain is expressed by adding a value to the circle, the circle included in the mark when the mark in the connected domain is the largest is the largest inscribed circle of the connected domain. Therefore, how to determine the maximum inscribed circle of the connected domain is an urgent problem to be solved.
发明内容Summary of the invention
本申请实施例的目的在于提供一种内切圆确定方法及装置,以实现连通域的最大内切圆的确定。具体技术方案如下:The purpose of the embodiments of the present application is to provide a method and a device for determining an inscribed circle, so as to realize the determination of the maximum inscribed circle of a connected domain. The specific technical solutions are as follows:
第一方面,本申请实施例提供了一种内切圆确定方法,所述方法包括:In a first aspect, an embodiment of the present application provides a method for determining an inscribed circle. The method includes:
获取二值化图像,所述二值化图像中连通域的区域内部的像素点的像素值为第一像素值,所述连通域的区域边缘的像素点的像素值为第二像素值;Acquiring a binarized image, in which the pixel value of the pixel inside the area of the connected domain is the first pixel value, and the pixel value of the pixel at the edge of the area of the connected domain is the second pixel value;
针对所述区域内部的每个像素点,采用如下步骤a和步骤b进行多次计算,得到所述区域内部每个像素点在多次计算后的权重值,直至满足预设的计算停止条件:For each pixel in the area, the following steps a and b are used for multiple calculations to obtain the weight value of each pixel in the area after multiple calculations until the preset calculation stop condition is met:
步骤a,计算所述区域内部的每个像素点在第1次计算后的权重值:针对所述区域内部的每个像素点,将该像素点相邻的第一目标像素点的个数确定为该像素点在第1次计算后的权重值,所述第一目标像素点为像素值为第一像素值的像素点;Step a: Calculate the weight value of each pixel inside the area after the first calculation: for each pixel inside the area, determine the number of first target pixels adjacent to the pixel Is the weight value of the pixel after the first calculation, and the first target pixel is a pixel whose pixel value is the first pixel value;
步骤b,计算所述区域内部的每个像素点在第m次计算后的权重值:针对所述区域内部的每个像素点,计算该像素点相邻的第二目标像素点的个数与该像素点在第m-1次计算后的权重值的和,作为该像素点在第m次计算后的权重值,所述第二目标像素点的像素值为所述第一像素值,且第m-1次计算后所述第二目标像素点的权重值为δ(m-1),δ为满足预设相邻条件的相邻像素点的最大个数,m为大于1;Step b: Calculate the weight value of each pixel in the area after the mth calculation: for each pixel in the area, calculate the number of second target pixels adjacent to the pixel and The sum of the weight values of the pixel after the m-1th calculation is used as the weight value of the pixel after the mth calculation, the pixel value of the second target pixel is the first pixel value, and After the m-1 calculation, the weight value of the second target pixel is δ(m-1), where δ is the maximum number of adjacent pixels that satisfy the preset adjacent condition, and m is greater than 1;
将在所述多次计算后权重值最大的像素点确定为所述连通域的内切圆的圆心;Determine the pixel point with the largest weight value after the multiple calculations as the center of the inscribed circle of the connected domain;
从所述二值化图像中,获取与所述圆心距离最近的所述第二像素值的像素点,并将所获取的像素点与所述圆心的距离确定为所述内切圆的半径。From the binarized image, obtain the pixel point of the second pixel value closest to the center of the circle, and determine the distance between the obtained pixel point and the center of the circle as the radius of the inscribed circle.
可选的,所述第一像素值为0,所述第二像素值为255;或所述第一像素值为255,所述第二像素值为0;所述δ=8。Optionally, the first pixel value is 0 and the second pixel value is 255; or the first pixel value is 255 and the second pixel value is 0; and δ=8.
可选的,所述计算停止条件为:Optionally, the calculation stop condition is:
在第m-1次计算后,所述区域内部存在权重值为8(m-1)的像素点,在第m次计算后,所述区域内部不存在权重值为8*m的像素点。After the m-1th calculation, there are pixels with a weight value of 8 (m-1) inside the area, and after the mth calculation, there are no pixels with a weight value of 8*m inside the area.
可选的,所述计算停止条件为:计算次数达到预设次数阈值。Optionally, the calculation stop condition is that: the number of calculations reaches a preset threshold.
可选的,所述计算所述区域内部的每个像素点在第m次计算后的权重值的步骤之后,还包括:Optionally, after the step of calculating the weight value of each pixel in the area after the m-th calculation, the method further includes:
判断第m次计算后所述区域内部的像素点中是否存在权重值为8*m的像素点;Determine whether there is a pixel with a weight value of 8*m among the pixels within the area after the mth calculation;
若存在,则计算所述区域内部的每个像素点在第(m+1)次计算后的权重值;If there is, calculate the weight value of each pixel in the area after the (m+1)th calculation;
若不存在,则确定满足所述计算停止条件。If it does not exist, it is determined that the calculation stop condition is satisfied.
可选的,所述区域内部的像素点的像素值为255,所述区域边缘的像素点的像素值为0;所述方法还包括:Optionally, the pixel value of the pixels inside the area is 255, and the pixel value of the pixels on the edge of the area is 0; the method further includes:
将所述区域边缘的像素点的像素值设置为255,将所述区域内部的像素点的像素值设置为0,将所得到的图像确定为权重值记录图像;Set the pixel value of the pixels on the edge of the area to 255, set the pixel value of the pixels inside the area to 0, and determine the obtained image as the weight value recording image;
以所述权重值记录图像中每一像素点的像素值作为每一像素点的权重值,针对所述区域内部的每个像素点,将得到的该像素点在每一次计算后的权重值作为所述权重值记录图像中该像素点的像素值。Use the weight value to record the pixel value of each pixel in the image as the weight value of each pixel, and for each pixel inside the area, use the obtained weight value of the pixel after each calculation as The weight value records the pixel value of the pixel in the image.
可选的,所述方法还包括:Optionally, the method further includes:
从所述权重值记录图像中获取每一像素点的像素值;Obtaining the pixel value of each pixel from the weight value recording image;
针对所获取的每一像素点的像素值,将该像素点的像素值确定为在所述二值化图像中位置与该像素点的位置相同的像素点的权重值。For each pixel value acquired, the pixel value of the pixel is determined as the weight value of the pixel whose position is the same as the position of the pixel in the binarized image.
第二方面,本申请实施例提供了一种内切圆确定装置,所述装置包括:In a second aspect, an embodiment of the present application provides an inscribed circle determination device, the device including:
第一获取模块,用于获取二值化图像,所述二值化图像中连通域的区域内部的像素点的像素值为第一像素值,所述连通域的区域边缘的像素点的像素值为第二像素值;The first acquisition module is used to acquire a binarized image, the pixel value of the pixels inside the region of the connected domain in the binarized image is the first pixel value, and the pixel value of the pixel at the edge of the region of the connected domain Is the second pixel value;
计算模块,用于针对所述区域内部的每个像素点,采用如下步骤a和步骤b进行多次计算,得到所述区域内部每个像素点在多次计算后的权重值,直至满足预设的计算停止条件:The calculation module is used to perform multiple calculations using the following steps a and b for each pixel in the area to obtain the weight value of each pixel in the area after multiple calculations until the preset value is met The calculation stop condition:
步骤a,计算所述区域内部的每个像素点在第1次计算后的权重值:针对所述区域内部的每个像素点,将该像素点相邻的第一目标像素点的个数确定为该像素点在第1次计算后的权重值,所述第一目标像素点为像素值为第一像素值的像素点;Step a: Calculate the weight value of each pixel inside the area after the first calculation: for each pixel inside the area, determine the number of first target pixels adjacent to the pixel Is the weight value of the pixel after the first calculation, and the first target pixel is a pixel whose pixel value is the first pixel value;
步骤b,计算所述区域内部的每个像素点在第m次计算后的权重值:针对 所述区域内部的每个像素点,计算该像素点相邻的第二目标像素点的个数与该像素点在第m-1次计算后的权重值的和,作为该像素点在第m次计算后的权重值,所述第二目标像素点的像素值为所述第一像素值,且第m-1次计算后所述第二目标像素点的权重值为δ(m-1),δ为满足预设相邻条件的相邻像素点的最大个数,m为大于1;Step b: Calculate the weight value of each pixel in the area after the mth calculation: for each pixel in the area, calculate the number of second target pixels adjacent to the pixel and The sum of the weight values of the pixel after the m-1th calculation is used as the weight value of the pixel after the mth calculation, the pixel value of the second target pixel is the first pixel value, and After the m-1 calculation, the weight value of the second target pixel is δ(m-1), where δ is the maximum number of adjacent pixels that satisfy the preset adjacent condition, and m is greater than 1;
第一确定模块,用于将在所述多次计算后权重值最大的像素点确定为所述连通域的内切圆的圆心;A first determining module, configured to determine the pixel point with the largest weight value after the multiple calculations as the center of the inscribed circle of the connected domain;
第二确定模块,用于从所述二值化图像中,获取与所述圆心距离最近的所述第二像素值的像素点,并将所获取的像素点与所述圆心的距离确定为所述内切圆的半径。A second determining module, configured to obtain the pixel point of the second pixel value closest to the center of the circle from the binarized image, and determine the distance between the obtained pixel point and the center of the circle as the State the radius of the inscribed circle.
可选的,所述第一像素值为0,所述第二像素值为255;或所述第一像素值为255,所述第二像素值为0;所述δ=8。Optionally, the first pixel value is 0 and the second pixel value is 255; or the first pixel value is 255 and the second pixel value is 0; and δ=8.
可选的,所述计算停止条件为:Optionally, the calculation stop condition is:
在第m-1次计算后,所述区域内部存在权重值为8(m-1)的像素点,在第m次计算后,所述区域内部不存在权重值为8*m的像素点。After the m-1th calculation, there are pixels with a weight value of 8 (m-1) inside the area, and after the mth calculation, there are no pixels with a weight value of 8*m inside the area.
可选的,所述计算停止条件为:计算次数达到预设次数阈值。Optionally, the calculation stop condition is that: the number of calculations reaches a preset threshold.
可选的,所述装置还包括:Optionally, the device further includes:
判断模块,用于判断第m次计算后所述区域内部的像素点中是否存在权重值为8*m的像素点;若存在,则计算所述区域内部的每个像素点在第(m+1)次计算后的权重值;若不存在,则确定满足所述计算停止条件。The judging module is used to judge whether there is a pixel with a weight value of 8*m among the pixels inside the area after the mth calculation; if there is, then calculate each pixel within the area at the (m+ 1) The weight value after the calculation; if it does not exist, it is determined that the calculation stop condition is satisfied.
可选的,所述区域内部的像素点的像素值为255,所述区域边缘的像素点的像素值为0;所述装置还包括:Optionally, the pixel value of the pixels inside the area is 255, and the pixel value of the pixels on the edge of the area is 0; the device further includes:
设置模块,用于将所述区域边缘的像素点的像素值设置为255,将所述区域内部的像素点的像素值设置为0,将所得到的图像确定为权重值记录图像;A setting module, configured to set the pixel value of the pixels on the edge of the area to 255, set the pixel value of the pixels inside the area to 0, and determine the obtained image as the weight value recording image;
存储模块,用于以所述权重值记录图像中每一像素点的像素值作为每一像素点的权重值,针对所述区域内部的每个像素点,将得到的该像素点在每一次计算后的权重值作为所述权重值记录图像中该像素点的像素值。The storage module is used to record the pixel value of each pixel in the image with the weight value as the weight value of each pixel, and for each pixel inside the area, calculate the obtained pixel every time The weight value after is used as the weight value to record the pixel value of the pixel in the image.
可选的,所述装置还包括:Optionally, the device further includes:
第二获取模块,用于从所述权重值记录图像中获取所存储的每一像素点的像素值;A second obtaining module, configured to obtain the stored pixel value of each pixel from the weight value recording image;
第三确定模块,用于针对所获取的每一像素点的像素值,将该像素点的像素值确定为在所述二值化图像中位置与该像素点的位置相同的像素点的权重值。The third determining module is used to determine the pixel value of each pixel as the weight value of the pixel whose position is the same as that of the pixel in the binarized image .
第三方面,本申请实施例提供了一种电子设备,包括处理器、通信接口、存储器和通信总线,其中,处理器、通信接口、存储器通过通信总线完成相互间的通信;In a third aspect, an embodiment of the present application provides an electronic device, including a processor, a communication interface, a memory, and a communication bus, where the processor, the communication interface, and the memory complete communication with each other through the communication bus;
存储器,用于存放计算机程序;Memory, used to store computer programs;
处理器,用于执行存储器上所存放的程序时,实现上述任一所述的内切圆确定方法步骤。The processor, when used to execute the program stored in the memory, implements any of the steps of the inscribed circle determination method described above.
第四方面,本申请实施例提供了一种机器可读存储介质,所述机器可读存储介质内存储有计算机程序,所述计算机程序被处理器执行时实现上述任一所述的内切圆确定方法步骤。According to a fourth aspect, an embodiment of the present application provides a machine-readable storage medium in which a computer program is stored, and when the computer program is executed by a processor, any inscribed circle described above is implemented Determine method steps.
第五方面,本申请实施例提供了一种计算机程序,所述计算机程序被处理器执行时实现上述任一所述的内切圆确定方法步骤。According to a fifth aspect, an embodiment of the present application provides a computer program that, when executed by a processor, implements any of the steps of the inscribed circle determination method described above.
本申请实施例提供的技术方案中,针对二值化图像中连通域区域内部的每一像素点,将该像素点相邻的第一目标像素点的个数确定为该像素点在第1次计算后的权重值,计算该像素点相邻的第二目标像素点的个数与该像素点在第m-1次计算后的权重值的和,作为该像素点在第m次计算后的权重值。对于连通域区域内部的像素点,其越靠近区域边缘,在第m-1次计算后,与该像素点相邻的第二目标像素点的个数越少,该像素点的权重值越小,同理,对于连通域区域内部的像素点,其越远离区域边缘,在第m-1次计算后,与该像素点相邻的第二目标像素点的个数越多,该像素点的权重值越大。因此,权重值越大的像素点越靠近连通域的中心。当多次计算后满足预设的计算停止条件时,将多次计算后权重值最大的像素点作为连通域的内切圆的圆心,再从二值化图像中获取与圆心距离最近的第二像素值的像素点,并将所获取的 像素点与圆心的距离确定为内切圆的半径。在确定圆心和半径之后,即可以得到连通域的最大内切圆。In the technical solution provided by the embodiment of the present application, for each pixel in the connected domain region in the binarized image, the number of the first target pixel adjacent to the pixel is determined as the first time The calculated weight value is the sum of the number of the second target pixel point adjacent to the pixel point and the weight value of the pixel point after the m-1th calculation, as the pixel point after the mth calculation Weights. For the pixels inside the connected domain area, the closer it is to the edge of the area, the smaller the number of second target pixels adjacent to the pixel after the m-1th calculation, the smaller the weight value of the pixel In the same way, for the pixels inside the connected domain area, the farther they are from the edge of the area, the greater the number of second target pixels adjacent to the pixel after the m-1th calculation, the pixel’s The larger the weight value. Therefore, the pixel with the larger weight value is closer to the center of the connected domain. When the preset calculation stop condition is met after multiple calculations, the pixel with the largest weight value after multiple calculations is used as the center of the inscribed circle of the connected domain, and then the second closest to the center of the circle is obtained from the binarized image The pixel value of the pixel value, and the distance between the acquired pixel point and the center of the circle is determined as the radius of the inscribed circle. After determining the center and radius of the circle, the maximum inscribed circle of the connected domain can be obtained.
附图说明BRIEF DESCRIPTION
为了更清楚地说明本申请实施例或现有技术中的技术方案,下面将对实施例或现有技术描述中所需要使用的附图作简单地介绍,显而易见地,下面描述中的附图仅仅是本申请的一些实施例,对于本领域普通技术人员来讲,在不付出创造性劳动的前提下,还可以根据这些附图获得其他的附图。In order to more clearly explain the embodiments of the present application or the technical solutions in the prior art, the following will briefly introduce the drawings used in the description of the embodiments or the prior art. Obviously, the drawings in the following description are only These are some embodiments of the present application. For those of ordinary skill in the art, without paying any creative labor, other drawings can be obtained based on these drawings.
图1为本申请实施例提供的内切圆确定方法的一种流程图;FIG. 1 is a flowchart of a method for determining an inscribed circle provided by an embodiment of this application;
图2为本申请实施例提供的内切圆确定方法的一种流程图;2 is a flowchart of a method for determining an inscribed circle provided by an embodiment of the present application;
图3(1)为本申请实施例提供的一种二值化图像;3(1) is a binary image provided by an embodiment of the present application;
图3(2)为本申请实施例提供的二值化图像第1次计算后的示意图;3(2) is a schematic diagram after the first calculation of the binary image provided by the embodiment of the present application;
图3(3)为本申请实施例提供的二值化图像第2次计算后的示意图;FIG. 3(3) is a schematic diagram after the second calculation of the binary image provided by the embodiment of the present application;
图3(4)为本申请实施例提供的二值化图像第3次计算后的示意图;3(4) is a schematic diagram after the third calculation of the binary image provided by the embodiment of the present application;
图4为本申请实施例提供的内切圆确定装置的一种结构示意图;4 is a schematic structural diagram of a device for determining an inscribed circle provided by an embodiment of the present application;
图5为本申请实施例提供的电子设备的一种结构示意图。FIG. 5 is a schematic structural diagram of an electronic device provided by an embodiment of the present application.
具体实施方式detailed description
下面将结合本申请实施例中的附图,对本申请实施例中的技术方案进行清楚、完整地描述,显然,所描述的实施例仅仅是本申请一部分实施例,而不是全部的实施例。基于本申请中的实施例,本领域普通技术人员在没有做出创造性劳动前提下所获得的所有其他实施例,都属于本申请保护的范围。The technical solutions in the embodiments of the present application will be described clearly and completely in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are only a part of the embodiments of the present application, but not all the embodiments. Based on the embodiments in the present application, all other embodiments obtained by a person of ordinary skill in the art without making creative efforts fall within the protection scope of the present application.
为了从连通域内确定出较大内切圆,本申请实施例提供了一种内切圆确定方法及装置,其中,该内切圆确定方法包括:In order to determine a larger inscribed circle from the connected domain, an embodiment of the present application provides a method and a device for determining an inscribed circle, where the method for determining an inscribed circle includes:
获取二值化图像,二值化图像中连通域的区域内部的像素点的像素值为第一像素值,连通域的区域边缘的像素点的像素值为第二像素值;Obtaining a binarized image, the pixel value of the pixels inside the area of the connected domain in the binarized image is the first pixel value, and the pixel value of the pixel points of the edge of the area of the connected domain is the second pixel value;
针对区域内部的每个像素点,采用如下步骤a和步骤b进行多次计算,得到区域内部每个像素点在多次计算后的权重值,直至满足预设的计算停止条 件:For each pixel in the area, the following steps a and b are used for multiple calculations to obtain the weight value of each pixel in the area after multiple calculations until the preset calculation stop condition is met:
步骤a,计算区域内部的每个像素点在第1次计算后的权重值:针对区域内部的每个像素点,将该像素点相邻的第一目标像素点的个数确定为该像素点在第1次计算后的权重值,第一目标像素点为像素值为第一像素值的像素点;Step a: Calculate the weight value of each pixel in the area after the first calculation: for each pixel in the area, determine the number of the first target pixel adjacent to the pixel as the pixel The weight value after the first calculation, the first target pixel is the pixel whose pixel value is the first pixel value;
步骤b,计算区域内部的每个像素点在第m次计算后的权重值:针对区域内部的每个像素点,计算该像素点相邻的第二目标像素点的个数与该像素点在第m-1次计算后的权重值的和,作为该像素点在第m次计算后的权重值,第二目标像素点的像素值为第一像素值,且第m-1次计算后第二目标像素点的权重值为δ(m-1),m为大于1;Step b: Calculate the weight value of each pixel in the area after the mth calculation: for each pixel in the area, calculate the number of the second target pixel adjacent to the pixel and the pixel The sum of the weight values after the m-1th calculation is taken as the weight value of the pixel after the mth calculation, the pixel value of the second target pixel is the first pixel value, and the The weight value of the two target pixels is δ(m-1), m is greater than 1;
将在多次计算后权重值最大的像素点确定为连通域的内切圆的圆心;Determine the pixel point with the largest weight value after multiple calculations as the center of the inscribed circle of the connected domain;
从二值化图像中,获取与圆心距离最近的第二像素值的像素点,并将所获取的像素点与圆心的距离确定为内切圆的半径。From the binarized image, the pixel point of the second pixel value closest to the center of the circle is obtained, and the distance between the obtained pixel point and the center of the circle is determined as the radius of the inscribed circle.
本申请实施例提供的技术方案中,对于连通域区域内部的像素点,其越靠近区域边缘,在第m-1次计算后,与该像素点相邻的第二目标像素点的个数越少,该像素点的权重值越小,同理,对于连通域区域内部的像素点,其越远离区域边缘,在第m-1次计算后,与该像素点相邻的第二目标像素点的个数越多,该像素点的权重值越大。因此,权重值越大的像素点越靠近连通域的中心。当多次计算后满足预设的计算停止条件时,将多次计算后权重值最大的像素点作为连通域的内切圆的圆心,再从二值化图像中获取与圆心距离最近的第二像素值的像素点,并将所获取的像素点与圆心的距离确定为内切圆的半径。在确定圆心和半径之后,即可以得到连通域的最大内切圆。In the technical solution provided by the embodiment of the present application, the closer the pixels in the connected domain region are to the edge of the region, the more the second target pixel adjacent to the pixel after the m-1th calculation Less, the smaller the weight value of the pixel, for the same reason, for the pixel inside the connected domain area, the farther away from the edge of the area, after the m-1th calculation, the second target pixel adjacent to the pixel The greater the number of, the greater the weight value of the pixel. Therefore, the pixel with the larger weight value is closer to the center of the connected domain. When the preset calculation stop condition is met after multiple calculations, the pixel with the largest weight value after multiple calculations is used as the center of the inscribed circle of the connected domain, and then the second closest to the center of the circle is obtained from the binarized image The pixel value of the pixel value, and the distance between the acquired pixel point and the center of the circle is determined as the radius of the inscribed circle. After determining the center and radius of the circle, the maximum inscribed circle of the connected domain can be obtained.
下面首先对本申请实施例提供的一种内切圆确定方法进行介绍,本申请实施例提供了一种内切圆确定方法,如图1所示,包括如下步骤。The following first describes a method for determining an inscribed circle provided by an embodiment of the present application. The embodiment of the present application provides a method for determining an inscribed circle, as shown in FIG. 1, including the following steps.
S101,获取二值化图像,二值化图像中连通域的区域内部的像素点的像素值为第一像素值,连通域的区域边缘的像素点的像素值为第二像素值。S101. Acquire a binarized image. In the binarized image, the pixel value of the pixel inside the region of the connected domain is the first pixel value, and the pixel value of the pixel inside the region of the connected domain is the second pixel value.
其中,上述二值化图像可以是用户自定义的二值化图像,这种情况下,该待处理的图像本身就是二值化的图像。另外,上述二值化图像还可以是彩色图像、灰度图像等非二值化图像经过二值化处理后所得到的图像,这种情 况下,待处理的图像为用户自定义的非二值化图像。The above-mentioned binary image may be a user-defined binary image. In this case, the image to be processed is itself a binary image. In addition, the above-mentioned binarized image may also be an image obtained by binarizing non-binarized images such as color images and grayscale images. In this case, the image to be processed is a user-defined non-binary化image.
本申请实施例中,区域边缘可以认为是连通域的边缘或轮廓。In the embodiment of the present application, the region edge may be regarded as the edge or contour of the connected domain.
S102,针对区域内部的每个像素点,采用如下步骤a和步骤b进行多次计算,得到区域内部每个像素点在多次计算后的权重值,直至满足预设的计算停止条件。S102: For each pixel in the area, perform multiple calculations using the following steps a and b to obtain the weight value of each pixel in the area after multiple calculations until the preset calculation stop condition is satisfied.
步骤a,计算区域内部的每个像素点在第1次计算后的权重值:针对区域内部的每个像素点,将该像素点相邻的第一目标像素点的个数确定为该像素点在第1次计算后的权重值,第一目标像素点为像素值为第一像素值的像素点;Step a: Calculate the weight value of each pixel in the area after the first calculation: for each pixel in the area, determine the number of the first target pixel adjacent to the pixel as the pixel The weight value after the first calculation, the first target pixel is the pixel whose pixel value is the first pixel value;
步骤b,计算区域内部的每个像素点在第m次计算后的权重值:针对区域内部的每个像素点,计算该像素点相邻的第二目标像素点的个数与该像素点在第m-1次计算后的权重值的和,作为该像素点在第m次计算后的权重值,第二目标像素点的像素值为第一像素值,且第m-1次计算后第二目标像素点的权重值为δ(m-1),δ为满足预设相邻条件的相邻像素点的最大个数,m为大于。Step b: Calculate the weight value of each pixel in the area after the mth calculation: for each pixel in the area, calculate the number of the second target pixel adjacent to the pixel and the pixel The sum of the weight values after the m-1th calculation is taken as the weight value of the pixel after the mth calculation, the pixel value of the second target pixel is the first pixel value, and the The weight value of the two target pixels is δ(m-1), where δ is the maximum number of neighboring pixels that satisfy the preset neighboring conditions, and m is greater than.
其中,预设相邻条件可以根据实际需求进行设定。例如,预设相邻条件可以为在左、右、上、下、左上、右上、左下、右下方向上相邻。预设相邻条件也可以为在左、右、上、下下方向上相邻。Among them, the preset neighboring conditions can be set according to actual needs. For example, the preset neighboring condition may be left, right, top, bottom, top left, top right, bottom left, bottom right and top adjacent. The preset neighboring conditions may also be left, right, up, down, up and down.
当预设相邻条件为在左、右、上、下、左上、右上、左下、右下方向上相邻时,δ为8。当预设相邻条件为在左、右、上、下方向上相邻时,δ为4。When the preset adjacent conditions are adjacent in the left, right, upper, lower, upper left, upper right, lower left, and lower right directions, δ is 8. When the preset neighboring condition is neighboring in the left, right, upper and lower directions, δ is 4.
本申请实施例中,预设相邻条件为还可以为其他形式的条件,对此不做具体限定。In the embodiment of the present application, the preset adjacent condition is a condition that can also be other forms, which is not specifically limited.
另外,计算停止条件可以根据实际需求进行设定。例如,计算停止条件可以为:在第m-1次计算后,区域内部存在权重值为8(m-1)的像素点,在第m次计算后,区域内部不存在权重值为8*m的像素点。再例如,计算停止条件可以为:计算次数达到预设次数阈值。In addition, the calculation stop condition can be set according to actual needs. For example, the calculation stop condition may be: after the m-1th calculation, there are pixels with a weight value of 8 (m-1) inside the area, and after the mth calculation, there is no weight value within the area of 8*m Pixels. For another example, the calculation stop condition may be: the number of calculations reaches a preset number of times threshold.
S103,将在多次计算后权重值最大的像素点确定为连通域的内切圆的圆心。S103: Determine the pixel point with the largest weight value after multiple calculations as the center of the inscribed circle of the connected domain.
S104,从二值化图像中,获取与圆心距离最近的第二像素值的像素点, 并将所获取的像素点与圆心的距离确定为内切圆的半径。S104: Obtain the pixel point of the second pixel value closest to the center of the circle from the binary image, and determine the distance between the obtained pixel point and the center of the circle as the radius of the inscribed circle.
本申请实施例提供的技术方案中,对于连通域区域内部的像素点,其越靠近区域边缘,在第m-1次计算后,与该像素点相邻的第二目标像素点的个数越少,该像素点的权重值越小,同理,对于连通域区域内部的像素点,其越远离区域边缘,在第m-1次计算后,与该像素点相邻的第二目标像素点的个数越多,该像素点的权重值越大。因此,权重值越大的像素点越靠近连通域的中心。当多次计算后满足预设的计算停止条件时,将多次计算后权重值最大的像素点作为连通域的内切圆的圆心,再从二值化图像中获取与圆心距离最近的第二像素值的像素点,并将所获取的像素点与圆心的距离确定为内切圆的半径。在确定圆心和半径之后,即可以得到连通域的最大内切圆。In the technical solution provided by the embodiment of the present application, the closer the pixels in the connected domain region are to the edge of the region, the more the second target pixel adjacent to the pixel after the m-1th calculation Less, the smaller the weight value of the pixel, for the same reason, for the pixel inside the connected domain area, the farther away from the edge of the area, after the m-1th calculation, the second target pixel adjacent to the pixel The greater the number of, the greater the weight value of the pixel. Therefore, the pixel with the larger weight value is closer to the center of the connected domain. When the preset calculation stop condition is met after multiple calculations, the pixel with the largest weight value after multiple calculations is used as the center of the inscribed circle of the connected domain, and then the second closest to the center of the circle is obtained from the binarized image The pixel value of the pixel value, and the distance between the acquired pixel point and the center of the circle is determined as the radius of the inscribed circle. After determining the center and radius of the circle, the maximum inscribed circle of the connected domain can be obtained.
本申请实施例中,二值化图像中连通域区域内部的像素点的像素值可以为0,区域边缘的像素点的像素值可以为255,即第一像素值为0,第二像素值为255。二值化图像中区域内部的像素点的像素值也可以为255,区域边缘的像素点的像素值也可以为0,即第一像素值为255,第二像素值为0。下面以δ=8为例,对本申请实施例提供的一种内切圆确定方法进行说明。基于上述情况,本申请实施例还提供了一种内切圆确定方法,如图2所示,包括如下步骤。In the embodiment of the present application, the pixel value of the pixel inside the connected domain region in the binarized image may be 0, and the pixel value of the pixel at the edge of the region may be 255, that is, the first pixel value is 0, and the second pixel value is 255. The pixel value of the pixel inside the area in the binarized image may also be 255, and the pixel value of the pixel at the edge of the area may also be 0, that is, the first pixel value is 255 and the second pixel value is 0. The following uses δ=8 as an example to describe an inscribed circle determination method provided by an embodiment of the present application. Based on the above situation, an embodiment of the present application also provides a method for determining an inscribed circle, as shown in FIG. 2, including the following steps.
S201,获取二值化图像中连通域包括的各像素点的像素值。其中,二值化图像中连通域的区域内部的像素点的像素值为第一像素值,连通域的区域边缘的像素点的像素值为第二像素值。S201. Acquire pixel values of pixels included in the connected domain in the binarized image. In the binarized image, the pixel value of the pixel inside the area of the connected domain is the first pixel value, and the pixel value of the pixel point of the edge of the connected domain is the second pixel value.
二值化图像可以是用户自定义的待处理的图像,这种情况下,该待处理的图像本身就是二值化的图像。另外,二值化图像还可以是彩色图像、灰度图像等非二值化图像经过二值化处理后所得到的图像,这种情况下,非二值化图像是用户自定义的待处理的图像。The binary image may be a user-defined image to be processed. In this case, the image to be processed is itself a binary image. In addition, the binarized image can also be an image obtained by binarizing non-binarized images such as color images and grayscale images. In this case, the non-binarized images are user-defined to be processed image.
本申请实施例提供的内切圆确定方法可以应用于二值化图像中的任一个连通域,即确定二值化图像中任一连通域的内切圆。本申请实施例针对二值化图像中的一个连通域进行说明。像素值相同且相邻的像素点可以形成一个连通域,一个连通域的区域内部包括的像素点的像素值相同。例如,连通域为白色像素点组成,则该连通域的区域内部的各像素点的像素值为255。The method for determining the inscribed circle provided in the embodiment of the present application can be applied to any connected domain in the binarized image, that is, to determine the inscribed circle of any connected domain in the binarized image. The embodiments of the present application describe a connected domain in a binarized image. Adjacent pixels with the same pixel value can form a connected domain. The pixels included in the area of a connected domain have the same pixel value. For example, if the connected domain is composed of white pixels, the pixel value of each pixel in the area of the connected domain is 255.
本申请实施例中,二值化图像中可以包括一个或多个连通域,一个连通域的区域内部的像素点的像素值相同。步骤S201中获取二值化图像中连通域包括的各像素点的像素值,即为获取二值化图像,基于二值化图像中各像素点的像素值可确定出一个或多个连通域。In the embodiment of the present application, the binarized image may include one or more connected domains, and the pixel values in the pixels within the area of one connected domain are the same. In step S201, acquiring the pixel values of each pixel included in the connected domain in the binarized image is to obtain the binarized image, and one or more connected domains can be determined based on the pixel values of each pixel in the binarized image.
S202,针对各像素点中的每个像素点,采用步骤a和步骤b进行n次计算,得到每个像素点在第n次计算后的权重值。S202: For each pixel in each pixel, perform step a and step b to perform n calculations to obtain the weight value of each pixel after the nth calculation.
上述各像素点为连通域的区域内部的像素点。区域内部的每个像素点的权重值进行迭代计算,n为满足预设的计算停止条件的计算的次数,n为大于1的正整数。因此,上述步骤S102即为针对区域内部的每个像素点,采用步骤a和步骤b进行n次计算,得到该像素点在多次计算后的权重值,直至满足预设的计算停止条件。本申请实施例中,第i次计算表示第i次像素点的权重值计算,i为正整数。本申请实施例中,第i次计算后像素点的权重值即为像素点在第i次计算后的权重值。The above-mentioned pixels are pixels in the area of the connected domain. The weight value of each pixel in the area is iteratively calculated, n is the number of calculations that satisfy the preset calculation stop condition, and n is a positive integer greater than 1. Therefore, the above step S102 is to perform step a and step b for n times of calculation for each pixel in the area to obtain the weight value of the pixel after multiple calculations until the preset calculation stop condition is satisfied. In the embodiment of the present application, the i-th calculation represents the calculation of the weight value of the i-th pixel, i is a positive integer. In the embodiment of the present application, the weight value of the pixel after the i-th calculation is the weight value of the pixel after the i-th calculation.
对于一个连通域内的每一个像素点来说,计算权重值的方式相同。基于此,本申请实施例提供的权重值的计算方式针对一个像素点进行说明。For each pixel in a connected domain, the way to calculate the weight value is the same. Based on this, the calculation method of the weight value provided by the embodiment of the present application is described for one pixel.
步骤a,计算区域内部的每个像素点在第1次计算后的权重值。具体的,针对区域内部的每个像素点,将该像素点相邻的第一目标像素点的个数确定为该像素点在第1次计算后的权重值。第一目标像素点的像素值为第一像素值,即第一目标像素点为区域内部的像素点。Step a: Calculate the weight value of each pixel in the area after the first calculation. Specifically, for each pixel inside the area, the number of the first target pixel adjacent to the pixel is determined as the weight value of the pixel after the first calculation. The pixel value of the first target pixel is the first pixel value, that is, the first target pixel is the pixel inside the area.
其中,在预设相邻条件为在左、右、上、下、左上、右上、左下、右下方向上相邻的情况下,一个像素点相邻的像素点最多可以有8个,即δ=8。以图3(1)为例,图3(1)为二值化图像,图3(1)中每一个方框表示一个像素点,其中黑框表示像素值为0的像素点,白框表示像素值为255的像素点。白框组成的区域为连通域的区域内部。对于坐标为(1,1)的像素点来说,相邻的像素点有3个,而对于坐标为(2,2)的像素点来说,相邻的像素点有8个。其中,(1,1)表示第一行第一列的坐标,(2,2)表示第二行第二列的坐标,本申请实施例中像素点的坐标均可以这样表示,此后不再赘述。In the case where the preset neighboring conditions are left, right, upper, lower, upper left, upper right, lower left, and lower right upward, there can be up to 8 pixels adjacent to a pixel, that is, δ= 8. Taking Figure 3(1) as an example, Figure 3(1) is a binary image. Each box in Figure 3(1) represents a pixel, where black boxes represent pixels with a pixel value of 0, and white boxes represent Pixels with a pixel value of 255. The area formed by the white frame is inside the area of the connected domain. For a pixel with coordinates (1,1), there are 3 adjacent pixels, and for a pixel with coordinates (2,2), there are 8 adjacent pixels. Among them, (1,1) represents the coordinates of the first row and the first column, (2,2) represents the coordinates of the second row and the second column, the coordinates of the pixel points in the embodiments of the present application can be expressed in this way, and will not be described hereafter. .
在获取到二值化图像之后,计算区域内部的每个像素点在第1次计算后的 权重值。具体的,对于区域内部的每一像素点来说,可以统计该像素点相邻的像素点中第一像素值的像素点的个数,即统计该像素点相邻的第一目标像素点的个数。其中,第一像素值为该区域内部的像素点的像素值。例如,如图3(1)所示,白框组成的连通域的区域内部中像素点的像素值为255,则第一像素值为255。当连通域的区域内部为由黑框组成时,则该连通域中像素点的像素值为0,则第一像素值为0。After acquiring the binarized image, calculate the weight value of each pixel in the area after the first calculation. Specifically, for each pixel in the area, the number of pixels with the first pixel value in the pixels adjacent to the pixel can be counted, that is, the number of the first target pixel adjacent to the pixel can be counted. Number. The first pixel value is the pixel value of the pixel inside the area. For example, as shown in FIG. 3(1), the pixel value of the pixels in the area of the connected domain composed of white frames is 255, and the first pixel value is 255. When the interior of the connected domain is composed of black frames, the pixel value of the pixel in the connected domain is 0, and the first pixel value is 0.
针对连通域的区域内部的每一像素点来说,在统计出该像素点相邻的第一目标像素点的个数之后,可以将所统计的个数确定为该像素点在第1次计算后的权重值。这样,区域内部的每一像素点均对应有一个第1次计算后的权重值。For each pixel in the area of the connected domain, after counting the number of the first target pixel adjacent to the pixel, the counted number can be determined as the first calculation of the pixel Weight value. In this way, each pixel in the area corresponds to a weight value after the first calculation.
以图3(1)所示的二值化图像为例,连通域内的像素点的像素值为255,即区域内部的像素点为白色像素点,则第一像素值为255。针对图3(1)中的每一个像素值为255的像素点,统计该像素点相邻的像素点中像素值为255的像素点个数,将统计得到的个数确定为该像素点在第1次计算后的权重值。在第1次计算之后,所得到的像素值为255的各像素点的权重值,即所得到的区域内部各像素点的权重值,如图3(2)所示。比如,坐标为(1,1)的像素点的权重值为3,坐标为(1,2)的像素点的权重值为5,坐标为(2,2)的像素点的权重值为8。Taking the binary image shown in FIG. 3(1) as an example, the pixel value of the pixels in the connected domain is 255, that is, the pixels in the area are white pixels, and the first pixel value is 255. For each pixel with a pixel value of 255 in Figure 3(1), the number of pixels with a pixel value of 255 among the pixels adjacent to the pixel is counted, and the counted number is determined to be the pixel at The weight value after the first calculation. After the first calculation, the weight value of each pixel obtained with a pixel value of 255, that is, the weight value of each pixel within the obtained area, is shown in FIG. 3(2). For example, a pixel with coordinates (1,1) has a weight value of 3, a pixel with coordinates (1,2) has a weight value of 5, and a pixel with coordinates (2,2) has a weight value of 8.
步骤a是针对第1次计算的。当完成步骤a之后,即可以得到区域内部各像素点在第1次计算后的权重值。Step a is calculated for the first time. After step a is completed, the weight value of each pixel in the area after the first calculation can be obtained.
步骤b,计算区域内部的每个像素点在第m次计算后的权重值。具体的,针对区域内部的每个像素点,计算该像素点相邻的第二目标像素点的个数与该像素点在第m-1次计算后的权重值的和值,作为该像素点在第m次计算后的权重值。其中,第二目标像素点的像素值为第一像素值,即第二子目标像素点为区域内部的像素点,另外,第二目标像素点在第m-1次计算后的权重值为8(m-1),m为大于1。这里,第二子目标像素点和第一子目标像素点可以统称为第一目标像素点。Step b: Calculate the weight value of each pixel in the area after the mth calculation. Specifically, for each pixel in the area, the sum of the number of the second target pixel adjacent to the pixel and the weight value of the pixel after the m-1th calculation is used as the pixel The weight value after the mth calculation. Among them, the pixel value of the second target pixel is the first pixel value, that is, the second sub-target pixel is the pixel inside the area, and the weight value of the second target pixel after the m-1th calculation is 8 (m-1), m is greater than 1. Here, the second sub-target pixel point and the first sub-target pixel point may be collectively referred to as a first target pixel point.
在完成第1次计算之后,在第1次计算得到的权重值的基础上,继续进行迭代计算,基于每一次计算的结果,可以对区域内部的各像素点的权重值进 行更新,直至预设的计算停止条件。After the first calculation is completed, on the basis of the weight value obtained in the first calculation, iterative calculation is continued. Based on the result of each calculation, the weight value of each pixel in the area can be updated until the preset The calculation stop condition.
从第2次计算开始,区域内部的各像素点在上一次计算后的权重值已知。因此,从第2次计算开始,针对区域内部的每一像素点的权重值的每一次计算,可参考该像素点相邻的像素点在上一次计算后的权重值。以第m次计算为例,区域内部的各像素点在第m-1次计算后的权重值已知,可以参考在第m-1次计算后区域内部的各像素点的权重值,计算区域内部的各像素点在第m次计算后的权重值。From the second calculation, the weight value of each pixel in the area after the last calculation is known. Therefore, from the second calculation, for each calculation of the weight value of each pixel inside the area, the weight value of the pixel adjacent to the pixel after the previous calculation can be referred to. Taking the mth calculation as an example, the weight value of each pixel in the area after the m-1 calculation is known. You can refer to the weight value of each pixel in the area after the m-1 calculation to calculate the area The weight value of each pixel in the mth calculation.
例如,当m为2时,区域内部的各像素点在第1次计算后的权重值已知,如图3(2)所示,图3(2)所示的为第1次计算后的各像素点的权重值,图3(2)中每个白框内的数值为该白框表示的像素点的权重值。可参考区域内部的各像素点在第1次计算后的权重值,计算区域内部的各像素点在第2次计算后的权重值。For example, when m is 2, the weight value of each pixel in the area after the first calculation is known, as shown in Figure 3(2), and Figure 3(2) shows the weight value after the first calculation For the weight value of each pixel, the value in each white frame in FIG. 3(2) is the weight value of the pixel indicated by the white frame. You can refer to the weight value of each pixel in the area after the first calculation, and calculate the weight value of each pixel in the area after the second calculation.
在进行第m次计算时,针对区域内部的每一像素点,可以确定该像素点相邻的像素点中第二目标像素点的个数。When performing the m-th calculation, for each pixel in the area, the number of second target pixels among the pixels adjacent to the pixel can be determined.
例如,当m为2时,第二目标像素点的权重值为8(2-1)=8。以图3(2)为例,图3(2)所示的为第一次计算后区域内部的各像素点的权重值。基于图3(2)所示,可以确定区域内部每个像素点相邻的像素点中第1次计算后的权重值为8的像素点的个数。比如,第1次计算后,坐标为(1,1)的像素点相邻的像素点中权重值为8的像素点有坐标为(2,2)的像素点,也就是,坐标为(1,1)的像素点相邻的像素点中权重值为8的像素点的个数为1。再比如,坐标(1,3)像素点相邻的像素点中权重值为8的像素点有坐标为(2,2)、(2,3)、(2,4)的像素点,也就是,坐标为(1,3)的像素点相邻的像素点中权重值为8的像素点的个数为3。For example, when m is 2, the weight value of the second target pixel is 8(2-1)=8. Taking FIG. 3(2) as an example, FIG. 3(2) shows the weight value of each pixel in the area after the first calculation. Based on FIG. 3(2), the number of pixels with a weight value of 8 after the first calculation among pixels adjacent to each pixel in the area can be determined. For example, after the first calculation, pixels with a weight value of 8 among pixels adjacent to the pixel with coordinates (1,1) have pixels with coordinates (2,2), that is, with coordinates (1 ,1) The number of pixels with a weight value of 8 among the pixels adjacent to the pixel is 1. As another example, the pixels with a weight value of 8 among the pixels adjacent to the pixel with coordinates (1,3) have pixels with coordinates (2,2), (2,3), (2,4), that is , The number of pixels with a weight value of 8 among the pixels adjacent to the pixel with coordinates (1, 3) is 3.
针对区域内部的每个像素点,在确定出该像素点相邻的第二目标像素点的个数之后,可以计算所确定的个数与该像素点在第m-1次计算后的权重值的和。以图3(2)为例,对于坐标为(1,1)的像素点,该像素点第1次计算后的权重值为3,所确定的该像素点相邻的第二目标像素点的个数为1个,则所得到的和值为3+1=4。For each pixel in the area, after determining the number of the second target pixel adjacent to the pixel, the determined number and the weight value of the pixel after the m-1th calculation can be calculated And. Taking FIG. 3(2) as an example, for a pixel with coordinates (1,1), the weight of the pixel after the first calculation is 3, and the determined second target pixel adjacent to the pixel If the number is one, the obtained sum value is 3+1=4.
针对区域内部的每个像素点,将所得到的该像素点对应的上述和确定为该像素点在第m次计算后的权重值。在完成第m次计算之后,区域内部各像素点的权重值均为第m次计算后的权重值。For each pixel in the area, the obtained sum corresponding to the pixel is determined as the weight value of the pixel after the mth calculation. After the mth calculation is completed, the weight value of each pixel in the area is the weight value after the mth calculation.
例如,当m为2时,第1次计算后的各像素点的权重值如图3(2)所示,第二目标像素点的权重值为8(2-1)=8。针对图3(2)中区域内部的每个像素点,确定该像素点相邻的像素点中权重值为8的像素点个数,并将所确定的个数与该像素点在第1次计算后的权重值相加,所得到的和即为该像素点在第2次计算后的权重值。相应于图3(2),第2次计算后区域内部各像素点的权重值如图3(3)所示。For example, when m is 2, the weight value of each pixel after the first calculation is shown in FIG. 3(2), and the weight value of the second target pixel is 8(2-1)=8. For each pixel inside the area in Fig. 3(2), determine the number of pixels with a weight value of 8 among the pixels adjacent to the pixel, and match the determined number with the pixel in the first time The calculated weight values are added, and the obtained sum is the weight value of the pixel after the second calculation. Corresponding to FIG. 3(2), the weight value of each pixel in the area after the second calculation is shown in FIG. 3(3).
以坐标为(1,1)的像素点为例,在图3(2)中,与该像素点相邻的像素点中权重值为8的像素点的个数为1个,且第1次计算后坐标为(1,1)的像素点在第1次计算后的权重值为3,则在第2次计算后该像素点的权重值为1+3=4。Taking the pixel with coordinates (1,1) as an example, in FIG. 3(2), the number of pixels with a weight value of 8 among the pixels adjacent to the pixel is 1, and the first time After the calculation, the pixel with the coordinate of (1,1) has a weight value of 3 after the first calculation, and then the weight value of the pixel after the second calculation is 1+3=4.
再以坐标为(2,2)的像素点为例,在图3(2)中,与该像素点相邻的像素点中权重值为8的像素点的个数为3个,且第1次计算后坐标为(2,2)的像素点在第1次计算后的权重值为8,则在第2次计算后该像素点的权重值为3+8=11。Taking the pixel with coordinates (2, 2) as an example, in FIG. 3 (2), the number of pixels with a weight value of 8 among the pixels adjacent to the pixel is 3, and the first After the second calculation, the pixel with the coordinate of (2, 2) has a weight value of 8 after the first calculation, and then the pixel has a weight value of 3+8=11 after the second calculation.
在上述步骤b中,m为大于1。第m次计算后满足预设的计算停止条件,不再进行下一次计算。例如,在第3次计算后满足预设的计算停止条件,结束区域内部各像素点的权重值的计算。In the above step b, m is greater than 1. After the mth calculation, the preset calculation stop condition is met, and the next calculation is not performed. For example, after the third calculation, the preset calculation stop condition is satisfied, and the calculation of the weight value of each pixel in the area is ended.
其中,计算停止条件可以是自定义设定的。在每一次计算结束后,可以判断当前的条件是否达到设定的计算停止条件,当判定未达到计算停止条件时则进入下一次计算,当判定达到计算停止条件时则停止计算,不再进行下一次计算。Among them, the calculation stop condition can be customized. After each calculation is completed, you can determine whether the current condition reaches the set calculation stop condition. When it is determined that the calculation stop condition is not reached, the next calculation is entered. When the determination is reached, the calculation is stopped and the process is not performed. Calculate once.
一种实施方式中,计算停止条件为:在第m-1次计算后,区域内部的各像素点中存在权重值为8(m-1)的像素点,在第m次计算后,区域内部的各像素点中不存在权重值为8*m的像素点。In one embodiment, the calculation stop condition is: after the m-1th calculation, there are pixels with a weight value of 8 (m-1) in each pixel inside the area, and after the mth calculation, inside the area There is no pixel with a weight value of 8*m in each pixel of.
第m-1次计算后可以得出区域内部各像素点的权重值,并且在所得到的权重值中存在8(m-1)的权重值,则在进行第m次计算时,针对区域内部每一像素点,统计该像素点相邻的像素点中在第n-1次计算后权重值为8(m-1)的像 素点的个数,计算所统计的个数与该像素点在第m-1次计算后的权重值的和值,将得到的和值确定为该像素点在第m次计算后的权重值。After the m-1th calculation, the weight value of each pixel in the area can be obtained, and there is a weight value of 8(m-1) in the obtained weight value. For each pixel, count the number of pixels with a weight value of 8 (m-1) after the n-1th calculation among the pixels adjacent to the pixel. Calculate the number of statistics and the pixel at The sum of the weight values after the m-1th calculation, and the obtained sum is determined as the weight value of the pixel after the mth calculation.
在完成第m次计算后,若所得到的区域内部各像素点中不存在权重值为8*m的像素点,无法对第m次计算后的权重值进行更新,停止像素点的权重值计算,不再进行第m+1次计算。After the mth calculation is completed, if there is no pixel with a weight value of 8*m in each pixel in the obtained area, the weight value after the mth calculation cannot be updated, and the weight value calculation of the pixel is stopped , The m+1th calculation is no longer performed.
例如,当m为3时,第m-1次计算即为第2次计算,第2次计算后区域内部各像素点的权重值如图3(3)所示,第2次计算后,区域内部像素点中存在权重值为2*8=16的像素点,则可以进行第3次计算。在第3次计算时,针对图3(3)中区域内部的每个像素点,确定该像素点相邻的像素点中权重值为16的像素点的个数,并将所确定的个数与该像素点第2次计算后的权重值相加,所得到的和即为第3次计算后该像素点的权重值。相应于图3(3),第3次计算后区域内部各像素点的权重值如图3(4)所示,第3次计算后,区域内部像素点中不存在权重值为3*8=24的像素点,则不再进行第4次计算。For example, when m is 3, the m-1 calculation is the second calculation. The weight value of each pixel in the area after the second calculation is shown in Figure 3(3). After the second calculation, the area If there are pixels with a weight value of 2*8=16 in the internal pixels, the third calculation can be performed. In the third calculation, for each pixel in the area in FIG. 3(3), determine the number of pixels with a weight value of 16 among the pixels adjacent to the pixel, and set the determined number It is added to the weight value of the pixel after the second calculation, and the obtained sum is the weight value of the pixel after the third calculation. Corresponding to FIG. 3(3), the weight value of each pixel in the area after the third calculation is shown in FIG. 3(4). After the third calculation, there is no weight value of 3*8= For 24 pixels, the fourth calculation is no longer performed.
另一种实施方式中,计算停止条件为:计算次数达到预设次数阈值。当计算次数达到预设次数阈值时不再进行下一次计算。In another embodiment, the calculation stop condition is that the number of calculations reaches a preset number of thresholds. When the number of calculations reaches the preset number of thresholds, the next calculation is not performed.
例如,该预设次数阈值为n。当计算次数达到n次时不再进行第n+1次计算。其中,预设次数阈值可以是自定义设定的。例如,预设次数阈值为30次,当m为30时即计算次数达到30次时,则不再进行第31次计算。For example, the preset number of times threshold is n. When the number of calculations reaches n times, the n+1th calculation is no longer performed. Wherein, the preset number of times threshold can be customized. For example, the preset number of times threshold is 30 times. When m is 30, that is, when the number of calculations reaches 30 times, the 31st calculation is no longer performed.
S203,将各像素点中在第n次计算后的权重值最大的像素点,确定为连通域的内切圆的圆心。S203: Determine the pixel with the largest weight value after the n-th calculation among the pixels as the center of the inscribed circle of the connected domain.
S203中各像素点为区域内部的像素点。因此,S203可以认为是,将多次计算后权重值最大的像素点确定为连通域的内切圆的圆心。Each pixel in S203 is a pixel within the area. Therefore, S203 can be considered as determining the pixel point with the largest weight value after multiple calculations as the center of the inscribed circle of the connected domain.
在完成多次计算后,可以得到连通域内各像素点在多次计算后的权重值。本申请实施例中,像素点的权重值越大表示在该像素点周围第一像素值的像素点越多。例如,在第1次计算后像素点的权重值为8表示该像素点相邻的8个像素点均为第一像素值的像素点。After completing multiple calculations, the weight value of each pixel in the connected domain after multiple calculations can be obtained. In the embodiment of the present application, a larger weight value of a pixel indicates that there are more pixels with a first pixel value around the pixel. For example, after the first calculation, the weight value of the pixel point is 8 indicating that the eight adjacent pixel points of the pixel point are all pixels with the first pixel value.
基于此,在第多次计算后所得到的权重值中,权重值最大的像素点周围的第一像素值的像素点最多。也就是,对于区域内部像素点,其越靠近区域 边缘,在多次计算后,与该像素点相邻的第一像素值的像素点的个数越少,该像素点的权重值越小,而对于区域内部像素点,其越远离区域边缘,在多次计算后,与该像素点相邻的第一像素值的像素点的个数越多,该像素点的权重值越大。因此,权重值越大的像素点越靠近连通域的中心。可以将多次计算后权重值最大的像素点确定为连通域的内切圆的圆心。在确定圆心后,基于该圆心可以确定连通域的最大内切圆。Based on this, among the weight values obtained after the multiple calculations, the pixels with the first pixel value around the pixel with the largest weight value have the most pixels. That is, for the pixels within the region, the closer they are to the edge of the region, after multiple calculations, the fewer the pixels of the first pixel value adjacent to the pixel, the smaller the weight value of the pixel, As for the pixels in the area, the farther they are from the edge of the area, the more pixel numbers of the first pixel value adjacent to the pixel after multiple calculations, the greater the weight value of the pixel. Therefore, the pixel with the larger weight value is closer to the center of the connected domain. The pixel with the largest weight value after multiple calculations can be determined as the center of the inscribed circle of the connected domain. After the center of the circle is determined, the maximum inscribed circle of the connected domain can be determined based on the center of the circle.
若计算停止条件为:在第m-1次计算后,区域内部存在权重值为8(m-1)的像素点,在第m次计算后,区域内部不存在权重值为8*m的像素点,则将权重值最大的像素点确定为连通域的内切圆的圆心。基于该圆心的内切圆是该连通域的最大内切圆。If the calculation stop condition is: after the m-1th calculation, there is a pixel with a weight value of 8 (m-1), and after the mth calculation, there is no pixel with a weight of 8*m Point, the pixel point with the largest weight value is determined as the center of the inscribed circle of the connected domain. The inscribed circle based on the center of the circle is the largest inscribed circle of the connected domain.
以图3(4)中右上角的连通域为例,在第3次计算后该连通域内不存在权重值为24的像素点,由图3(4)中可知最大权重值为23,则可以将权重值为23的像素点作为该连通域的内切圆的圆心,且基于该圆心的内切圆为图3(4)中连通域的最大内切圆。Taking the connected domain in the upper right corner of Figure 3(4) as an example, there are no pixels with a weight value of 24 in the connected domain after the third calculation. From Figure 3(4), it can be seen that the maximum weight value is 23, then you can The pixel point with a weight value of 23 is taken as the center of the inscribed circle of the connected domain, and the inscribed circle based on the center of the circle is the largest inscribed circle of the connected domain in FIG. 3(4).
若在多次计算后连通域内权重值最大的像素点有一个,则可以将该权重值最大的像素点作为连通域的内切圆的圆心。If there is one pixel with the largest weight value in the connected domain after multiple calculations, the pixel with the largest weight value can be used as the center of the inscribed circle of the connected domain.
若在多次计算后权重值最大的像素点有多个,可以从该多个权重值最大的像素点中任意选取一个像素点作为连通域的内切圆的圆心。If there are multiple pixels with the largest weight value after multiple calculations, one pixel can be arbitrarily selected from the pixels with the largest weight value as the center of the inscribed circle of the connected domain.
S204,从二值化图像中获取与圆心距离最近的第二像素值的像素点,并将所获取的像素点与圆心的距离确定为内切圆的半径。S204: Obtain the pixel point of the second pixel value closest to the center of the circle from the binarized image, and determine the distance between the obtained pixel point and the center of the circle as the radius of the inscribed circle.
其中,第二像素值为连通域的区域边缘中像素点的像素值。例如,二值化图像中连通域的区域内部为由白色像素点组成,连通域的区域边缘为由黑色像素点组成,则第二像素值为黑色像素点的像素值,即第二像素值为0。The second pixel value is the pixel value of the pixel in the edge of the area of the connected domain. For example, if the area of the connected domain in the binarized image is composed of white pixels, and the edge of the area of the connected domain is composed of black pixels, then the second pixel value is the pixel value of the black pixel, that is, the second pixel value 0.
在确定圆心后,基于该圆心,从二值化图像中寻找与该圆心距离最近的第二像素值的像素点。After determining the center of the circle, based on the center of the circle, find the pixel point of the second pixel value closest to the center of the circle from the binarized image.
一种实现方式中,可以以圆心作为起始点,同时向四周扩散的方向上依次遍历像素点,直至第一次遍历到第二像素值的像素点。可以认为,在二值化图像中第一次遍历到的第二像素值的像素点与圆心距离最近。In one implementation, the center of the circle can be used as the starting point, and the pixels are sequentially traversed in the direction of diffusion around until the first pixel of the second pixel value is traversed. It can be considered that the pixel point of the second pixel value traversed for the first time in the binarized image is closest to the center of the circle.
例如,四周扩散的方向包括:左、右、上、下、左上、右上、左下、右下。以图3(4)为例,圆心为权重值为23的像素点,该像素点的坐标为(9,7),以坐标(9,7)作为起始点,先遍历左方向上坐标为(9,6)、右方向上坐标为(9,8)、上方向上坐标为(8,7)、下方向上坐标为(10,7)、左上方向上坐标为(8,6)、右上方向上坐标为(8,8)、左下方向上坐标为(10,6)、右下方向上坐标为(10,8)的像素点。若遍历到的8个像素点中不存在第二像素值的像素点,则继续在左、右、上、下、左上、右上、左下、右下这8个方向上遍历第二像素值的像素点,直至第一次遍历到第二像素值的像素点。For example, the directions of diffusion around: left, right, top, bottom, top left, top right, bottom left, bottom right. Taking Figure 3(4) as an example, the center of the circle is a pixel with a weight value of 23. The coordinates of the pixel are (9,7), and the coordinates (9,7) are used as the starting point. The coordinates in the left direction are first traversed as ( 9,6), the coordinate in the right direction is (9,8), the coordinate in the upper direction is (8,7), the coordinate in the lower upward direction is (10,7), the coordinate in the upper left direction is (8,6), the upper right direction Pixels with an upper coordinate of (8,8), a lower left upward coordinate of (10,6), and a lower right upward coordinate of (10,8). If there are no pixels of the second pixel value among the 8 traversed pixels, continue to traverse the pixels of the second pixel value in the eight directions of left, right, up, down, top left, top right, bottom left, and bottom right Point until the pixel point of the second pixel value is traversed for the first time.
另一种实现方式中,可以以圆心作为起始点,分别向四周扩散的方向上依次遍历像素点。每一方向上像素点遍历,直至在该方向上第一次遍历到第二像素值的像素点为止。In another implementation manner, the center of the circle can be used as a starting point to sequentially traverse the pixels in the direction of diffusion around. The pixels in each direction are traversed until the pixels with the second pixel value are traversed for the first time in that direction.
例如,四周扩散的方向包括:左、右、上、下、左上、右上、左下、右下。以图3(4)为例,圆心为权重值为23的像素点,该像素点的坐标为(9,7),以坐标(9,7)作为起始点,分别向四周扩散的方向上依次遍历像素点。例如,在右方向上依次进行像素点遍历,先遍历坐标为(9,8)的像素点,该像素点的像素值为第一像素值,即为255,则继续遍历坐标为(9,9)的像素点,以此类推,直至在右方向上第一次遍历到第二像素值的像素点,则停止右方向上像素点遍历。For example, the directions of diffusion around: left, right, top, bottom, top left, top right, bottom left, bottom right. Taking Figure 3(4) as an example, the center of the circle is a pixel with a weight of 23, the coordinates of the pixel are (9,7), and the coordinates (9,7) are used as starting points, respectively, in the direction of diffusion around Traverse pixels. For example, in order to traverse pixels in the right direction, first traverse the pixel with coordinates (9,8), the pixel value of the pixel is the first pixel value, which is 255, then continue to traverse the coordinates with (9,9 ), and so on, until the pixel point of the second pixel value is traversed for the first time in the right direction, then the pixel point traversal in the right direction is stopped.
在每一方向上均遍历完成后,选择在遍历次数最少的方向上第一次遍历到第二像素值的像素点,作为与该圆心距离最近的第二像素值的像素点。After the traversal in each direction is completed, the pixel point traversed to the second pixel value for the first time in the direction with the least number of traversals is selected as the pixel point of the second pixel value closest to the center of the circle.
在获取到与圆心距离最近的第二像素值的像素点之后,可以将所获取的像素点与圆心的距离确定为连通域中内切圆的半径。基于圆心和半径,即可以确定出连通域的最大内切圆。After acquiring the pixel point of the second pixel value closest to the center of the circle, the distance between the acquired pixel and the center of the circle may be determined as the radius of the inscribed circle in the connected domain. Based on the center and radius, the maximum inscribed circle of the connected domain can be determined.
一种实施方式中,针对于上述步骤b,在得到第m次计算后区域内部各像素点的权重值之后,可以判断第m次计算后区域内部像素点中是否存在权重值为8*m的像素点。若存在,则可以对连通域中的各像素点的权重值进行第(m+1)次计算。也就是,针对区域内部的每个像素点,计算该像素点相邻的第三目标像素点的个数与该像素点在第m次计算后的权重值的和,作为该像素点在第m+1次计算后的权重值,第三目标像素点的像素值为第一像素值,且第m次计 算后第三目标像素点的权重值为8*m。In one embodiment, for step b, after obtaining the weight value of each pixel in the area after the mth calculation, it can be determined whether there is a weight value of 8*m in the pixel inside the area after the mth calculation pixel. If it exists, the weight value of each pixel in the connected domain can be calculated for the (m+1)th time. That is, for each pixel in the area, the sum of the number of the third target pixel adjacent to the pixel and the weight value of the pixel after the mth calculation is calculated as the pixel at the mth The weight value after the +1 calculation, the pixel value of the third target pixel is the first pixel value, and the weight value of the third target pixel after the mth calculation is 8*m.
以图3(3)为例,m为2,在第2次计算后区域内部的像素点中存在权重值为8*2=16的像素点,则可以继续进行第3次计算,即针对区域内部的每个像素点,计算该像素点相邻的权重值为16的像素点的个数与该像素点在第2次计算后的权重值的和值,作为第3次计算后该像素点的权重值。Taking Figure 3(3) as an example, m is 2, and there are pixels with a weight value of 8*2=16 in the pixels inside the area after the second calculation, then the third calculation can be continued, that is, for the area For each pixel inside, calculate the sum of the number of pixels adjacent to the pixel with a weight value of 16 and the weight value of the pixel after the second calculation as the pixel after the third calculation Weight value.
若判断出第m次计算后区域内部的像素点中不存在权重值为8*m的像素点,则确定到满足计算停止条件,不再继续进行第(m+1)次计算。此时可以执行步骤203,将多次计算后权重值最大的像素点确定为二值化图像中连通域的内切圆的圆心。If it is determined that there is no pixel with a weight value of 8*m among the pixels within the area after the mth calculation, it is determined that the calculation stop condition is satisfied, and the (m+1)th calculation is not continued. At this time, step 203 may be executed to determine the pixel point with the largest weight value after multiple calculations as the center of the inscribed circle of the connected domain in the binarized image.
以图3(4)为例,m为3,在第3次计算后区域内部的像素点中不存在权重值为8*3=24的像素点,则不再进行第4次计算。此时,区域内部的像素点的最大权重值为23,则将权重值为23的像素点确定为连通域的内切圆的圆心。Taking FIG. 3(4) as an example, m is 3, and there is no pixel with a weight value of 8*3=24 in the pixels inside the area after the third calculation, so the fourth calculation is not performed. At this time, the maximum weight value of the pixels in the area is 23, and the pixel with the weight value of 23 is determined as the center of the inscribed circle of the connected domain.
一种实施方式中,二值化图像中连通域的区域内部由白色像素点组成,二值化图像中的连通域的区域边缘为由黑色像素点组成,也就是说,二值化图像中连通域中像素点的像素值为255,连通域的区域边缘的像素点的像素值为0。例如,如图3(1)所示的二值化图像。In one embodiment, the area of the connected domain in the binarized image is composed of white pixels, and the edge of the area of the connected domain in the binarized image is composed of black pixels, that is, the connected image in the binarized image The pixel value of the pixel in the domain is 255, and the pixel value of the pixel at the edge of the area connected to the domain is 0. For example, a binarized image as shown in Fig. 3(1).
可以将二值化图像中像素值为0的像素点设置为255,将像素值为255的像素点设置为0,将所得到的图像确定为权重值记录图像,该权重值记录图像用于对每一次计算所到的权重值进行存储。You can set the pixel value of the pixel value 0 in the binarized image to 255, and set the pixel value of the pixel value 255 to 0, and determine the obtained image as the weight value recording image. The weight value recording image is used for The weight value calculated every time is stored.
具体的,将连通域的区域边缘的像素点的像素值设置为255,将连通域的区域内部的像素点的像素值设置为0,将所得到的图像确定为权重值记录图像。针对权重值记录图像每一像素点,该像素点的像素值即为二值化图像中位置与该像素点的位置相同的像素点的权重值。Specifically, the pixel value of the pixel at the edge of the area of the connected domain is set to 255, the pixel value of the pixel inside the area of the connected domain is set to 0, and the obtained image is determined as the weight value recording image. For the weight value, each pixel of the image is recorded, and the pixel value of the pixel is the weight value of the pixel at the same position as the pixel in the binary image.
以权重值记录图像中每一像素点的像素值作为每一像素点的权重值。也就是,区域内部每一像素点的初始权重值为0。针对区域内部的每个像素点,将每一次计算后得到的该像素点的权重值存储至权重值记录图像中该像素点的位置。The pixel value of each pixel in the image is recorded with the weight value as the weight value of each pixel. That is, the initial weight value of each pixel in the area is 0. For each pixel in the area, the weight value of the pixel obtained after each calculation is stored to the position of the pixel in the weight value recording image.
由于权重值记录图像每一像素点的像素值即为二值化图像中位置与该像 素点的位置相同的像素点的权重值,因此,上述针对区域内部的每个像素点,将每一次计算后得到的该像素点的权重值存储至权重值记录图像中该像素点的位置,可以为:针对区域内部的每个像素点,将每一次计算后得到的该像素点的权重值作为权重值记录图像中该像素点的像素值。Since the weight value records the pixel value of each pixel of the image as the weight value of the pixel in the binary image whose position is the same as the position of the pixel, the above calculation will be performed for each pixel within the area every time The weight value of the pixel obtained afterwards is stored to the position of the pixel in the weight value recording image, which can be: for each pixel in the area, the weight value of the pixel obtained after each calculation is used as the weight value Record the pixel value of the pixel in the image.
这样,在每一次计算后,权重值记录图像中记录有二值化图像的连通域的区域内部各像素点的权重值,且权重值记录图像中记录的权重值与二值化图像中与记录该权重值的位置相同的位置处的像素点对应,这样便于对各像素点的权重值进行存储,且从权重值记录图像中获取各像素点的权重值。In this way, after each calculation, the weight value records the weight value of each pixel in the area of the connected domain of the binarized image in the image, and the weight value records the weight value recorded in the image and the binarized image. The pixels at the same position as the weight value correspond to each other, which is convenient for storing the weight value of each pixel, and obtaining the weight value of each pixel from the weight value recording image.
以图3(3)为例,图3(3)中的数值为:第2次计算后区域内部各像素点的权重值,则在第2次计算后,将每一像素点的权重值存储至权重值记录图像中与该像素点的坐标相同的位置。例如,将坐标为(1,1)的像素点的权重值4存储在权重值记录图像中坐标为(1,1)的位置,即将权重值记录图像中坐标为(1,1)的像素点的像素值设置为4,将坐标为(9,7)的像素点的权重值16存储在权重值记录图像中坐标为(9,7)的位置,即将权重值记录图像中坐标为(9,7)的像素点的像素值设置为16。Taking Figure 3(3) as an example, the values in Figure 3(3) are: the weight value of each pixel in the area after the second calculation, then after the second calculation, the weight value of each pixel is stored To the weight value, record the position in the image with the coordinates of the pixel. For example, the weight value 4 of the pixel point with the coordinate (1,1) is stored at the position of the coordinate (1,1) in the weight value recording image, that is, the pixel point with the coordinate (1,1) in the weight value recording image The pixel value of is set to 4, and the weight value 16 of the pixel point with the coordinate (9,7) is stored at the position of the coordinate (9,7) in the weight value recording image, that is, the coordinate of the weight value recording image is (9, 7) The pixel value of the pixel is set to 16.
其中,在对二值化图像进行第m次计算后,权重值记录图像中存储第m次计算后区域内部各像素点的权重值。在进行第m+1次计算后可以得到第m+1次计算后区域内部各像素点的权重值,将所得到的第m+1次计算后的权重值存储至权重值记录图像中时,覆盖权重值记录图像中已存储的第m次计算后的权重值。After performing the mth calculation on the binarized image, the weight value record image stores the weight value of each pixel in the area after the mth calculation. After the m+1th calculation, the weight value of each pixel in the area after the m+1th calculation can be obtained, and when the obtained weight value after the m+1th calculation is stored in the weight value recording image, The overlay weight value records the weight value after the m-th calculation that has been stored in the image.
在本实施方式中,权重值记录图像中用于记录权重值的部分为黑色像素点区域,基于这一区域的像素点的像素值为0,可以有效存储区域内部各像素点的权重值,避免由于权重值超过255而溢出。In this embodiment, the part of the weight value recording image used to record the weight value is a black pixel area, and the pixel value of the pixels based on this area is 0, which can effectively store the weight value of each pixel in the area to avoid Overflow due to weight value exceeding 255.
一种实施方式中,可以从权重值记录图像中获取所存储的权重值,并将所获取的每一权重值,确定为在二值化图像中位置与该权重值的存储位置相同的像素点的权重值。In one embodiment, the stored weight value may be obtained from the weight value recording image, and each obtained weight value may be determined as a pixel point whose position in the binarized image is the same as the storage position of the weight value Weight value.
权重值记录图像每一像素点的像素值即为二值化图像中位置与该像素点的位置相同的像素点的权重值。因此,上述从权重值记录图像中获取所存储 的权重值,并将所获取的每一权重值,确定为在二值化图像中位置与该权重值的存储位置相同的像素点的权重值,即为:从权重值记录图像中获取每一像素点的像素值;针对所获取的每一像素点的像素值,将该像素点的像素值确定为在二值化图像中位置与该像素点的位置相同的像素点的权重值。The weight value records the pixel value of each pixel of the image as the weight value of the pixel in the binary image whose position is the same as that of the pixel. Therefore, the above obtains the stored weight value from the weight value recording image, and determines each obtained weight value as the weight value of the pixel in the binary image whose position is the same as the storage position of the weight value, That is: the pixel value of each pixel is obtained from the weight value recording image; for the pixel value of each pixel obtained, the pixel value of the pixel is determined as the position and the pixel in the binary image The weight value of the pixels with the same position.
一种实现方式中,在每一次计算之前,需要获取上一次计算后所得到的区域内部各像素点的权重值,权重值记录图像中存储上一次计算后区域内部各像素点的权重值,则可以从权重值记录图像中获取上一次计算后区域内部的权重值。In one implementation, before each calculation, the weight value of each pixel in the area obtained after the last calculation needs to be obtained, and the weight value recorded in the image stores the weight value of each pixel in the area after the last calculation, then The weight value inside the area after the last calculation can be obtained from the weight value recording image.
以图3(3)为例,在进行第3次计算前,需要获取第2次计算后区域内部各像素点的权重值,此时权重值记录图像中存储第2次计算后区域内部各像素点的权重值,可以从权重值记录图像中获取第2次计算后区域内部各像素点的权重值,且将所获取的每一权重值,确定为在二值化图像中位置与该权重值的存储位置相同的像素点的权重值。例如,在权重值记录图像中坐标为(1,1)位置处存储的权重值为4,则将该权重值4确定为二值化图像中坐标为(1,1)的像素点的权重值。Taking Figure 3(3) as an example, before performing the third calculation, the weight value of each pixel in the area after the second calculation needs to be obtained. At this time, the weight value recorded image stores each pixel in the area after the second calculation The weight value of the point can be obtained from the weight value recorded image. The weight value of each pixel in the area after the second calculation, and each weight value obtained is determined as the position and the weight value in the binary image The weight value of the pixels with the same storage location. For example, if the weight value stored at the position where the coordinates are (1,1) in the weight value recording image is 4, the weight value 4 is determined as the weight value of the pixel point with the coordinates (1,1) in the binarized image .
本申请实施例提供的技术方案中,针对二值化图像中连通域区域内部的每一像素点,将该像素点相邻的第一目标像素点的个数确定为该像素点在第1次计算后的权重值,计算该像素点相邻的第二目标像素点的个数与该像素点在第m-1次计算后的权重值的和,作为该像素点在第m次计算后的权重值。对于连通域区域内部的像素点,其越靠近区域边缘,在第m-1次计算后,与该像素点相邻的第二目标像素点的个数越少,该像素点的权重值越小,同理,对于连通域区域内部的像素点,其越远离区域边缘,在第m-1次计算后,与该像素点相邻的第二目标像素点的个数越多,该像素点的权重值越大。因此,权重值越大的像素点越靠近连通域的中心。当多次计算后满足预设的计算停止条件时,将多次计算后权重值最大的像素点作为连通域的内切圆的圆心,再从二值化图像中获取与圆心距离最近的第二像素值的像素点,并将所获取的像素点与圆心的距离确定为内切圆的半径。在确定圆心和半径之后,即可以得到连通域的最大内切圆。In the technical solution provided by the embodiment of the present application, for each pixel in the connected domain region in the binarized image, the number of the first target pixel adjacent to the pixel is determined as the first time The calculated weight value is the sum of the number of the second target pixel point adjacent to the pixel point and the weight value of the pixel point after the m-1th calculation, as the pixel point after the mth calculation Weights. For the pixels inside the connected domain area, the closer it is to the edge of the area, the smaller the number of second target pixels adjacent to the pixel after the m-1th calculation, the smaller the weight value of the pixel In the same way, for the pixels inside the connected domain area, the farther they are from the edge of the area, the greater the number of second target pixels adjacent to the pixel after the m-1th calculation, the pixel’s The larger the weight value. Therefore, the pixel with the larger weight value is closer to the center of the connected domain. When the preset calculation stop condition is met after multiple calculations, the pixel with the largest weight value after multiple calculations is used as the center of the inscribed circle of the connected domain, and then the second closest to the center of the circle is obtained from the binarized image The pixel value of the pixel value, and the distance between the acquired pixel point and the center of the circle is determined as the radius of the inscribed circle. After determining the center and radius of the circle, the maximum inscribed circle of the connected domain can be obtained.
相应于上述内切圆确定方法实施例,本申请实施例还提供一种内切圆确 定装置,如图4所示,该内切圆确定装置包括:Corresponding to the above embodiment of the method for determining an inscribed circle, an embodiment of the present application further provides an apparatus for determining an inscribed circle. As shown in FIG. 4, the apparatus for determining an inscribed circle includes:
第一获取模块410,用于获取二值化图像,二值化图像中连通域的区域内部的像素点的像素值为第一像素值,连通域的区域边缘的像素点的像素值为第二像素值;The first obtaining module 410 is used to obtain a binarized image. In the binarized image, the pixel value of the pixel inside the region of the connected domain is the first pixel value, and the pixel value of the pixel at the edge of the region of the connected domain is the second. Pixel values;
计算模块420,用于针对区域内部的每个像素点,采用如下步骤a和步骤b进行多次计算,得到区域内部每个像素点在多次计算后的权重值,直至满足预设的计算停止条件:The calculation module 420 is used to perform multiple calculations using the following steps a and b for each pixel in the area to obtain the weight value of each pixel in the area after multiple calculations until the preset calculation stops condition:
步骤a,计算区域内部的每个像素点在第1次计算后的权重值:针对区域内部的每个像素点,将该像素点相邻的第一目标像素点的个数确定为该像素点在第1次计算后的权重值,第一目标像素点为像素值为第一像素值的像素点;Step a: Calculate the weight value of each pixel in the area after the first calculation: for each pixel in the area, determine the number of the first target pixel adjacent to the pixel as the pixel The weight value after the first calculation, the first target pixel is the pixel whose pixel value is the first pixel value;
步骤b,计算区域内部的每个像素点在第m次计算后的权重值:针对区域内部的每个像素点,计算该像素点相邻的第二目标像素点的个数与该像素点在第m-1次计算后的权重值的和,作为该像素点在第m次计算后的权重值,第二目标像素点的像素值为第一像素值,且第m-1次计算后第二目标像素点的权重值为δ(m-1),δ为满足预设相邻条件的相邻像素点的最大个数,m为大于1;Step b: Calculate the weight value of each pixel in the area after the mth calculation: for each pixel in the area, calculate the number of the second target pixel adjacent to the pixel and the pixel The sum of the weight values after the m-1th calculation is taken as the weight value of the pixel after the mth calculation, the pixel value of the second target pixel is the first pixel value, and the The weight value of the two target pixels is δ(m-1), δ is the maximum number of neighboring pixels that meet the preset neighboring conditions, and m is greater than 1;
第一确定模块430,用于将在多次计算后权重值最大的像素点确定为连通域的内切圆的圆心;The first determining module 430 is configured to determine the pixel point with the largest weight value after multiple calculations as the center of the inscribed circle of the connected domain;
第二确定模块440,用于从二值化图像中,获取与圆心距离最近的第二像素值的像素点,并将所获取的像素点与圆心的距离确定为内切圆的半径。The second determination module 440 is configured to obtain the pixel point of the second pixel value closest to the center of the circle from the binarized image, and determine the distance between the obtained pixel point and the center of the circle as the radius of the inscribed circle.
一种实施方式中,第一像素值为0,第二像素值为255;或第一像素值为255,第二像素值为0;δ=8。In one embodiment, the first pixel value is 0 and the second pixel value is 255; or the first pixel value is 255 and the second pixel value is 0; δ=8.
一种实施方式中,计算停止条件为:In one embodiment, the calculation stop condition is:
在第m-1次计算后,区域内部存在权重值为8(m-1)的像素点,在第m次计算后,区域内部不存在权重值为8*m的像素点。After the m-1th calculation, there are pixels with a weight value of 8 (m-1) inside the area. After the mth calculation, there are no pixels with a weight value of 8*m inside the area.
一种实施方式中,计算停止条件为:计算次数达到预设次数阈值。In one embodiment, the calculation stop condition is: the number of calculations reaches a preset number of thresholds.
一种实施方式中,该内切圆确定装置还可以包括:In an embodiment, the inscribed circle determining device may further include:
判断模块,用于判断第m次计算后区域内部的像素点中是否存在权重值为8*m的像素点;若存在,则计算区域内部的每个像素点在第(m+1)次计算后的权重值;若不存在,则确定满足计算停止条件。The judgment module is used to judge whether there is a pixel with a weight value of 8*m among the pixels inside the area after the mth calculation; if it exists, each pixel inside the calculation area is calculated at the (m+1)th time After the weight value; if it does not exist, it is determined that the calculation stop condition is satisfied.
一种实施方式中,区域内部的像素点的像素值为255,区域边缘的像素点的像素值为0;装置还包括:In one embodiment, the pixel value of the pixels inside the area is 255, and the pixel value of the pixels on the edge of the area is 0; the device further includes:
设置模块,用于将区域边缘的像素点的像素值设置为255,将区域内部的像素点的像素值设置为0,将所得到的图像确定为权重值记录图像;The setting module is used to set the pixel value of the pixels on the edge of the area to 255, set the pixel value of the pixels inside the area to 0, and determine the obtained image as the weight value recording image;
存储模块,用于以权重值记录图像中每一像素点的像素值作为每一像素点的权重值,针对区域内部的每个像素点,将得到的该像素点在每一次计算后的权重值作为权重值记录图像中该像素点的像素值。The storage module is used to record the pixel value of each pixel in the image with the weight value as the weight value of each pixel, and for each pixel in the area, the obtained weight value of the pixel after each calculation Record the pixel value of the pixel in the image as a weight value.
一种实施方式中,该内切圆确定装置还可以包括:In an embodiment, the inscribed circle determining device may further include:
第二获取模块,用于从权重值记录图像中获取所存储的每一像素点的像素值;A second obtaining module, configured to obtain the stored pixel value of each pixel from the weight value recording image;
第三确定模块,用于针对所获取的每一像素点的像素值,将该像素点的像素值确定为在二值化图像中位置与该像素点的位置相同的像素点的权重值。The third determining module is used to determine the pixel value of each pixel as the weight value of the pixel whose position is the same as that of the pixel in the binarized image.
本申请实施例提供的技术方案中,针对二值化图像中连通域区域内部的每一像素点,将该像素点相邻的第一目标像素点的个数确定为该像素点在第1次计算后的权重值,计算该像素点相邻的第二目标像素点的个数与该像素点在第m-1次计算后的权重值的和,作为该像素点在第m次计算后的权重值。对于连通域区域内部的像素点,其越靠近区域边缘,在第m-1次计算后,与该像素点相邻的第二目标像素点的个数越少,该像素点的权重值越小,同理,对于连通域区域内部的像素点,其越远离区域边缘,在第m-1次计算后,与该像素点相邻的第二目标像素点的个数越多,该像素点的权重值越大。因此,权重值越大的像素点越靠近连通域的中心。当多次计算后满足预设的计算停止条件时,将多次计算后权重值最大的像素点作为连通域的内切圆的圆心,再从二值化图像中获取与圆心距离最近的第二像素值的像素点,并将所获取的像素点与圆心的距离确定为内切圆的半径。在确定圆心和半径之后,即可以得到连通域的最大内切圆。In the technical solution provided by the embodiment of the present application, for each pixel in the connected domain region in the binarized image, the number of the first target pixel adjacent to the pixel is determined as the first time The calculated weight value is the sum of the number of the second target pixel point adjacent to the pixel point and the weight value of the pixel point after the m-1th calculation, as the pixel point after the mth calculation Weights. For the pixels inside the connected domain area, the closer it is to the edge of the area, the smaller the number of second target pixels adjacent to the pixel after the m-1th calculation, the smaller the weight value of the pixel In the same way, for the pixels inside the connected domain area, the farther they are from the edge of the area, the greater the number of second target pixels adjacent to the pixel after the m-1th calculation, the pixel’s The larger the weight value. Therefore, the pixel with the larger weight value is closer to the center of the connected domain. When the preset calculation stop condition is met after multiple calculations, the pixel with the largest weight value after multiple calculations is used as the center of the inscribed circle of the connected domain, and then the second closest to the center of the circle is obtained from the binarized image The pixel value of the pixel value, and the distance between the acquired pixel point and the center of the circle is determined as the radius of the inscribed circle. After determining the center and radius of the circle, the maximum inscribed circle of the connected domain can be obtained.
相应于上述内切圆确定方法实施例,本申请实施例还提供了一种电子设备,如图5所示,包括处理器510、通信接口520、存储器530和通信总线540,其中,处理器510、通信接口520、存储器530通过通信总线540完成相互间的通信;Corresponding to the above embodiment of the inscribed circle determination method, an embodiment of the present application further provides an electronic device, as shown in FIG. 5, including a processor 510, a communication interface 520, a memory 530, and a communication bus 540, where the processor 510 The communication interface 520 and the memory 530 complete communication with each other through the communication bus 540;
存储器530,用于存放计算机程序;The memory 530 is used to store computer programs;
处理器510,用于执行存储器530上所存放的程序时,实现如下步骤:When the processor 510 is used to execute the program stored in the memory 530, the following steps are implemented:
获取二值化图像,二值化图像中连通域的区域内部的像素点的像素值为第一像素值,连通域的区域边缘的像素点的像素值为第二像素值;Obtaining a binarized image, the pixel value of the pixels inside the area of the connected domain in the binarized image is the first pixel value, and the pixel value of the pixel points of the edge of the area of the connected domain is the second pixel value;
针对区域内部的每个像素点,采用如下步骤a和步骤b进行多次计算,得到区域内部每个像素点在多次计算后的权重值,直至满足预设的计算停止条件:For each pixel in the area, the following steps a and b are used for multiple calculations to obtain the weight value of each pixel in the area after multiple calculations until the preset calculation stop condition is met:
步骤a,计算区域内部的每个像素点在第1次计算后的权重值:针对区域内部的每个像素点,将该像素点相邻的第一目标像素点的个数确定为该像素点在第1次计算后的权重值,第一目标像素点为像素值为第一像素值的像素点;Step a: Calculate the weight value of each pixel in the area after the first calculation: for each pixel in the area, determine the number of the first target pixel adjacent to the pixel as the pixel The weight value after the first calculation, the first target pixel is the pixel whose pixel value is the first pixel value;
步骤b,计算区域内部的每个像素点在第m次计算后的权重值:针对区域内部的每个像素点,计算该像素点相邻的第二目标像素点的个数与该像素点在第m-1次计算后的权重值的和,作为该像素点在第m次计算后的权重值,第二目标像素点的像素值为第一像素值,且第m-1次计算后第二目标像素点的权重值为δ(m-1),δ为满足预设相邻条件的相邻像素点的最大个数,m为大于1;Step b: Calculate the weight value of each pixel in the area after the mth calculation: for each pixel in the area, calculate the number of the second target pixel adjacent to the pixel and the pixel The sum of the weight values after the m-1th calculation is the weight value of the pixel after the mth calculation, the pixel value of the second target pixel is the first pixel value, and the The weight value of the two target pixels is δ(m-1), δ is the maximum number of neighboring pixels that meet the preset neighboring conditions, and m is greater than 1;
将在多次计算后权重值最大的像素点确定为连通域的内切圆的圆心;Determine the pixel point with the largest weight value after multiple calculations as the center of the inscribed circle of the connected domain;
从二值化图像中,获取与圆心距离最近的第二像素值的像素点,并将所获取的像素点与圆心的距离确定为内切圆的半径。From the binarized image, the pixel point of the second pixel value closest to the center of the circle is obtained, and the distance between the obtained pixel point and the center of the circle is determined as the radius of the inscribed circle.
本申请实施例提供的技术方案中,针对二值化图像中连通域区域内部的每一像素点,将该像素点相邻的第一目标像素点的个数确定为该像素点在第1次计算后的权重值,计算该像素点相邻的第二目标像素点的个数与该像素点在第m-1次计算后的权重值的和,作为该像素点在第m次计算后的权重值。对于连通域区域内部的像素点,其越靠近区域边缘,在第m-1次计算后,与该像 素点相邻的第二目标像素点的个数越少,该像素点的权重值越小,同理,对于连通域区域内部的像素点,其越远离区域边缘,在第m-1次计算后,与该像素点相邻的第二目标像素点的个数越多,该像素点的权重值越大。因此,权重值越大的像素点越靠近连通域的中心。当多次计算后满足预设的计算停止条件时,将多次计算后权重值最大的像素点作为连通域的内切圆的圆心,再从二值化图像中获取与圆心距离最近的第二像素值的像素点,并将所获取的像素点与圆心的距离确定为内切圆的半径。在确定圆心和半径之后,即可以得到连通域的最大内切圆。In the technical solution provided by the embodiment of the present application, for each pixel in the connected domain region in the binarized image, the number of the first target pixel adjacent to the pixel is determined as the first time The calculated weight value is the sum of the number of the second target pixel point adjacent to the pixel point and the weight value of the pixel point after the m-1th calculation, as the pixel point after the mth calculation Weights. For the pixels inside the connected domain area, the closer it is to the edge of the area, the smaller the number of second target pixels adjacent to the pixel after the m-1th calculation, the smaller the weight value of the pixel In the same way, for the pixels inside the connected domain area, the farther they are from the edge of the area, the greater the number of second target pixels adjacent to the pixel after the m-1th calculation, the pixel’s The larger the weight value. Therefore, the pixel with the larger weight value is closer to the center of the connected domain. When the preset calculation stop condition is met after multiple calculations, the pixel with the largest weight value after multiple calculations is used as the center of the inscribed circle of the connected domain, and then the second closest to the center of the circle is obtained from the binarized image The pixel value of the pixel value, and the distance between the acquired pixel point and the center of the circle is determined as the radius of the inscribed circle. After determining the center and radius of the circle, the maximum inscribed circle of the connected domain can be obtained.
上述电子设备提到的通信总线可以是外设部件互连标准(Peripheral Component Interconnect,PCI)总线或扩展工业标准结构(Extended Industry Standard Architecture,EISA)总线等。该通信总线可以分为地址总线、数据总线、控制总线等。为便于表示,图中仅用一条粗线表示,但并不表示仅有一根总线或一种类型的总线。The communication bus mentioned in the above electronic equipment may be a peripheral component interconnection standard (Peripheral Component Interconnect, PCI) bus or an extended industry standard structure (Extended Industry Standard Architecture, EISA) bus, etc. The communication bus can be divided into an address bus, a data bus, and a control bus. For ease of representation, only a thick line is used in the figure, but it does not mean that there is only one bus or one type of bus.
通信接口用于上述电子设备与其他设备之间的通信。The communication interface is used for communication between the electronic device and other devices.
存储器可以包括随机存取存储器(Random Access Memory,RAM),也可以包括非易失性存储器(Non-Volatile Memory,NVM),例如至少一个磁盘存储器。可选的,存储器还可以是至少一个位于远离前述处理器的存储装置。The memory may include random access memory (Random Access Memory, RAM), or non-volatile memory (Non-Volatile Memory, NVM), for example, at least one disk memory. Optionally, the memory may also be at least one storage device located away from the foregoing processor.
处理器可以是通用处理器,包括中央处理器(Central Processing Unit,CPU)、网络处理器(Network Processor,NP)等;还可以是数字信号处理器(Digital Signal Processing,DSP)、专用集成电路(Application Specific Integrated Circuit,ASIC)、现场可编程门阵列(Field-Programmable Gate Array,FPGA)或者其他可编程逻辑器件、分立门或者晶体管逻辑器件、分立硬件组件。The processor can be a general-purpose processor, including a central processor (Central Processing Unit, CPU), a network processor (Network Processor, NP), etc.; it can also be a digital signal processor (Digital Signal Processing, DSP), a dedicated integrated circuit ( Application Specific (Integrated Circuit, ASIC), Field-Programmable Gate Array (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components.
相应于上述内切圆确定方法实施例,本申请实施例还提供了一种机器可读存储介质,机器可读存储介质内存储有计算机程序,计算机程序被处理器执行时实现上述任一的内切圆确定方法步骤。Corresponding to the above embodiment of the method for determining an inscribed circle, an embodiment of the present application further provides a machine-readable storage medium in which a computer program is stored. When the computer program is executed by a processor, any of the above Tangent circle determination method steps.
相应于上述内切圆确定方法实施例,本申请实施例还提供了一种有计算机程序,计算机程序被处理器执行时实现上述任一的内切圆确定方法步骤。Corresponding to the above embodiment of the method for determining an inscribed circle, an embodiment of the present application further provides a computer program that implements any of the steps of the method for determining an inscribed circle when the computer program is executed by a processor.
需要说明的是,在本文中,诸如第一和第二等之类的关系术语仅仅用来将一个实体或者操作与另一个实体或操作区分开来,而不一定要求或者暗示这些实体或操作之间存在任何这种实际的关系或者顺序。而且,术语“包括”、“包含”或者其任何其他变体意在涵盖非排他性的包含,从而使得包括一系列要素的过程、方法、物品或者设备不仅包括那些要素,而且还包括没有明确列出的其他要素,或者是还包括为这种过程、方法、物品或者设备所固有的要素。在没有更多限制的情况下,由语句“包括一个……”限定的要素,并不排除在包括所述要素的过程、方法、物品或者设备中还存在另外的相同要素。It should be noted that in this article, relational terms such as first and second are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply that these entities or operations There is any such actual relationship or order. Moreover, the terms "include", "include" or any other variant thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device that includes a series of elements includes not only those elements, but also those not explicitly listed Or other elements that are inherent to this process, method, article, or equipment. Without more restrictions, the element defined by the sentence "include one..." does not exclude that there are other identical elements in the process, method, article or equipment that includes the element.
本说明书中的各个实施例均采用相关的方式描述,各个实施例之间相同相似的部分互相参见即可,每个实施例重点说明的都是与其他实施例的不同之处。尤其,对于内切圆确定装置、电子设备、机器可读存储介质以及计算机程序实施例而言,由于其基本相似于内切圆确定方法实施例,所以描述的比较简单,相关之处参见方法实施例的部分说明即可。Each embodiment in this specification is described in a related manner. The same or similar parts between the embodiments can be referred to each other. Each embodiment focuses on the differences from other embodiments. In particular, for the embodiments of the inscribed circle determination device, electronic equipment, machine-readable storage medium, and computer program, since they are basically similar to the inscribed circle determination method embodiments, the description is relatively simple. Explain part of the example.
以上所述仅为本申请的较佳实施例而已,并非用于限定本申请的保护范围。凡在本申请的精神和原则之内所作的任何修改、等同替换、改进等,均包含在本申请的保护范围内。The above are only the preferred embodiments of the present application, and are not intended to limit the protection scope of the present application. Any modifications, equivalent replacements, improvements, etc. made within the spirit and principles of this application are included in the scope of protection of this application.

Claims (17)

  1. 一种内切圆确定方法,其特征在于,所述方法包括:A method for determining an inscribed circle, characterized in that the method includes:
    获取二值化图像,所述二值化图像中连通域的区域内部的像素点的像素值为第一像素值,所述连通域的区域边缘的像素点的像素值为第二像素值;Acquiring a binarized image, in which the pixel value of the pixel inside the area of the connected domain is the first pixel value, and the pixel value of the pixel at the edge of the area of the connected domain is the second pixel value;
    针对所述区域内部的每个像素点,采用如下步骤a和步骤b进行多次计算,得到所述区域内部每个像素点在多次计算后的权重值,直至满足预设的计算停止条件:For each pixel in the area, the following steps a and b are used for multiple calculations to obtain the weight value of each pixel in the area after multiple calculations until the preset calculation stop condition is met:
    步骤a,计算所述区域内部的每个像素点在第1次计算后的权重值:针对所述区域内部的每个像素点,将该像素点相邻的第一目标像素点的个数确定为该像素点在第1次计算后的权重值,所述第一目标像素点为像素值为第一像素值的像素点;Step a: Calculate the weight value of each pixel inside the area after the first calculation: for each pixel inside the area, determine the number of first target pixels adjacent to the pixel Is the weight value of the pixel after the first calculation, and the first target pixel is a pixel whose pixel value is the first pixel value;
    步骤b,计算所述区域内部的每个像素点在第m次计算后的权重值:针对所述区域内部的每个像素点,计算该像素点相邻的第二目标像素点的个数与该像素点在第m-1次计算后的权重值的和,作为该像素点在第m次计算后的权重值,所述第二目标像素点的像素值为所述第一像素值,且第m-1次计算后所述第二目标像素点的权重值为δ(m-1),δ为满足预设相邻条件的相邻像素点的最大个数,m为大于1;Step b: Calculate the weight value of each pixel in the area after the mth calculation: for each pixel in the area, calculate the number of second target pixels adjacent to the pixel and The sum of the weight values of the pixel after the m-1th calculation is used as the weight value of the pixel after the mth calculation, the pixel value of the second target pixel is the first pixel value, and After the m-1 calculation, the weight value of the second target pixel is δ(m-1), where δ is the maximum number of adjacent pixels that satisfy the preset adjacent condition, and m is greater than 1;
    将在所述多次计算后权重值最大的像素点确定为所述连通域的内切圆的圆心;Determine the pixel point with the largest weight value after the multiple calculations as the center of the inscribed circle of the connected domain;
    从所述二值化图像中,获取与所述圆心距离最近的所述第二像素值的像素点,并将所获取的像素点与所述圆心的距离确定为所述内切圆的半径。From the binarized image, obtain the pixel point of the second pixel value closest to the center of the circle, and determine the distance between the obtained pixel point and the center of the circle as the radius of the inscribed circle.
  2. 根据权利要求1所述的方法,其特征在于,所述第一像素值为0,所述第二像素值为255;或所述第一像素值为255,所述第二像素值为0;所述δ=8。The method of claim 1, wherein the first pixel value is 0 and the second pixel value is 255; or the first pixel value is 255 and the second pixel value is 0; Δ=8.
  3. 根据权利要求1或2所述的方法,其特征在于,所述计算停止条件为:The method according to claim 1 or 2, wherein the calculation stop condition is:
    在第m-1次计算后,所述区域内部存在权重值为8(m-1)的像素点,在第m次计算后,所述区域内部不存在权重值为8*m的像素点。After the m-1th calculation, there are pixels with a weight value of 8 (m-1) inside the area, and after the mth calculation, there are no pixels with a weight value of 8*m inside the area.
  4. 根据权利要求1或2所述的方法,其特征在于,所述计算停止条件为: 计算次数达到预设次数阈值。The method according to claim 1 or 2, wherein the calculation stop condition is that: the number of calculations reaches a preset number of thresholds.
  5. 根据权利要求1或2所述的方法,其特征在于,所述计算所述区域内部的每个像素点在第m次计算后的权重值的步骤之后,还包括:The method according to claim 1 or 2, wherein after the step of calculating the weight value of each pixel in the area after the m-th calculation, the method further comprises:
    判断第m次计算后所述区域内部的像素点中是否存在权重值为8*m的像素点;Determine whether there is a pixel with a weight value of 8*m among the pixels within the area after the mth calculation;
    若存在,则计算所述区域内部的每个像素点在第(m+1)次计算后的权重值;If there is, calculate the weight value of each pixel in the area after the (m+1)th calculation;
    若不存在,则确定满足所述计算停止条件。If it does not exist, it is determined that the calculation stop condition is satisfied.
  6. 根据权利要求1或2所述的方法,其特征在于,所述区域内部的像素点的像素值为255,所述区域边缘的像素点的像素值为0;所述方法还包括:The method according to claim 1 or 2, wherein the pixel value of the pixel inside the area is 255, and the pixel value of the pixel at the edge of the area is 0; the method further comprises:
    将所述区域边缘的像素点的像素值设置为255,将所述区域内部的像素点的像素值设置为0,将所得到的图像确定为权重值记录图像;Set the pixel value of the pixels on the edge of the area to 255, set the pixel value of the pixels inside the area to 0, and determine the obtained image as the weight value recording image;
    以所述权重值记录图像中每一像素点的像素值作为每一像素点的权重值,针对所述区域内部的每个像素点,将得到的该像素点在每一次计算后的权重值作为所述权重值记录图像中该像素点的像素值。Use the weight value to record the pixel value of each pixel in the image as the weight value of each pixel, and for each pixel inside the area, use the obtained weight value of the pixel after each calculation as The weight value records the pixel value of the pixel in the image.
  7. 根据权利要求6所述的方法,其特征在于,所述方法还包括:The method according to claim 6, wherein the method further comprises:
    从所述权重值记录图像中获取每一像素点的像素值;Obtaining the pixel value of each pixel from the weight value recording image;
    针对所获取的每一像素点的像素值,将该像素点的像素值确定为在所述二值化图像中位置与该像素点的位置相同的像素点的权重值。For each pixel value acquired, the pixel value of the pixel is determined as the weight value of the pixel whose position is the same as the position of the pixel in the binarized image.
  8. 一种内切圆确定装置,其特征在于,所述装置包括:An inscribed circle determination device, characterized in that the device includes:
    第一获取模块,用于获取二值化图像,所述二值化图像中连通域的区域内部的像素点的像素值为第一像素值,所述连通域的区域边缘的像素点的像素值为第二像素值;The first acquisition module is used to acquire a binarized image, the pixel value of the pixels inside the region of the connected domain in the binarized image is the first pixel value, and the pixel value of the pixel at the edge of the region of the connected domain Is the second pixel value;
    计算模块,用于针对所述区域内部的每个像素点,采用如下步骤a和步骤b进行多次计算,得到所述区域内部每个像素点在多次计算后的权重值,直至满足预设的计算停止条件:The calculation module is used to perform multiple calculations using the following steps a and b for each pixel in the area to obtain the weight value of each pixel in the area after multiple calculations until the preset value is met The calculation stop condition:
    步骤a,计算所述区域内部的每个像素点在第1次计算后的权重值:针对所述区域内部的每个像素点,将该像素点相邻的第一目标像素点的个数确定为该像素点在第1次计算后的权重值,所述第一目标像素点为像素值为第一像素值的像素点;Step a: Calculate the weight value of each pixel inside the area after the first calculation: for each pixel inside the area, determine the number of first target pixels adjacent to the pixel Is the weight value of the pixel after the first calculation, and the first target pixel is a pixel whose pixel value is the first pixel value;
    步骤b,计算所述区域内部的每个像素点在第m次计算后的权重值:针对所述区域内部的每个像素点,计算该像素点相邻的第二目标像素点的个数与该像素点在第m-1次计算后的权重值的和,作为该像素点在第m次计算后的权重值,所述第二目标像素点的像素值为所述第一像素值,且第m-1次计算后所述第二目标像素点的权重值为δ(m-1),δ为满足预设相邻条件的相邻像素点的最大个数,m为大于1;Step b: Calculate the weight value of each pixel in the area after the mth calculation: for each pixel in the area, calculate the number of second target pixels adjacent to the pixel and The sum of the weight values of the pixel after the m-1th calculation is used as the weight value of the pixel after the mth calculation, the pixel value of the second target pixel is the first pixel value, and After the m-1 calculation, the weight value of the second target pixel is δ(m-1), where δ is the maximum number of adjacent pixels that satisfy the preset adjacent condition, and m is greater than 1;
    第一确定模块,用于将在所述多次计算后权重值最大的像素点确定为所述连通域的内切圆的圆心;A first determining module, configured to determine the pixel point with the largest weight value after the multiple calculations as the center of the inscribed circle of the connected domain;
    第二确定模块,用于从所述二值化图像中,获取与所述圆心距离最近的所述第二像素值的像素点,并将所获取的像素点与所述圆心的距离确定为所述内切圆的半径。A second determining module, configured to obtain the pixel point of the second pixel value closest to the center of the circle from the binarized image, and determine the distance between the obtained pixel point and the center of the circle as the State the radius of the inscribed circle.
  9. 根据权利要求8所述的装置,其特征在于,所述第一像素值为0,所述第二像素值为255;或所述第一像素值为255,所述第二像素值为0;所述δ=8。The device according to claim 8, wherein the first pixel value is 0 and the second pixel value is 255; or the first pixel value is 255 and the second pixel value is 0; Δ=8.
  10. 根据权利要求8或9所述的装置,其特征在于,所述计算停止条件为:The device according to claim 8 or 9, wherein the calculation stop condition is:
    在第m-1次计算后,所述区域内部存在权重值为8(m-1)的像素点,在第m次计算后,所述区域内部不存在权重值为8*m的像素点。After the m-1th calculation, there are pixels with a weight value of 8 (m-1) inside the area, and after the mth calculation, there are no pixels with a weight value of 8*m inside the area.
  11. 根据权利要求8或9所述的装置,其特征在于,所述计算停止条件为:计算次数达到预设次数阈值。The device according to claim 8 or 9, wherein the calculation stop condition is that the number of calculations reaches a preset number of thresholds.
  12. 根据权利要求8或9所述的装置,其特征在于,所述装置还包括:The device according to claim 8 or 9, wherein the device further comprises:
    判断模块,用于判断第m次计算后所述区域内部的像素点中是否存在权重值为8*m的像素点;若存在,则计算所述区域内部的每个像素点在第(m+1)次计算后的权重值;若不存在,则确定满足所述计算停止条件。The judging module is used to judge whether there is a pixel with a weight value of 8*m among the pixels inside the area after the mth calculation; if there is, then calculate each pixel within the area at the (m+ 1) The weight value after the calculation; if it does not exist, it is determined that the calculation stop condition is satisfied.
  13. 根据权利要求8或9所述的装置,其特征在于,所述区域内部的像素 点的像素值为255,所述区域边缘的像素点的像素值为0;所述装置还包括:The device according to claim 8 or 9, wherein the pixel value of the pixel inside the area is 255, and the pixel value of the pixel at the edge of the area is 0; the device further comprises:
    设置模块,用于将所述区域边缘的像素点的像素值设置为255,将所述区域内部的像素点的像素值设置为0,将所得到的图像确定为权重值记录图像;A setting module, configured to set the pixel value of the pixels on the edge of the area to 255, set the pixel value of the pixels inside the area to 0, and determine the obtained image as the weight value recording image;
    存储模块,用于以所述权重值记录图像中每一像素点的像素值作为每一像素点的权重值,针对所述区域内部的每个像素点,将得到的该像素点在每一次计算后的权重值作为所述权重值记录图像中该像素点的像素值。The storage module is used to record the pixel value of each pixel in the image with the weight value as the weight value of each pixel, and for each pixel inside the area, calculate the obtained pixel every time The weight value after is used as the weight value to record the pixel value of the pixel in the image.
  14. 根据权利要求13所述的装置,其特征在于,所述装置还包括:The device according to claim 13, wherein the device further comprises:
    第二获取模块,用于从所述权重值记录图像中获取所存储的每一像素点的像素值;A second obtaining module, configured to obtain the stored pixel value of each pixel from the weight value recording image;
    第三确定模块,用于针对所获取的每一像素点的像素值,将该像素点的像素值确定为在所述二值化图像中位置与该像素点的位置相同的像素点的权重值。The third determining module is used to determine the pixel value of each pixel as the weight value of the pixel whose position is the same as that of the pixel in the binarized image .
  15. 一种电子设备,其特征在于,包括处理器、通信接口、存储器和通信总线,其中,处理器、通信接口、存储器通过通信总线完成相互间的通信;An electronic device characterized by comprising a processor, a communication interface, a memory, and a communication bus, wherein the processor, the communication interface, and the memory complete communication with each other through the communication bus;
    存储器,用于存放计算机程序;Memory, used to store computer programs;
    处理器,用于执行存储器上所存放的程序时,实现权利要求1-7任一所述的方法步骤。The processor, when used to execute the program stored in the memory, implements the method steps of any one of claims 1-7.
  16. 一种机器可读存储介质,其特征在于,所述机器可读存储介质内存储有计算机程序,所述计算机程序被处理器执行时实现权利要求1-7任一所述的方法步骤。A machine-readable storage medium, characterized in that a computer program is stored in the machine-readable storage medium, and when the computer program is executed by a processor, the method steps of any one of claims 1-7 are realized.
  17. 一种计算机程序,其特征在于,所述计算机程序被处理器执行时实现权利要求1-7任一所述的方法步骤。A computer program, characterized in that, when the computer program is executed by a processor, the method steps of any one of claims 1-7 are realized.
PCT/CN2019/126702 2018-12-29 2019-12-19 Inscribed circle determination method and device WO2020135230A1 (en)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN201811636143.6 2018-12-29
CN201811636143.6A CN109785380B (en) 2018-12-29 2018-12-29 Inscribed circle determining method and device

Publications (1)

Publication Number Publication Date
WO2020135230A1 true WO2020135230A1 (en) 2020-07-02

Family

ID=66498927

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2019/126702 WO2020135230A1 (en) 2018-12-29 2019-12-19 Inscribed circle determination method and device

Country Status (2)

Country Link
CN (1) CN109785380B (en)
WO (1) WO2020135230A1 (en)

Families Citing this family (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN109785380B (en) * 2018-12-29 2020-09-18 北京金山安全软件有限公司 Inscribed circle determining method and device
CN110544241A (en) * 2019-08-22 2019-12-06 云南电网有限责任公司 matching system for power cable metal cross section trace feature recognition degree
CN110796695B (en) * 2019-10-24 2022-04-05 深圳市瑞源祥橡塑制品有限公司 Food cooking size obtaining method and device, computer equipment and storage medium

Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN104866856A (en) * 2015-05-17 2015-08-26 西南石油大学 Imaging log image solution cave information picking method based on connected domain equivalence pair processing
CN107729883A (en) * 2017-11-22 2018-02-23 吉林大学 A kind of vein image area-of-interest exacting method
US20180173327A1 (en) * 2016-03-22 2018-06-21 Guangdong Virtual Reality Technology Co., Ltd. Method, device and terminal for determining effectiveness of stripe set
CN108335311A (en) * 2018-01-22 2018-07-27 上海烟草集团有限责任公司 Extracting method, electronic equipment and the storage medium of tobacco leaf Morphologic Characteristics
CN108776978A (en) * 2018-05-28 2018-11-09 江苏中烟工业有限责任公司 A kind of threshed redried strips piece shape characterizing method
CN109785380A (en) * 2018-12-29 2019-05-21 北京金山安全软件有限公司 Inscribed circle determining method and device

Family Cites Families (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP4405942B2 (en) * 2005-06-14 2010-01-27 キヤノン株式会社 Image processing apparatus and method
CN103049763B (en) * 2012-12-07 2015-07-01 华中科技大学 Context-constraint-based target identification method
US10354133B2 (en) * 2015-08-26 2019-07-16 Beijing Lejent Technology Co., Ltd. Method for structural analysis and recognition of handwritten mathematical formula in natural scene image
CN106169186A (en) * 2016-07-01 2016-11-30 西安电子科技大学 Based on the method obtaining initial profile in level set moving object detection
CN107545568B (en) * 2017-08-07 2021-08-20 东方财富信息股份有限公司 Processing method and system for 3D binary image
CN108875579B (en) * 2018-05-15 2022-08-05 厦门大学 Morphology-based close-range gesture recognition method

Patent Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN104866856A (en) * 2015-05-17 2015-08-26 西南石油大学 Imaging log image solution cave information picking method based on connected domain equivalence pair processing
US20180173327A1 (en) * 2016-03-22 2018-06-21 Guangdong Virtual Reality Technology Co., Ltd. Method, device and terminal for determining effectiveness of stripe set
CN107729883A (en) * 2017-11-22 2018-02-23 吉林大学 A kind of vein image area-of-interest exacting method
CN108335311A (en) * 2018-01-22 2018-07-27 上海烟草集团有限责任公司 Extracting method, electronic equipment and the storage medium of tobacco leaf Morphologic Characteristics
CN108776978A (en) * 2018-05-28 2018-11-09 江苏中烟工业有限责任公司 A kind of threshed redried strips piece shape characterizing method
CN109785380A (en) * 2018-12-29 2019-05-21 北京金山安全软件有限公司 Inscribed circle determining method and device

Also Published As

Publication number Publication date
CN109785380B (en) 2020-09-18
CN109785380A (en) 2019-05-21

Similar Documents

Publication Publication Date Title
WO2020135230A1 (en) Inscribed circle determination method and device
US10803554B2 (en) Image processing method and device
US10224955B2 (en) Data compression and decompression method of demura table, and mura compensation method
WO2020135056A1 (en) Image processing method and device
US11790499B2 (en) Certificate image extraction method and terminal device
CN107833238A (en) Largest connected field mark method, method for tracking target, augmented reality/virtual reality device
CN107590447A (en) A kind of caption recognition methods and device
CN111325716A (en) Screen scratch fragmentation detection method and equipment
US11521303B2 (en) Method and device for inpainting image
CN111311556B (en) Mobile phone defect position identification method and equipment
CN111091572B (en) Image processing method and device, electronic equipment and storage medium
CN110619333A (en) Text line segmentation method, text line segmentation device and electronic equipment
CN104700062A (en) Method and equipment for identifying two-dimension code
CN108737875B (en) Image processing method and device
CN109271910A (en) A kind of Text region, character translation method and apparatus
US9087272B2 (en) Optical match character classification
CN109308478B (en) Character recognition method and device
CN111325717A (en) Mobile phone defect position identification method and equipment
CN107993239B (en) Method and device for calculating depth order of monocular image
WO2021102948A1 (en) Image processing method and device
CN111127592B (en) Picture color filling method and device, electronic equipment and readable storage medium
WO2018058573A1 (en) Object detection method, object detection apparatus and electronic device
CN114677319A (en) Stem cell distribution determination method and device, electronic equipment and storage medium
CN109977937B (en) Image processing method, device and equipment
CN116977783A (en) Training method, device, equipment and medium of target detection model

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 19905792

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

122 Ep: pct application non-entry in european phase

Ref document number: 19905792

Country of ref document: EP

Kind code of ref document: A1