Calculation method and segmentation method of related parameters of image segmentation threshold and electronic equipment

The method enhances image segmentation on ARM boards by dynamically adjusting thresholds and using a single-layer neural network with optimized parameters, improving accuracy and speed for image thresholding.

CN120318268APending Publication Date: 2025-07-15JINGYU LASER TECH CHONGQING
View PDF 0 Cites 2 Cited by

Patent Information

Application Number
CN202510470525.X
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-04-15
Publication Date
2025-07-15

AI Technical Summary

Technical Problem

The prior art image threshold segmentation method on the ARM industrial control board has a problem of slow processing speed and low accuracy.

Method used

The original sample image is segmented by dynamically adjusting the segmentation threshold by feature markers, a training data set is constructed and a single-layer image segmentation model iteratively trained, and a standardized parameters and weight parameters are obtained to calculate the target segmentation threshold.

Benefits of technology

On the ARM industrial control board with lower performance, it improves the speed and accuracy of image segmentation, reduces the amount of calculation, and is suitable for equipment such as hair removal instruments.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120318268A_ABST
    Figure CN120318268A_ABST
Patent Text Reader

Abstract

The invention relates to the technical field of image processing, in particular to an image segmentation threshold related parameter calculation method, an image segmentation method and electronic equipment. The calculation method comprises the steps of segmenting an original sample image through a feature marker based on a dynamically adjusted segmentation threshold, taking an adjustment threshold used by a target contour map corresponding to an expected segmentation effect as a first segmentation threshold, determining N features based on a preset feature selection rule, and calculating feature values corresponding to the N features based on the target contour map; marking corresponding N feature values by adopting a first segmentation threshold value corresponding to each original sample image to obtain a training data set; performing iterative training on the single-layer image segmentation model based on the training data set to obtain standardization parameters and weight parameters respectively corresponding to the N features; and the standardization parameter and the weight parameter are used for obtaining the target segmentation threshold based on the N feature values of the to-be-detected image, so that the problems of low processing speed and low accuracy of the image threshold segmentation method in the prior art can be solved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the technical field of image processing, and in particular, to a method for calculating parameters related to an image segmentation threshold, a segmentation method, and an electronic device. Background Art

[0002] In the prior art, image threshold segmentation methods include: 1) threshold segmentation and template matching algorithms based on traditional vision technologies; 2) object detection and segmentation algorithms based on deep learning, especially convolutional neural networks (CNNs).

[0003] The threshold segmentation and template matching algorithms based on traditional vision usually benefit from the support of mature libraries, the calculation process is relatively simple, and they do not require dependence on specific hardware devices. However, they require machine vision engineers to manually extract features, and the feature matching process is relatively strict. In addition, the generalization ability of these algorithms is limited when dealing with complex images.

[0004] The convolutional neural network method based on deep learning benefits from a mature deep learning framework, and convolutional neural networks perform excellently in image localization and classification tasks. However, convolutional neural networks have high requirements for hardware resources, especially on devices with limited performance, and their processing speed is slow.

[0005] For example, on a low-performance ARM (Advanced RISC Machine) industrial control board, it is challenging to achieve accurate and rapid medical image threshold segmentation. If a deep learning convolutional neural network is used, the processing speed is too slow; if traditional machine vision methods are relied on, the generalization ability is insufficient and the accuracy is low. Summary of the Invention

[0006] In view of this, embodiments of the present application provide a method for calculating parameters related to an image segmentation threshold, a segmentation method, and an electronic device, which can effectively solve the problems of slow processing speed and low accuracy of the image threshold segmentation method applied to an ARM industrial control board in the prior art, etc.

[0007] In a first aspect, an embodiment of the present application provides a method for calculating parameters related to an image segmentation threshold, including:

[0008] Segmenting an original sample image by a feature marker based on a dynamically adjusted segmentation threshold, and using the adjusted threshold for obtaining a target contour map as a first segmentation threshold, where the target contour map is a contour map obtained when an expected segmentation effect is achieved; determining N features based on a preset feature selection rule, and calculating feature values corresponding to the N features based on the target contour map; where N is an integer greater than 0;

[0009] Mark the corresponding N eigenvalues with the first segmentation threshold corresponding to each of the original sample images to construct a training data set;

[0010] Based on the training data set, iteratively train the constructed single-layer image segmentation model to obtain the normalization parameters and weight parameters corresponding to the N features respectively; wherein, the normalization parameters and the weight parameters are used to obtain the target segmentation threshold based on the N eigenvalues of the image to be measured.

[0011] In some embodiments, the method of segmenting the original sample image by the feature marker based on the dynamically adjusted segmentation threshold and taking the adjusted threshold corresponding to the target contour map with the desired segmentation effect as the first segmentation threshold includes:

[0012] Input the original sample image into the feature marker, so that the feature marker performs image segmentation based on the configured empirical segmentation threshold and displays the segmented image through a preset interface, receive the adjustment of the segmentation threshold corresponding to the operable control on the preset interface by the user and synchronously update the segmented image on the preset interface;

[0013] In response to obtaining the target contour map with the desired segmentation effect, take the currently adjusted segmentation threshold as the first segmentation threshold.

[0014] In some embodiments, the method of determining N features based on a preset feature selection rule and calculating the eigenvalues corresponding to the N features based on the target contour map includes:

[0015] Convert the original sample image in RGB format to the Lab color space, and then extract the monochromatic image of the L channel;

[0016] Generate a contour map based on the monochromatic image and the step size determined according to the feature selection rule;

[0017] According to each of the N features, extract the corresponding gray value from the contour map to obtain the corresponding eigenvalue.

[0018] In some embodiments, the method of determining N features based on a preset feature selection rule includes:

[0019] Determine N - 1 features based on N - 1 preset pixel thresholds, and determine one feature based on the input target recognition region; wherein, the preset N - 1 pixel thresholds include: a first low pixel threshold for removing dark noise, a second high pixel threshold for removing bright noise, a second low pixel threshold for removing dark noise, a third high pixel threshold for removing bright noise, a third low pixel threshold for removing black dark spots, a fourth high pixel threshold for removing white bright spots, a gray median, a gray average, a gray standard deviation, multiple pixel thresholds divided based on a first wide step according to a first pixel section, and multiple pixel thresholds divided based on a second wide step according to a second pixel section;

[0020] Wherein, the first pixel section is a pixel interval determined from the median of the effective gray levels to the fifth high pixel threshold; the second pixel section is a pixel interval determined from the fifth high pixel threshold to the first high pixel threshold.

[0021] In some embodiments, the single - layer image segmentation model includes a single - layer fully - connected network; the single - layer fully - connected network includes N input neurons and one output neuron;

[0022] Based on the training data set, iteratively train the constructed single - layer image segmentation model to obtain the normalization parameters and weight parameters corresponding to the N features, including:

[0023] Input N feature values one - to - one into the N input neurons, use the second segmentation threshold fitted according to N first segmentation thresholds as the training target, iteratively train the single - layer fully - connected network, and at the same time use the gradient descent method to optimize the parameters to obtain the weight parameters and the normalization parameters; the weight parameters include the bias and the weight corresponding to each feature; the normalization parameters include the average value and the standard deviation corresponding to each feature.

[0024] In some embodiments, before converting the original sample image in RGB format to the Lab color space, it further includes:

[0025] Perform inverse gamma correction on the RGB values in the original sample image in RGB format, and convert the corrected RGB values to the Lab color space.

[0026] In a second aspect, an embodiment of the present application provides a dynamic threshold image segmentation method, including:

[0027] Obtain the original image to be segmented and convert it into a monochromatic image;

[0028] Extract the feature values corresponding to N features determined based on a preset feature selection rule from the monochromatic image to obtain N feature values;

[0029] Calculate a target segmentation threshold using the weight parameters and the N normalized eigenvalues; wherein, the weight parameters and the normalization parameters are both obtained by using a calculation method for parameters related to an image segmentation threshold provided in the first aspect of the present application;

[0030] Based on the monochromatic image, perform image segmentation according to the target segmentation threshold to obtain a target segmentation image.

[0031] In some embodiments, it further includes: normalizing the extracted N eigenvalues according to the normalization parameters; wherein, the normalization parameters include the average value and the standard deviation respectively corresponding to the N features;

[0032] Further, the normalizing the extracted N eigenvalues according to the normalization parameters includes normalizing the N eigenvalues by using the following formula:

[0033]

[0034] wherein, x i represents the i-th eigenvalue, μ i represents the average value corresponding to the i-th feature, σ i represents the standard deviation corresponding to the i-th feature, and n represents the total number of features.

[0035] In some embodiments, the weight parameters include a deviation and the weights respectively corresponding to the N features;

[0036] The calculating the target segmentation threshold using the weight parameters and the N normalized eigenvalues includes obtaining the target segmentation threshold by using the following formula:

[0037] y = w1x1 + w2x2 + … + w n x n + b

[0038] wherein, y represents the target segmentation threshold, w i represents the weight corresponding to the i-th feature, x i represents the i-th eigenvalue, and b represents the deviation.

[0039] In a third aspect, an embodiment of the present application provides an electronic device, which includes a processor and a memory. The memory stores a computer program, and the processor is configured to execute the computer program to implement a dynamic threshold image segmentation method provided in the second aspect of the present application.

[0040] The embodiments of the present application have the following beneficial effects:

[0041] First, in this application, the original sample image is segmented by a feature tagger based on a dynamically adjusted segmentation threshold. The adjusted threshold corresponding to the target contour map with the desired segmentation effect is used as the first segmentation threshold. Then, N features are determined based on a preset feature selection rule, and the feature values corresponding to the N features are calculated based on the target contour map. Next, the N feature values corresponding to each original sample image are marked with the first segmentation threshold corresponding to it to construct a training data set. Finally, the constructed single-layer image segmentation model is iteratively trained based on the training data set to obtain the normalization parameters and weight parameters corresponding to the N features respectively. The normalization parameters and weight parameters are used to obtain the target segmentation threshold based on the N feature values of the image to be measured. To improve the accuracy of the samples, in this application, first, through the dynamically adjusted segmentation threshold, the target contour map and the first segmentation threshold (the ideal segmentation threshold) in the case of an ideal segmentation effect are obtained. Then, based on the preset feature selection rule, the N feature values in the target contour map are extracted. The first segmentation threshold is used to label the corresponding N features for training to obtain the normalization parameters and weight parameters. The normalization parameters and weight parameters are particularly suitable for use in segmenting images on electronic devices with poor performance to reduce the computational amount of the electronic devices. Thus, this application can effectively solve the problems of slow processing speed and low accuracy of the image threshold segmentation method used in the existing technology on the ARM industrial control board, etc. Description of the Drawings

[0042] To more clearly illustrate the technical solutions of the embodiments of this application, the following will briefly introduce the drawings required to be used in the embodiments. It should be understood that the following drawings only show some embodiments of this application and should not be regarded as limiting the scope. For those of ordinary skill in the art, other related drawings can also be obtained based on these drawings without creative efforts.

[0043] Figure 1 Shows a flowchart of a calculation method for image segmentation threshold-related parameters according to an embodiment of this application;

[0044] Figure 2 Shows a schematic structural diagram of a single-layer fully connected network of a dynamic threshold image segmentation method according to an embodiment of this application;

[0045] Figure 3 Shows a flowchart of a dynamic threshold image segmentation method according to an embodiment of this application;

[0046] Figure 4 Shows a schematic structural diagram of a dynamic threshold image segmentation device according to an embodiment of this application.

[0047] Main Component Symbol Description:

[0048] 410 - Image conversion module; 420 - Feature extraction module; 430 - Standardization module; 440 - Threshold calculation module; 450 - Segmentation module. Detailed implementation manners

[0049] Next, the technical solutions in the embodiments of the present application will be clearly and completely described in conjunction with the accompanying drawings in the embodiments of the present application. Obviously, the described embodiments are only a part of the embodiments of the present application, rather than all the embodiments.

[0050] Generally, the components of the embodiments of the present application described and illustrated herein can be arranged and designed in various different configurations. Therefore, the following detailed description of the embodiments of the present application provided in the drawings is not intended to limit the scope of the claimed present application, but merely represents selected embodiments of the present application. Based on the embodiments of the present application, all other embodiments obtained by those skilled in the art without creative efforts fall within the scope of protection of the present application.

[0051] In the following, the terms "including", "having" and their cognates that can be used in various embodiments of the present application are only intended to indicate specific features, numbers, steps, operations, elements, components or combinations of the foregoing items, and should not be construed as first excluding the existence of one or more other features, numbers, steps, operations, elements, components or combinations of the foregoing items or increasing the possibility of one or more features, numbers, steps, operations, elements, components or combinations of the foregoing items. In addition, the terms "first", "second", "third", etc. are only used for differential description and cannot be understood as indicating or implying relative importance.

[0052] Unless otherwise defined, all terms (including technical terms and scientific terms) used herein have the same meaning as commonly understood by those of ordinary skill in the art to which the various embodiments of the present application belong. The terms (such as those defined in a commonly used dictionary) will be interpreted as having the same meaning as the contextual meaning in the relevant technical field and will not be interpreted as having an idealized meaning or being overly formal, unless clearly defined in the various embodiments of the present application.

[0053] Next, in conjunction with the accompanying drawings, some implementation manners of the present application will be described in detail. Without conflict, the following embodiments and the features in the embodiments can be combined with each other.

[0054] In the prior art, when using a deep learning convolutional neural network to segment an image, the processing speed may be too slow; when using a traditional machine vision method to segment an image, the generalization ability may be insufficient and the accuracy rate may be low. Especially on a low-performance ARM industrial control board, it is a great challenge to achieve accurate and rapid medical image threshold segmentation.

[0055] Accordingly, the present application provides a method for calculating parameters related to an image segmentation threshold, a segmentation method, and an electronic device, which can effectively solve the problems of slow processing speed and low accuracy of the image threshold segmentation method applied to an ARM industrial control board in the prior art, etc.

[0056] The present application first provides an electronic device. Exemplarily, the electronic device includes a processor and a memory. The memory stores a computer program, and the processor is configured to execute the computer program to implement a dynamic threshold image segmentation method provided by the present application. Both the weight parameter and the normalization parameter used in the dynamic threshold image segmentation method of the embodiments of the present application are obtained by using a method for calculating parameters related to an image segmentation threshold provided by the embodiments of the present application.

[0057] Further, the electronic device includes, but is not limited to, an ARM industrial control board. The products corresponding to the electronic device of the present application include, but are not limited to, hair removal devices. By using the dynamic threshold image segmentation method of the present application, the recognition accuracy of the hair removal device can be improved, and the effect of the hair removal device can be enhanced.

[0058] Next, some specific embodiments will be combined to illustrate the method for calculating parameters related to the image segmentation threshold.

[0059] Figure 1 FIG. shows a flowchart of a method for calculating parameters related to an image segmentation threshold according to an embodiment of the present application. Exemplarily, the method for calculating parameters related to an image segmentation threshold is applicable to a PC or a tablet computer. The method for calculating parameters related to an image segmentation threshold includes the following steps:

[0060] S110, segment the original sample image by a feature marker based on a dynamically adjusted segmentation threshold, and use the adjusted threshold for obtaining the target contour map as the first segmentation threshold. The target contour map is the contour map obtained when an expected segmentation effect is achieved. Based on a preset feature selection rule, determine N features, and calculate the feature values corresponding to the N features based on the target contour map; where N is an integer greater than 0. The expected segmentation effect is an ideal segmentation effect, that is, when the original sample image is segmented using the first segmentation threshold, the target contour map with an ideal segmentation effect is obtained. The present application first collects the original sample image, and the original sample image varies according to the different work contents executed by the electronic device. For example, when the electronic device is a hair removal device, the original sample image is a skin sample image.

[0061] The criteria for the above ideal segmentation effect include at least two or more combinations of clear and complete main body, thorough separation of the main body from the background, accurate position and shape of the main body, retention of internal details, satisfaction of robustness and consistency, matching of the target quantity with the actual situation, and satisfaction of interpretability and practicability. Specifically, it is determined according to the working object of the electronic device and the accuracy requirement for the target contour map. The present application does not make specific limitations on this.

[0062] 1) The main body is clear and complete.

[0063] The target boundary is clear: The boundary between the segmented target object (such as characters, regions, and when the electronic device is a hair removal device, the target object is hair) and the background is distinct, without blurring or burrs.

[0064] The body has no missing parts: The key parts of the target object (such as contours, details) are completely retained, without loss or breakage.

[0065] There is no artifact or noise: There are no abnormal points, small pieces of noise, or redundant regions in the segmentation result caused by algorithms or preprocessing.

[0066] 2) The main body is completely separated from the background.

[0067] The background is pure: The background area is completely marked as a single background value (such as black), without residue or mixed pixels of the target object.

[0068] The main body has no adhesion: There is no adhesion or fusion between the target objects, maintaining independent distinguishability.

[0069] The contrast is obvious: The gray / color difference between the target and the background is significant, facilitating visual judgment and subsequent processing.

[0070] 3) The position and shape of the main body are accurate.

[0071] The main body is centered or aligned: If the target object has clear position requirements (such as text lines, cells), the segmentation result should conform to the expected arrangement or centering rules.

[0072] The shape is maintained: The shape and proportion of the target object are consistent with the original image, without distortion or deformation.

[0073] The size is reasonable: The size of the segmented area matches the actual size of the target object, without excessive magnification or reduction.

[0074] 4) Internal details are retained.

[0075] The texture or structure is clear: The texture, lines, or structure (such as cell nuclei, blood vessels) inside the target object can still be identified after segmentation.

[0076] The edge is smooth: The edge of the target object is smooth, without serrated or stepped artifacts.

[0077] No details are lost: Small targets or detailed features (such as character strokes, cell edges) are not misjudged as the background.

[0078] 5) Robustness and consistency are satisfied.

[0079] Robust to light or noise: The segmentation result is insensitive to illumination changes and noise interference in the image, maintaining stability.

[0080] Consistency of the same type of objects: The segmentation results of the same type of objects (such as multiple cells, characters) are consistent in shape, size, and position.

[0081] 6) The number of objects matches the actual situation.

[0082] Accurate number of objects: The number of target objects segmented is the same as the number of objects in the actual image, without omission or redundancy.

[0083] No repeated segmentation: The same target object is not repeatedly segmented into multiple regions.

[0084] 7) Meet interpretability and practicality.

[0085] Easy to analyze: The segmentation result can be directly used for subsequent image analysis (such as measurement, classification) without additional processing.

[0086] Meet the requirements of the field: The segmentation result meets the visual or functional requirements of a specific field (such as medicine, industrial inspection).

[0087] In this application, a feature marker is pre-constructed. The segmentation threshold can be dynamically adjusted in the feature marker, and the original sample image is segmented based on the dynamically adjusted segmentation threshold. Moreover, the feature marker can also give the target contour map of the expected segmentation effect.

[0088] After obtaining the expected segmentation effect and getting the target contour map, the segmentation threshold used when obtaining the target contour map, that is, the first segmentation threshold, can also be obtained.

[0089] In this application, according to the different work contents executed by the electronic device, a feature selection rule is set, and the corresponding feature values are extracted according to the feature selection rule.

[0090] S120, use the first segmentation threshold corresponding to each original sample image to mark the corresponding N feature values to construct a training data set.

[0091] To better train the single-layer image segmentation model of this application, first use the corresponding first segmentation threshold to mark the feature values corresponding to each original sample image, so that the single-layer image segmentation model can better learn the target features.

[0092] S130, perform iterative training on the constructed single-layer image segmentation model based on the training data set to obtain the standardized parameters and weight parameters corresponding to the N features; among them, the standardized parameters and weight parameters are used to obtain the target segmentation threshold based on the N feature values of the image to be measured.

[0093] In one embodiment, the original sample image is segmented by a feature marker based on a dynamically adjusted segmentation threshold, and the adjusted threshold corresponding to the target contour map with the desired segmentation effect is used as the first segmentation threshold, including:

[0094] S111, input the original sample image into the feature marker, so that the feature marker performs image segmentation based on the configured empirical segmentation threshold and displays the segmented image through a preset interface, receive the adjustment of the segmentation threshold corresponding to the operable control on the preset interface by the user, and synchronously update the segmented image on the preset interface;

[0095] S112, in response to obtaining the target contour map with the desired segmentation effect, use the currently adjusted segmentation threshold as the first segmentation threshold.

[0096] In this application, in order to reduce the operation of the user and reduce the adjustment time, an empirical segmentation threshold is default configured in the feature marker, so as to quickly obtain the target contour map with the desired segmentation effect.

[0097] Specifically, the feature marker includes a preset interface, and the preset interface includes operable controls. The size of the segmentation threshold can be adjusted through the operable controls. For example, the operable controls include but are not limited to a slider. The preset interface is also used to display the effect of the segmented image. The feature marker obtains the original sample image, displays the original sample image on the preset interface, and segments the original sample image based on the default empirical segmentation threshold to obtain the contour map of the target object; generally, the contour map effect of the target object at this time is poor. The user adjusts the segmentation threshold by dragging the slider, and the user also views the segmentation effect according to the contour map (target contour map) of the target object obtained based on the current segmentation threshold on the preset interface until the user determines to obtain the target contour map with the desired segmentation effect, then stops dragging the slider, that is, stops adjusting the segmentation threshold, saves the current segmentation threshold, and obtains the first segmentation threshold. In the embodiment of this application, the user manually drags the slider and observes the real-time feedback of the output contour map to obtain the optimal result.

[0098] In one embodiment, determining N features based on a preset feature selection rule, and calculating the feature values corresponding to the N features based on the target contour map, including:

[0099] S113, convert the original sample image in RGB format to the Lab (CIELab) color space, and then extract the monochromatic image of the L channel; the monochromatic image is a grayscale image. After conversion to the Lab color space, the L channel forms a grayscale image (corresponding to the monochromatic image) that only focuses on light and dark. After conversion to the Lab color space, the contrast is higher and the features are more obvious.

[0100] S114, generate a contour map based on the monochromatic image and the step size determined according to the feature selection rule.

[0101] S115. Extract the corresponding gray value from the contour map according to each of the N features to obtain the corresponding feature value.

[0102] Further, determine the N features based on a preset feature selection rule, including:

[0103] S116. Determine N - 1 features based on N - 1 preset pixel thresholds, and determine one feature based on the input target recognition region; the target recognition region is the main treatment region (main treatment site), and according to the target recognition region, its features can be significantly enhanced and the accuracy can be improved.

[0104] Among them, the N - 1 preset pixel thresholds include: determine N - 1 features based on N - 1 preset pixel thresholds, and determine one feature based on the input target recognition region; among them, the N - 1 preset pixel thresholds include: the first low pixel threshold corresponding to removing dark noise, the second high pixel threshold corresponding to removing bright noise, the second low pixel threshold corresponding to removing dark noise, the third high pixel threshold corresponding to removing bright noise, the third low pixel threshold for removing black dark spots, the fourth high pixel threshold for removing white bright spots, the gray median, the gray average, the gray standard deviation, multiple pixel thresholds divided according to the first wide step based on the first pixel section, and multiple pixel thresholds divided according to the second wide step based on the second pixel section.

[0105] Among them, the first pixel section is the pixel interval determined by the median of the effective gray level to the fifth high pixel threshold; the second pixel section is the pixel interval determined by the fifth high pixel threshold to the first high pixel threshold.

[0106] Among them, 0% < the first low pixel threshold < the second low pixel threshold < the third low pixel threshold < the median of the effective gray level < the fifth high pixel threshold (the lower limit value of the interval to be detected) < the fourth high pixel threshold < the third high pixel threshold < the second high pixel threshold < the first high pixel threshold ≤ 100% (100% of the overall gray value of the pixel set). The first wide step > the second wide step. The value range of the first wide step is 0.4% - 0.55%, and one feature is taken every first wide step. The value range of the second wide step is 0.06% - 0.14%, and one feature is taken every first wide step.

[0107] Table 1 Feature Selection Rule

[0108]

[0109]

[0110]

[0111] Exemplarily, a contour map is generated based on a monochromatic image and a step size determined according to a feature selection rule, including: dividing a gray level ladder based on each pixel threshold determined in Table 1, and generating a contour map according to each gray level ladder and the monochromatic image. It can be understood that according to each selected feature, the corresponding gray value is extracted from the contour map to obtain the corresponding feature value, including: extracting the corresponding feature values from the contour map according to N (N = n in the embodiments of the present application) features determined according to the feature selection rule.

[0112] Further, the corresponding N feature values are marked with the first segmentation threshold corresponding to each original sample image to construct a training data set, including: obtaining a piece of sub-data according to the correspondence between the first segmentation threshold and the corresponding N feature values, filling the sub-data into a row of the training data table, and further obtaining a training data set in tabular form from the sub-data of each original sample image, as shown in Table 2.

[0113] Table 2 Training data set

[0114]

[0115] The purpose of the feature extractor in the present application is to obtain the segmentation threshold corresponding to the ideal segmentation result through the method of manual annotation. That is, to obtain the "feature-label" pair corresponding to the desired segmentation effect as the training data set to prepare for the next model training. Compared with the data annotation in the prior art, the present application is more intuitive and accurate.

[0116] Further, before converting the original sample image in RGB format to the Lab color space, it also includes:

[0117] Performing inverse gamma correction on the RGB values in the original sample image in RGB format, and converting the corrected RGB values to the Lab color space.

[0118] In other words, converting the original sample image in RGB format to the Lab color space includes:

[0119] 1) Normalizing the RGB values of the original sample image to the range of [0, 1].

[0120] 2) Linearizing the RGB values and performing inverse gamma correction on the RGB values. Exemplarily, the following formula is used for inverse gamma correction:

[0121]

[0122] where thr represents the demarcation threshold between the linear and non-linear intervals, and the value range of thr is 0.04039 - 0.04050, which is derived from the formula thr = coefficientL / coefficientH * scale;

[0123] The scale represents the scaling factor of the linear interval, which is used to compensate for the non - linear distortion of low - brightness values. The value range of scale is 12.89 - 12.95.

[0124] Both coefficientL and coefficientH represent the adjustment coefficients of the non - linear interval, ensuring that the function is continuous and has a smooth transition at the demarcation point. The value range of coefficientL is 0.055, and the value range of coefficientH is 1.055. gmma = 2.4.

[0125] 3) Use the transformation matrix to convert the linear RGB values into XYZ values.

[0126] 4) Normalize the XYZ values. Compare the XYZ values with the reference white point, and usually D65 is used as the white point.

[0127] 5) Calculate the corresponding values of L, a, and b using the following formula:

[0128] L * = 116·f(Y)-16

[0129] a * = 500·(f(X)-f(Y))

[0130] b * = 200·(f(Y)-f(Z))

[0131] In one implementation, the single - layer image segmentation model includes a single - layer fully - connected network; the single - layer fully - connected network includes N input neurons and one output neuron.

[0132] Iteratively train the constructed single - layer image segmentation model based on the training dataset to obtain the normalization parameters and weight parameters corresponding to N features, including:

[0133] Input the N feature values one - by - one into the N input neurons, use the second segmentation threshold fitted according to the N first segmentation thresholds as the training target, iteratively train the single - layer fully - connected network, and at the same time use the gradient descent method to optimize the parameters to obtain the weight parameters and normalization parameters; the weight parameters include the bias and the weights corresponding to each feature; the normalization parameters include the mean value and standard deviation corresponding to each feature.

[0134] Specifically, the training process includes:

[0135] 1) Construct a single - layer fully - connected network with the number of input neurons being n and the number of output neurons being 1, as Figure 2 shown.

[0136] 2) Fit the N first segmentation thresholds to obtain the second segmentation threshold, and use the above training dataset for training with the second segmentation threshold as the training objective.

[0137] 3) During the training process, the mean squared error is used to evaluate the loss. Among them, the calculation formula of the mean squared error MSE is as follows:

[0138]

[0139] Among them, n is the number of samples, y i is the true value of the i-th sample, is the predicted value of the i-th sample. 4) The stochastic gradient descent method is used to optimize the parameters during training. The formula of stochastic gradient descent is as follows:

[0140]

[0141] Among them, θ represents the model parameters, η represents the learning rate, represents the gradient, and represents the gradient of the loss function with respect to the parameters. It is a vector pointing in the direction of the fastest growth of the function.

[0142] 5) Standardize the N eigenvalues. Calculate the mean, standard deviation and other standardization parameters of the standardized features during the training process, and save them to the standardization parameter table file, as shown in Table 3.

[0143] Table 3 Standardization parameter table file

[0144] Feature 1 Feature 2 Feature 3 ... Feature n Average value xxx xxx xxx xxx Standard deviation xxx xxx xxx xxx

[0145] The above mean (average value) is the arithmetic mean of all sample eigenvalues; the standard deviation of the feature measures the degree of dispersion of the eigenvalues. Standardize the features using the calculated mean and standard deviation to standardize each eigenvalue.

[0146] 6) Obtain the bias and the weights corresponding to each feature through training iteration and convergence, and save them to the weight parameter table file, as shown in Table 4.

[0147] Table 4 Weight parameter table file

[0148]

[0149] Specifically, the gradient descent method is used to update the weights and biases of the model in the direction of minimizing the loss function, including the following key steps:

[0150] (1) Initialize the parameters: Randomly initialize the weights and biases.

[0151] (2) Forward propagation: Calculate the predicted value using the current weights and biases.

[0152] (3) Calculate the loss: Calculate the loss (error) by comparing the predicted value and the true value.

[0153] (4) Backpropagation: Calculate the gradients of the loss with respect to the weights and biases.

[0154] (5) Update the parameters: Adjust the weights and biases according to the gradients.

[0155] (6) Repeat steps (2)-(5): Until a predetermined number of iterations is reached or the loss converges to a sufficiently small value.

[0156] Figure 3 A flowchart of a dynamic threshold image segmentation method according to an embodiment of the present application is shown. Exemplarily, the dynamic threshold image segmentation method includes the following steps:

[0157] S210, Obtain the original image to be segmented and convert it into a monochromatic image.

[0158] On an electronic device, such as on a hair removal device, obtain the original image to be segmented, convert the original image into the Lab color space, and extract the features on the L channel to obtain a monochromatic image (grayscale image).

[0159] S220, Extract the feature values corresponding to N features determined based on a preset feature selection rule from the monochromatic image to obtain N feature values.

[0160] Based on the intervals between the N features determined by the preset feature selection rule, generate a contour map according to the monochromatic image, and extract the feature values (gray values) of the N features based on the contour map.

[0161] S230, Standardize the N feature values extracted according to the standardization parameters.

[0162] Further, the standardization parameters include the average value and standard deviation corresponding to each of the N features;

[0163] Standardizing the N feature values extracted according to the standardization parameters includes standardizing the N feature values using the following formula:

[0164]

[0165] where, x i represents the i-th feature value, μ i represents the average value corresponding to the i-th feature, σ i represents the standard deviation corresponding to the i-th feature, and n represents the total number of features.

[0166] S240. Calculate the target segmentation threshold using the weight parameters and the N normalized eigenvalue. The weight parameters and the normalization parameters are obtained by using the calculation method of the image segmentation threshold related parameters in the embodiments of the present application.

[0167] In the ARM industrial control board of the present application, there is no need to run a deep learning algorithm model. Only determine N features according to the preset feature selection rules, and extract the corresponding N features. Finally, process the N features according to the weight parameters and the normalization parameters to obtain the target segmentation threshold, with less calculation amount and fast processing speed. The weight parameters include the bias and the weights corresponding to the N features respectively.

[0168] Further, calculating the target segmentation threshold using the weight parameters and the N normalized eigenvalue includes obtaining the target segmentation threshold by using the following formula:

[0169] y = w1x1 + w2x2 + … + w n x n + b

[0170] where y represents the target segmentation threshold, w i represents the weight corresponding to the i-th feature, x i represents the i-th eigenvalue, and b represents the bias.

[0171] S250. Based on the monochromatic image, perform image segmentation according to the target segmentation threshold to obtain the target segmentation image. For example, based on the monochromatic image, perform binary segmentation according to the target segmentation threshold to obtain the target segmentation image.

[0172] S260. Use the preset morphological operations to optimize the target segmentation image, and draw the target based on the contour to obtain the final target object image.

[0173] Specifically, using the preset morphological operations to optimize the target segmentation image includes:

[0174] Use the dilation operation in the morphological operations to merge the target regions; use the erosion operation in the morphological operations to eliminate the holes.

[0175] The purpose of the dilation operation is to expand the boundaries of the target regions so that they "dilate" or increase. The dilation operation is performed through a structuring element (Structuring Element or Kernel). The structuring element is a small matrix used to determine which pixels should be merged into the target regions. The specific dilation operation process includes:

[0176] Place the structuring element: Place the structuring element at a certain position in the image.

[0177] Matching and filling: For each pixel in the structural element, if the pixel is within the target area, mark the position corresponding to the center of the structural element as part of the new area.

[0178] Moving the structural element: Move the structural element to the next position in the image and repeat the above process until the entire image is traversed.

[0179] First, in this application, the gray-scale distribution of the image is deeply analyzed, and representative features are formed by extracting gray-scale contour lines, reducing the computational amount of feature extraction. Second, a customized feature extractor is designed to build a learning model with artificial supervision.

[0180] Finally, in the visual search algorithm, a binary threshold segmentation technique is used to separate instances, and a linear regression network is used to predict the corresponding threshold.

[0181] In this application, by combining a single-layer neural network with traditional vision techniques, the computational requirements for image processing are effectively reduced (the computational amount is reduced), making it possible to deploy on a low-performance ARM platform.

[0182] Figure 4 FIG. shows a schematic structural diagram of a dynamic threshold image segmentation device according to an embodiment of the present application. Exemplarily, the dynamic threshold image segmentation device includes: an image conversion module 410, a feature extraction module 420, a normalization module 430, a threshold calculation module 440, and a segmentation module 450.

[0183] The image conversion module 410 is configured to obtain the original image to be segmented and convert it into a monochrome image;

[0184] The feature extraction module 420 is configured to extract the feature values corresponding to N features determined based on a preset feature selection rule from the monochrome image to obtain N feature values;

[0185] The normalization module 430 is configured to normalize the N feature values extracted according to normalization parameters;

[0186] The threshold calculation module 440 is configured to calculate the target segmentation threshold by using weight parameters and the normalized N feature values; wherein, the weight parameters and the normalization parameters are both obtained by using the calculation method of the image segmentation threshold related parameters in the embodiment of the present application;

[0187] The segmentation module 450 is configured to perform binary segmentation on the monochrome image according to the target segmentation threshold to obtain the target segmentation image.

[0188] It can be understood that the device in this embodiment corresponds to the dynamic threshold image segmentation method in the above embodiment, and the optional items in the above embodiment are also applicable to this embodiment, so they will not be repeated here.

[0189] The present application also provides a terminal device. Exemplarily, the terminal device includes a processor and a memory. Among them, the memory stores a computer program, and the processor executes the above-mentioned dynamic threshold image segmentation method or the functions of each module in the above-mentioned dynamic threshold image segmentation device by running the computer program.

[0190] Among them, the processor can be an integrated circuit chip with signal processing capabilities. The processor can be a general-purpose processor, including at least one of a central processing unit (CPU), a graphics processing unit (GPU), a network processor (NP), a digital signal processor (DSP), an application specific integrated circuit (ASIC), a field programmable gate array (FPGA), or other programmable logic devices, discrete gate or transistor logic devices, and discrete hardware components. The general-purpose processor can be a microprocessor or the processor can also be any conventional processor, etc., and can implement or execute the various methods, steps, and logic block diagrams disclosed in the embodiments of the present application.

[0191] The memory can be, but is not limited to, a random access memory (RAM), a read-only memory (ROM), a programmable read-only memory (PROM), an erasable programmable read-only memory (EPROM), an electrically erasable programmable read-only memory (EEPROM), etc. Among them, the memory is used to store the computer program, and after receiving the execution instruction, the processor can execute the computer program accordingly.

[0192] The present application also provides a computer-readable storage medium for storing the computer program used in the above terminal device. For example, the computer-readable storage medium can include, but is not limited to: various media such as a USB flash drive, a mobile hard disk, a read-only memory (ROM, Read-Only Memory), a random access memory (RAM, Random Access Memory), a magnetic disk, or an optical disc that can store program codes.

[0193] In several embodiments provided in this application, it should be understood that the disclosed devices and methods can also be implemented in other ways. The device embodiments described above are merely illustrative. For example, the flowcharts and structure diagrams in the accompanying drawings show the possible architectures, functions, and operations of devices, methods, and computer program products according to multiple embodiments of this application. In this regard, each block in the flowchart or block diagram can represent a module, a program segment, or a part of code, and the module, program segment, or part of code contains one or more executable instructions for implementing the specified logical function. It should also be noted that in an alternative implementation, the functions marked in the blocks can occur in a different order from that marked in the accompanying drawings. For example, two consecutive blocks can actually be executed substantially in parallel, and they can sometimes be executed in the reverse order, depending on the functions involved. It should also be noted that each block in the structure diagram and / or flowchart, as well as the combination of blocks in the structure diagram and / or flowchart, can be implemented by a dedicated hardware-based system that performs the specified functions or actions, or can be implemented by a combination of dedicated hardware and computer instructions.

[0194] In addition, each functional module or unit in various embodiments of this application can be integrated together to form an independent part, or each module can exist alone, or two or more modules can be integrated to form an independent part.

[0195] If the above functions are implemented in the form of software function modules and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, or a part of this technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions for causing a computer device (which can be a smart phone, a personal computer, a server, or a network device, etc.) to execute all or part of the steps of the methods described in various embodiments of this application.

[0196] As mentioned above, the above is only the specific implementation manner of this application, but the protection scope of this application is not limited thereto. Any person skilled in the art within the technical scope disclosed in this application can easily think of changes or substitutions, and all should be covered by the protection scope of this application.

Claims

1. A method for calculating parameters related to an image segmentation threshold, characterized in that, Including: Segmenting the original sample image by a feature marker based on a dynamically adjusted segmentation threshold, and using the adjusted threshold for obtaining the target contour map as the first segmentation threshold, where the target contour map is the contour map obtained when an expected segmentation effect is achieved; determining N features based on a preset feature selection rule, and calculating the feature values corresponding to the N features based on the target contour map; where N is an integer greater than 0; Marking the N feature values corresponding to each of the original sample images with the first segmentation threshold corresponding to each original sample image to construct a training data set; Based on the training data set, iteratively training the constructed single-layer image segmentation model to obtain the normalization parameters and weight parameters corresponding to the N features respectively; where the normalization parameters and the weight parameters are used to obtain the target segmentation threshold based on the N feature values of the image to be measured.

2. The calculation method of the parameters related to the image segmentation threshold according to claim 1, characterized in that, The segmenting the original sample image by a feature marker based on a dynamically adjusted segmentation threshold and using the adjusted threshold corresponding to the target contour map with an expected segmentation effect as the first segmentation threshold includes: Inputting the original sample image into the feature marker, so that the feature marker performs image segmentation based on a configured empirical segmentation threshold and displays the segmented image through a preset interface, receiving the adjustment of the segmentation threshold corresponding to the operable control on the preset interface by the user and synchronously updating the segmented image on the preset interface; In response to obtaining the target contour map with an expected segmentation effect, taking the currently adjusted segmentation threshold as the first segmentation threshold.

3. The calculation method of the parameters related to the image segmentation threshold according to claim 1, characterized in that, The determining N features based on a preset feature selection rule and calculating the feature values corresponding to the N features based on the target contour map includes: Converting the original sample image in RGB format to the Lab color space, and then extracting the monochromatic image of the L channel; Generating a contour map based on the monochromatic image and a step size determined according to the feature selection rule; Extracting the corresponding gray value from the contour map according to each of the N features to obtain the corresponding feature value.

4. The calculation method of the parameters related to the image segmentation threshold according to claim 1, characterized in that, The determining N features based on a preset feature selection rule includes: Determining N - 1 features based on N - 1 preset pixel thresholds, and determining one feature based on the input target recognition region; where the preset N - 1 pixel thresholds include: the first low pixel threshold for removing dark noise, the second high pixel threshold for removing bright noise, the second low pixel threshold for removing dark noise, the third high pixel threshold for removing bright noise, the third low pixel threshold for removing black dark spots, the fourth high pixel threshold for removing white bright spots, the gray median, the gray average value, the gray standard deviation, multiple pixel thresholds divided based on a first pixel section according to a first wide step size, and multiple pixel thresholds divided based on a second pixel section according to a second wide step size; Wherein, the first pixel section is the pixel interval determined by the median of the effective gray scale to the fifth high pixel threshold; the second pixel section is the pixel interval determined by the fifth high pixel threshold to the first high pixel threshold.

5. The calculation method of the image segmentation threshold-related parameter according to any one of claims 1-4, characterized in that The single-layer image segmentation model includes a single-layer fully connected network; the single-layer fully connected network includes N input neurons and one output neuron; Based on the training data set, iteratively training the constructed single-layer image segmentation model to obtain the standardized parameters and weight parameters corresponding to the N features, including: Inputting the N feature values one by one into the N input neurons, using the second segmentation threshold fitted according to the N first segmentation thresholds as the training target, iteratively training the single-layer fully connected network, and at the same time using the gradient descent method to optimize the parameters to obtain the weight parameters and the standardized parameters; the weight parameters include the bias and the weight corresponding to each feature; the standardized parameters include the average value and the standard deviation corresponding to each feature.

6. The calculation method of the parameters related to the image segmentation threshold according to claim 3, characterized in that, Before converting the original sample image in RGB format to the Lab color space, it further includes: Performing inverse gamma correction on the RGB values in the original sample image in RGB format, and converting the corrected RGB values to the Lab color space.

7. A dynamic threshold image segmentation method, characterized in that, It includes: Obtaining the original image to be segmented and converting it into a monochrome image; Extracting the feature values corresponding to N features determined based on a preset feature selection rule from the monochrome image to obtain N feature values; Using the weight parameters and the standardized N feature values to calculate the target segmentation threshold; wherein, the weight parameters and the standardized parameters are both obtained by using the calculation method of the image segmentation threshold-related parameters described in any one of claims 1-6. Based on the monochrome image, performing image segmentation according to the target segmentation threshold to obtain the target segmentation image.

8. The dynamic threshold image segmentation method according to claim 7, wherein It further includes: Standardizing the extracted N feature values according to the standardized parameters; wherein, the standardized parameters include the average value and the standard deviation corresponding to the N features respectively; Further, the standardizing the extracted N feature values according to the standardized parameters includes standardizing the N feature values by using the following formula: where x i represents the i-th eigenvalue, μ i represents the average value corresponding to the i-th feature, σ i represents the standard deviation corresponding to the i-th feature, and n represents the total number of features.

9. The dynamic threshold image segmentation method according to claim 7 or 8, characterized in that The weight parameters include the bias and the weights corresponding to the N features respectively; The using the weight parameters and the standardized N feature values to calculate the target segmentation threshold includes obtaining the target segmentation threshold by using the following formula: y = w1x1 + w2x2 + … + w n x n + b where y represents the target segmentation threshold, w i represents the weight corresponding to the i-th feature, x i represents the i-th feature value, and b represents the bias.

10. An electronic device, characterized in that, The electronic device includes a processor and a memory, the memory stores a computer program, and the processor is configured to execute the computer program to implement the dynamic threshold image segmentation method described in any one of claims 7-9.

Citation Information

Cited By

  • Ischemic cerebrovascular disease angiography image segmentation analysis method

    CN120876510A

  • Ischemic cerebrovascular disease angiogram image segmentation analysis method

    CN120876510B