A region of interest processing method, device, equipment and storage medium
By combining deep learning and traditional adaptive threshold segmentation methods, and utilizing binary mask image processing, skeleton extraction, and distance transformation techniques, the accuracy and versatility issues of ROI extraction and coarse measurement for industrial products are solved, achieving high-precision ROI extraction and measurement.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- WUHAN JINGCE ELECTRONICS GRP CO LTD
- Filing Date
- 2026-04-09
- Publication Date
- 2026-07-31
AI Technical Summary
Existing methods for extracting ROI from industrial products lack accuracy in complex contexts, especially in the segmentation of elongated target regions, and there are errors in the measurement of the thickness of connected components. Their versatility needs to be improved.
By combining deep learning segmentation models with traditional adaptive threshold segmentation, the target segmentation threshold is determined through binary mask image processing and dilation difference. Combined with skeleton extraction and distance transformation techniques, the ROI is accurately extracted and its coarseness is measured.
It significantly improves the accuracy and robustness of ROI extraction, ensures accurate extraction of target regions and noise removal in complex backgrounds, has high measurement accuracy, adapts to different types of connected domains, reduces errors, and improves product qualification rate.
Smart Images

Figure CN122493022A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of image defect detection technology, specifically to a method, apparatus, device, and storage medium for processing regions of interest. Background Technology
[0002] In image-based industrial product defect detection, it is necessary to accurately extract the ROI (Region of Interest) of the product in the image and measure the ROI's thickness, area, and other morphological indicators. Then, control thresholds are set based on the morphological indicators to screen out unqualified products and improve the pass rate of shipped products.
[0003] Existing methods for extracting ROI from industrial products can be broadly categorized into two types: traditional threshold-based segmentation methods and deep learning-based segmentation model methods. Threshold-based segmentation methods are suitable for scenarios where the target and background grayscale values differ significantly, or where the background is uniform and not connected to the target area. Deep learning-based segmentation model methods can effectively overcome the shortcomings of traditional threshold-based segmentation methods and are suitable for scenarios with complex backgrounds and low contrast; however, these methods often fail to accurately distinguish target boundaries when segmenting long and narrow target areas (such as the adhesive lines applied to the surface of a manufacturing screen), and may even segment the same connected region into multiple regions.
[0004] In measuring the coarseness of connected components, the current mainstream approach is as follows: determine the endpoints of the connected component; extract the two boundaries along the extension direction of the connected component and obtain the coordinate set of the boundary points; for each point on one boundary, calculate the point with the shortest distance to the other boundary to form two sets of point pairs; for each set of point pairs, calculate the pair with the largest distance and the pair with the smallest distance, and take the larger of the pair with the largest distance and the smaller of the pair with the smallest distance as the coarsest and thinnest positions of the connected component. Although this method is relatively simple, it requires more effort in handling details, such as: determining the endpoints of the connected component and extracting boundary points often requires customized implementation logic based on the shape of the connected component, and its versatility needs to be improved; it is difficult to handle cases where the endpoints do not intersect with the image boundaries; the measurement lines at the coarsest and thinnest positions are often not strictly perpendicular to the direction of the connected component, introducing unnecessary errors to the measurement indicators. Summary of the Invention
[0005] This application provides a method, apparatus, device, and storage medium for processing regions of interest, which can effectively improve the extraction accuracy and the accuracy and versatility of coarseness measurement.
[0006] In a first aspect, embodiments of this application provide a method for processing regions of interest, the method comprising: The original image is segmented based on a deep learning segmentation model to obtain a binary mask image representing the target region, and the original image is then converted into a grayscale image. Based on the effective pixel positions in the binary mask image, the pixel values at the corresponding positions in the grayscale image are extracted to determine the grayscale value of the target region; The binary mask image is dilated to obtain a dilated binary image. The difference between the dilated binary image and the binary mask image is used as a background region mask. Based on the effective pixel positions in the background region mask, the pixel values at the corresponding positions in the grayscale image are extracted to determine the grayscale value of the background region. A target segmentation threshold is determined based on the grayscale values of the target region and the background region. The grayscale image is then segmented using the target segmentation threshold to obtain a re-segmented binary image. Non-target region content in the re-segmented binary image is removed based on the dilated binary image to obtain the target binary image.
[0007] In conjunction with the first aspect, in one implementation, after obtaining the target binary image, the method further includes: Extract all connected components from the target binary image, and extract the skeleton of each connected component to obtain a skeleton point set; Perform a distance transformation on each connected component to obtain a distance-transformed graph; Traverse the set of skeleton points, determine the distance value corresponding to each skeleton point according to the distance transformation diagram, and filter out the extreme distance points. The coarseness value of the connected component is calculated based on the distance extreme points.
[0008] In conjunction with the first aspect, in one implementation, prior to extracting all connected components from the target binary image, the method further includes: The target binary image is subjected to morphological optimization processing, which includes hole filling, opening operation, and / or closing operation.
[0009] In conjunction with the first aspect, in one implementation, determining the target segmentation threshold based on the grayscale values of the target region and the background region includes: Calculate the weighted average of the grayscale values of the target region and the background region, and use the weighted average as the target segmentation threshold.
[0010] Secondly, embodiments of this application provide another method for processing regions of interest, the method comprising: Extract all connected components from the target binary image, and extract the skeleton of each connected component to obtain a set of skeleton points; Perform a distance transformation on each connected component to obtain a distance-transformed graph; Traverse the set of skeleton points, determine the distance value corresponding to each skeleton point according to the distance transformation diagram, and filter out the extreme distance points. The coarseness value of the connected component is calculated based on the distance extreme points.
[0011] In conjunction with the second aspect, in one implementation, calculating the coarseness value of the connected component based on the distance extreme point includes: Extract the set of contour points of the connected component, and search for candidate contour points within a preset neighborhood range of the distance extreme point; Calculate the direction vector of the skeleton line near the extreme point; Based on the vector relationship between the direction vector and the candidate contour points, target contour points located on both sides of the skeleton line are selected. Calculate the distance between the target contour points on both sides, and use it as the thickness value of the connected region at the extreme point of the distance.
[0012] In conjunction with the second aspect, in one embodiment, after calculating the coarseness value of the connected component based on the distance extreme points, the method further includes: Compare and record the maximum and minimum thickness values of each connected component to obtain the global maximum and minimum thickness values.
[0013] Thirdly, embodiments of this application provide a region of interest processing apparatus, the region of interest processing apparatus comprising: An image processing module is used to segment the original image to obtain a binary mask image representing the target region, and to convert the original image into a grayscale image; The calculation module extracts the pixel value at the corresponding position in the grayscale image based on the effective pixel position in the binary mask image to determine the grayscale value of the target region; the calculation module is also used to dilate the binary mask image to obtain an dilated binary image, use the difference between the dilated binary image and the binary mask image as a background region mask, and extract the pixel value at the corresponding position in the grayscale image based on the effective pixel position in the background region mask to determine the grayscale value of the background region; The segmentation optimization module determines a target segmentation threshold based on the grayscale values of the target region and the background region, segments the grayscale image using the target segmentation threshold to obtain a re-segmented binary image, and removes non-target region content from the re-segmented binary image based on the dilated binary image to obtain the target binary image.
[0014] In conjunction with the third aspect, in one embodiment, a coarse measurement module is further included, the coarse measurement module being used for: Extract all connected components from the target binary image, and extract the skeleton of each connected component to obtain a skeleton point set; Perform a distance transformation on each connected component to obtain a distance-transformed graph; Traverse the set of skeleton points, determine the distance value corresponding to each skeleton point according to the distance transformation diagram, and filter out the extreme distance points. The coarseness value of the connected component is calculated based on the distance extreme points.
[0015] Fourthly, embodiments of this application provide a region of interest (ROI) processing device, which includes a processor, a memory, and a ROI processing program stored in the memory and executable by the processor, wherein when the ROI processing program is executed by the processor, it implements the steps of the ROI processing method described above.
[0016] Fifthly, embodiments of this application provide a computer-readable storage medium storing a region of interest (ROI) processing program, wherein when the ROI processing program is executed by a processor, it implements the steps of the ROI processing method described above.
[0017] The beneficial effects of the technical solutions provided in this application include: The Region of Interest (ROI) processing method in this application significantly improves the accuracy and robustness of ROI extraction by combining the advantages of deep learning segmentation and traditional adaptive threshold segmentation. Specifically, it utilizes a binary mask generated by a deep learning model to guide the calculation of the mean grayscale values of the foreground and background, thereby determining the adaptive segmentation threshold. Combined with intersection operations and morphological optimization of dilated regions, it effectively overcomes the problems of edge misalignment in single deep learning models or poor anti-interference ability of single threshold segmentation. This achieves accurate extraction of target regions and noise removal in complex backgrounds, ensuring the fundamental data quality for subsequent processing.
[0018] In ROI coarseness measurement, a versatile and high-precision measurement scheme is provided based on skeleton extraction and distance transformation technology. By traversing skeleton points and combining the distance transformation map to locate extreme points, and using direction vectors to filter contour points perpendicular to the skeleton's direction for distance calculation, this method can adapt to connected regions with different curvatures without requiring customized measurement logic for different target shapes. This not only ensures that the measurement line is strictly perpendicular to the target's direction, avoiding errors caused by oblique measurements, but also accurately obtains the global maximum and minimum coarseness values, significantly improving measurement accuracy and product pass rate screening capabilities in industrial inspection. Attached Figure Description
[0019] Figure 1 This is a flowchart illustrating an embodiment of the Region of Interest (ROI) extraction step in the Region of Interest (ROI) processing method of this application; Figure 2This is a flowchart illustrating an embodiment of the ROI coarse measurement step in the ROI processing method of this application; Figure 3 This is a schematic diagram of the connected components in this application; Figure 4 This is an overall flowchart of the region of interest processing method in this application; Figure 5 This is a schematic diagram of the relevant images during the ROI extraction and refining process of this application, where a is a grayscale image, b is a schematic diagram of the superposition of the target ROI and the grayscale image, c is a schematic diagram of removing non-target pixels, and d is the refining binary image of the target ROI. Figure 6 The images shown are schematic diagrams of relevant images during the ROI coarse measurement process of this application. a is a schematic diagram of the skeleton line, b is a distance transformation map, c is a superimposed rendering of the skeleton and distance transformation map, and d is a superimposed image of the measurement results. Figure 7 This is a schematic diagram of the functional modules of an embodiment of the region of interest processing device of this application; Figure 8 This is a schematic diagram of the hardware structure of the region of interest processing device involved in the embodiments of this application. Detailed Implementation
[0020] To enable those skilled in the art to better understand the present application, the technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present application, and not all embodiments. Based on the embodiments in the present application, all other embodiments obtained by those of ordinary skill in the art without creative effort are within the scope of protection of the present application.
[0021] To make the objectives, technical solutions, and advantages of this application clearer, the embodiments of this application will be described in further detail below with reference to the accompanying drawings.
[0022] Firstly, embodiments of this application provide a method for processing regions of interest.
[0023] In one embodiment, reference is made to Figure 1 , Figure 1 This is a flowchart illustrating the first embodiment of the region of interest processing method of this application. Figure 1 As shown, the methods for processing regions of interest include: S1. The original image is segmented based on a deep learning segmentation model to obtain a binary mask image representing the target region, and the original image is converted into a grayscale image; In step S1, the original image SrcImg, which includes the target region, is segmented into a binary mask image with the target as the foreground based on a deep learning segmentation model. The original image SrcImg is then converted into a grayscale image GrayImg.
[0024] It is worth noting that, regarding deep learning segmentation models, this embodiment does not limit the type of segmentation model. It can be a relatively general visual large model such as DINOV2, DINOV3 or SAM, or a supervised model trained on a carefully labeled dataset, such as U-Net, Mask R-CNN, BiSeNet, etc.
[0025] S2. Based on the effective pixel positions in the binary mask image, extract the pixel values at the corresponding positions in the grayscale image to determine the grayscale value of the target region; In step S2, the main process involves segmenting the grayscale image GrayImg. Calculate the mean value of the image regions with a pixel value of 255 and use it as the gray value of the target region. .
[0026] In the conventional practice of digital image processing, binary images contain only two pixel values: 0 and 255. 0 typically represents black (background or ignored areas), while 255 represents white (foreground or target areas). Therefore, the area with a pixel value of 255 mentioned in step S2 actually refers to the area in the binary image that is marked as the target or valid area.
[0027] It's worth noting that the pixel values in the binary mask image are only 0 and 255, while the pixel values in the grayscale image GrayImg are any integers between 0 and 255. A pixel value of 255 is used to determine the location; the mean value is calculated by determining the brightness value of those locations in the grayscale image GrayImg. That is, first in the binary mask image... In the image, find all coordinate points with a pixel value of 255, then read the pixel values at the corresponding positions in the grayscale image GrayImg based on these coordinate points, and finally calculate the mean.
[0028] S3. Dilate the binary mask image to obtain a dilated binary image. Use the difference between the dilated binary image and the binary mask image as a background region mask. Based on the effective pixel positions in the background region mask, extract the pixel values at the corresponding positions in the grayscale image to determine the grayscale value of the background region. In step S3, the main task is to calculate the average grayscale value of the background. First, the average grayscale value of the background is calculated. Perform a dilation operation to expand the target region outward, resulting in a dilated binary image. .use reduce Obtain the binary image of the extended region. Most pixels in this extended region are located in the background area. This is segmented from the grayscale image GrayImg. Calculate the mean value of the image region with a pixel value of 255 and use it as the gray value of the background region. .
[0029] Among them, grayscale value The calculation can be referred to the calculation method in step S2, and will not be repeated here in this embodiment.
[0030] S4. Determine the target segmentation threshold based on the gray values of the target region and the background region, segment the gray image using the target segmentation threshold to obtain a re-segmented binary image, and remove non-target region content from the re-segmented binary image based on the dilated binary image to obtain the target binary image.
[0031] In step S4, a weighted average of the grayscale values of the target region and the background region is calculated, and then the weighted average is used as the target segmentation threshold.
[0032] Specifically, take and The weighted average is used as the target segmentation threshold. The calculation formula is as follows: .
[0033] Then, based on Thresholding is performed on the grayscale image GrayImg to obtain a re-segmented binary image with grayscale values of 255 for the target region and 0 for the background region. .right and Perform intersection operation and eliminate The non-target regions in the image are used to obtain the target binary image. .
[0034] Preferably, The image may contain holes in the target area and small connected regions scattered around the target, therefore further analysis is possible. The process involves hole filling, opening operations, closing operations, and other processing to finally obtain the refined binary image of the target.
[0035] Based on the above steps, this application utilizes the semantic understanding capabilities of deep learning models for coarse localization and the edge sensitivity of traditional threshold segmentation for fine localization. By combining the advantages of both through intersection operations, it retains the adaptability of deep learning to complex backgrounds while using threshold segmentation to correct boundaries. Finally, morphological operations are used to remove noise and holes. This completes the ROI region extraction and refinement process.
[0036] Furthermore, after obtaining the target binary image, coarse measurement of the ROI region can be performed. This involves extracting all connected components from the target binary image DstImg, and then performing the following on each connected component: skeleton extraction, distance transformation, distance extremum point calculation, measurement location calculation, and coarseness value update. It is worth noting that the target binary image used for ROI region coarse measurement can be either the target binary image processed in steps S1 to S4 above, or it can be an image that has not been processed in steps S1 to S4, such as the type of target binary image used in existing technologies.
[0037] Specifically, see Figure 2 As shown, the coarse measurement of the ROI region includes the following steps: S5. Extract all connected components from the target binary image, and extract the skeleton of each connected component to obtain a skeleton point set; Step S5 mainly involves skeleton extraction. In this embodiment, it involves extracting the skeleton lines of the i-th connected component to obtain the skeleton graph and the set of skeleton points. The skeleton extraction algorithm is not limited; it can be based on thinning algorithms, such as the Zhang-Suen thinning algorithm and the Guo-Hall thinning algorithm; it can also be based on distance variation algorithms or Voronoi diagram algorithms, etc. Each algorithm has its own advantages and disadvantages in terms of accuracy and efficiency, and the choice should be made according to the application scenario.
[0038] S6. Perform distance transformation on each connected component to obtain the distance transformation graph; Step S6 mainly involves performing distance transformation. In this embodiment, the distance transformation operation is performed on the i-th connected component to obtain the distance-transformed graph. Distance transformation calculates the distance from a foreground pixel to its nearest background pixel. Points along the central axis or skeleton of the transformed connected component distance map have larger distance values than other locations; this property can be used to measure the coarseness of the connected components. Several distance metrics can be used for distance transformation, with Euclidean distance being a commonly used one. Distance), Manhattan distance ( (distance), etc. More precise distances, suitable for scenarios with significant curvature in connected components. Distance is more suitable for scenarios where the connected domains are more flat.
[0039] S7. Traverse the set of skeleton points, determine the distance value corresponding to each skeleton point according to the distance transformation diagram, and filter out the extreme distance points. Step S7 mainly involves calculating the extreme distance points. In this embodiment, a global maximum distance value is set. and global minimum distance value Traverse the set of skeleton points. For each point in the graph, record its coordinates in the distance transformation graph. The distance value at the corresponding position is compared with... and Size relationship, update and The value is recorded at the same time. and The corresponding skeleton point coordinates. Finally, the skeleton points corresponding to the maximum and minimum distances are obtained. and .
[0040] S8. Calculate the coarseness value of the connected component based on the distance extreme points.
[0041] Step S8 mainly involves calculating the measurement position. The following uses the maximum distance point (i.e., the maximum value point) as an example to illustrate the coarse measurement method for the position of the maximum value point. The coarse measurement method for the position of the minimum value point is the same.
[0042] Searching for K-nearest neighbors: Extracting the contour lines of connected components yields the set of contour points corresponding to those contour lines. Traverse the set of contour points Calculate the K contour points that are closest to the maximum point. The value of K depends on the specific application scenario; preferably, it can be 20.
[0043] Calculate the skeleton line direction vector near the maximum point. Take points with an interval of N to the left and right of the maximum value. and The value of N depends on the specific application scenario; for example, it can be set to 5. The direction vector can be calculated using the following formula:
[0044] Constructing candidate measurement points: Traverse K contour points, calculate the point-pair vector formed by the contour point and the maximum point, and calculate the point-pair vector and the direction vector. The cross product is calculated, and points with a cross product value less than 0 belong to the left contour point set, while those with a cross product value greater than 0 belong to the right contour point set. See also... Figure 3 The colored points in the graph, and the set of left and right contour points of the maximum point are collectively referred to as the candidate measurement point set of the maximum point.
[0045] Calculate the distances between the left and right contour points and the maximum point, respectively. Find the point among the left and right contour points that is closest to the maximum point and use it as the measurement point for the left and right contours. Figure 3 The red dots in the diagram represent the measurement lines. The lines connecting the measurement points of the left and right contours form the measurement lines, and the length of the measurement lines represents the maximum thickness of the i-th connected component. Similarly, the minimum thickness of the i-th connected component and its corresponding left and right contour measurement points can be obtained.
[0046] Finally, the maximum and minimum coarseness values of each connected component in the target binary image DstImg are compared and recorded, along with their corresponding measurement point information. This process ultimately yields the global maximum and minimum coarseness values and their corresponding measurement point information, thus enabling ROI coarseness measurement.
[0047] Based on the above steps, this application uses skeleton extraction to obtain an approximate central axis of the connected region and uses distance transformation to obtain the distance information from each point on the skeleton to the edge. It finds the extreme distance points by traversing the skeleton points. Using the cross product relationship between the skeleton direction vector and the contour point vector near the extreme point, it filters out the left and right contour points perpendicular to the skeleton direction, thereby calculating the thickness value strictly perpendicular to the direction. This completes the ROI coarseness measurement.
[0048] See Figure 4 The diagram shown illustrates the overall process of ROI extraction, refinement, and coarse measurement. A specific example is provided below for illustrative purposes: Regarding ROI extraction and refinement, such as Figure 5 In image 'a', the grayscale image is GrayImg, and the target ROI is the black striped region in the image. A deep learning model is used to segment the original image, obtaining a binary image of the target ROI. This binary image is then overlaid with the grayscale image GrayImg, resulting in the following effect: Figure 5 b. It can be seen that the segmentation results of the deep learning model do not strictly match the target ROI.
[0049] This application uses deep learning model segmentation results for coarse target ROI localization; based on this, a more accurate connected component segmentation threshold is calculated; then, a traditional algorithm is used to extract the ROI that closely matches the actual target. Finally, the intersection of the inflated deep learning model segmentation results and the traditional algorithm results is calculated to obtain a more accurate target ROI. After correction using the refinement method proposed in this application, the target ROI better matches its actual region, eliminating non-target pixels, such as... Figure 5 c. Finally, the refined binary image of the target ROI is obtained, as shown below. Figure 5 d.
[0050] Regarding coarse measurement, first extract the skeleton line of the target ROI, such as... Figure 6 a) Simultaneously, the set of points corresponding to the skeleton lines is obtained. A distance transform operation is performed on the binary image of the target ROI to obtain the distance transform result image, as shown below. Figure 6 b. This image reflects the distance from the target region pixel to its nearest background pixel, and objectively reflects the change in the coarseness of the target ROI. The skeleton line is an approximation of the central axis of the target ROI. The coordinates of each point on the skeleton line correspond to the local maximum pixel value at the corresponding position in the distance transformation image. The distance transformation image superimposed with the skeleton line is shown below. Figure 6c. Based on the measurement location calculation method proposed in this invention, the maximum and minimum thickness locations of the target ROI and their corresponding thickness values can be obtained, such as... Figure 6 d.
[0051] The Region of Interest (ROI) processing method in this application significantly improves the accuracy and robustness of ROI extraction by combining the advantages of deep learning segmentation and traditional adaptive threshold segmentation. Specifically, it utilizes a binary mask generated by a deep learning model to guide the calculation of the mean grayscale values of the foreground and background, thereby determining the adaptive segmentation threshold. Combined with intersection operations and morphological optimization of dilated regions, it effectively overcomes the problems of edge misalignment in single deep learning models or poor anti-interference ability of single threshold segmentation. This achieves accurate extraction of target regions and noise removal in complex backgrounds, ensuring the fundamental data quality for subsequent processing.
[0052] In ROI coarseness measurement, a versatile and high-precision measurement scheme is provided based on skeleton extraction and distance transformation technology. By traversing skeleton points and combining the distance transformation map to locate extreme points, and using direction vectors to filter contour points perpendicular to the skeleton's direction for distance calculation, this method can adapt to connected regions with different curvatures without requiring customized measurement logic for different target shapes. This not only ensures that the measurement line is strictly perpendicular to the target's direction, avoiding errors caused by oblique measurements, but also accurately obtains the global maximum and minimum coarseness values, significantly improving measurement accuracy and product pass rate screening capabilities in industrial inspection.
[0053] Secondly, embodiments of this application also provide a region of interest processing apparatus.
[0054] In one embodiment, reference is made to Figure 7 , Figure 7 This is a functional block diagram of an embodiment of the region of interest processing apparatus of this application. Figure 7 As shown, the region of interest processing device includes: An image processing module is used to segment the original image to obtain a binary mask image representing the target region, and to convert the original image into a grayscale image; The calculation module extracts the pixel value at the corresponding position in the grayscale image based on the effective pixel position in the binary mask image to determine the grayscale value of the target region; the calculation module is also used to dilate the binary mask image to obtain an dilated binary image, use the difference between the dilated binary image and the binary mask image as a background region mask, and extract the pixel value at the corresponding position in the grayscale image based on the effective pixel position in the background region mask to determine the grayscale value of the background region; The segmentation optimization module determines a target segmentation threshold based on the grayscale values of the target region and the background region, segments the grayscale image using the target segmentation threshold to obtain a re-segmented binary image, and removes non-target region content from the re-segmented binary image based on the dilated binary image to obtain the target binary image.
[0055] Furthermore, in one embodiment, a coarse measurement module is also included, the coarse measurement module being used for: Extract all connected components from the target binary image, and extract the skeleton of each connected component to obtain a skeleton point set; Perform a distance transformation on each connected component to obtain a distance-transformed graph; Traverse the set of skeleton points, determine the distance value corresponding to each skeleton point according to the distance transformation diagram, and filter out the extreme distance points. The coarseness value of the connected component is calculated based on the distance extreme points.
[0056] Further, in one embodiment, the coarseness measurement module calculates the coarseness value of the connected component based on the distance extreme point, including: Extract the set of contour points of the connected component, and search for candidate contour points within a preset neighborhood range of the distance extreme point; Calculate the direction vector of the skeleton line near the extreme point; Based on the vector relationship between the direction vector and the candidate contour points, target contour points located on both sides of the skeleton line are selected. Calculate the distance between the target contour points on both sides, and use it as the thickness value of the connected region at the extreme point of the distance.
[0057] Furthermore, in one embodiment, after calculating the coarseness value of the connected component based on the distance extreme points, the coarseness measurement module is further configured to: Compare and record the maximum and minimum thickness values of each connected component to obtain the global maximum and minimum thickness values.
[0058] Further, in one embodiment, the segmentation optimization module determines the target segmentation threshold based on the grayscale values of the target region and the background region, including: Calculate the weighted average of the grayscale values of the target region and the background region, and use the weighted average as the target segmentation threshold.
[0059] Furthermore, in one embodiment, the segmentation optimization module is also used for: The target binary image is subjected to morphological optimization processing, which includes hole filling, opening operation, and / or closing operation.
[0060] The functions of each module in the aforementioned region of interest processing device correspond to the steps in the aforementioned region of interest processing method embodiment, and their functions and implementation processes will not be described in detail here.
[0061] Thirdly, embodiments of this application provide a region of interest processing device, which can be a personal computer (PC), laptop computer, server, or other device with data processing capabilities.
[0062] Reference Figure 8 , Figure 8 This is a schematic diagram of the hardware structure of the region of interest processing device involved in the embodiments of this application. In the embodiments of this application, the region of interest processing device may include a processor, a memory, a communication interface, and a communication bus.
[0063] The communication bus can be of any type and is used to interconnect the processor, memory, and communication interface.
[0064] Communication interfaces include input / output (I / O) interfaces, physical interfaces, and logical interfaces used for interconnecting devices within the region of interest (ROI) processing device, as well as interfaces used for interconnecting the ROI processing device with other devices (such as other computing devices or user equipment). Physical interfaces can be Ethernet interfaces, fiber optic interfaces, ATM interfaces, etc.; user equipment can be displays, keyboards, etc.
[0065] Memory can be various types of storage media, such as random access memory (RAM), read-only memory (ROM), non-volatile RAM (NVRAM), flash memory, optical storage, hard disk, programmable ROM (PROM), erasable PROM (EPROM), electrically erasable PROM (EEPROM), etc.
[0066] The processor can be a general-purpose processor, which can call the region of interest (ROI) processing program stored in memory and execute the ROI processing method provided in the embodiments of this application. For example, the general-purpose processor can be a central processing unit (CPU). It can also be combined with a deep learning-specific processor, such as a GPU or TPU, to collaboratively improve processing efficiency. The method executed when the ROI processing program is called can be referred to in the various embodiments of the ROI processing method of this application, and will not be repeated here.
[0067] Those skilled in the art will understand that Figure 8 The hardware structure shown does not constitute a limitation of this application and may include more or fewer components than shown, or combine certain components, or have different component arrangements.
[0068] Fourthly, embodiments of this application also provide a computer-readable storage medium.
[0069] The present application has a computer-readable storage medium storing a region of interest processing program, wherein when the region of interest processing program is executed by a processor, it implements the steps of the region of interest processing method as described above.
[0070] The method implemented when the region of interest processing procedure is executed can be referred to in various embodiments of the region of interest processing method of this application, and will not be repeated here.
[0071] It should be noted that the sequence numbers of the embodiments in this application are for descriptive purposes only and do not represent the superiority or inferiority of the embodiments.
[0072] The terms "comprising" and "having," and any variations thereof, in the specification, claims, and accompanying drawings of this application are intended to cover non-exclusive inclusion. For example, a process, method, system, product, or apparatus that includes a series of steps or units is not limited to the listed steps or units, but may optionally include steps or units not listed, or may optionally include other steps or units inherent to such process, method, product, or apparatus. The terms "first," "second," and "third," etc., are used to distinguish different objects, etc., and do not indicate a sequence, nor do they limit "first," "second," and "third" to different types.
[0073] In the description of the embodiments of this application, terms such as "exemplary," "for example," or "for instance" are used to indicate examples, illustrations, or explanations. Any embodiment or design described as "exemplary," "for example," or "for instance" in the embodiments of this application should not be construed as being more preferred or advantageous than other embodiments or designs. Specifically, the use of terms such as "exemplary," "for example," or "for instance" is intended to present the relevant concepts in a concrete manner.
[0074] In the description of the embodiments of this application, unless otherwise stated, " / " means "or". For example, A / B can mean A or B. The "and / or" in the text is merely a description of the relationship between related objects, indicating that there can be three relationships. For example, A and / or B can mean: A exists alone, A and B exist simultaneously, and B exists alone. In addition, in the description of the embodiments of this application, "multiple" means two or more.
[0075] In some processes described in the embodiments of this application, multiple operations or steps are included in a specific order. However, it should be understood that these operations or steps may not be executed in the order they appear in the embodiments of this application, or they may be executed in parallel. The sequence number of the operation is only used to distinguish different operations, and the sequence number itself does not represent any execution order. In addition, these processes may include more or fewer operations, and these operations or steps may be executed sequentially or in parallel, and these operations or steps may be combined.
[0076] Through the above description of the embodiments, those skilled in the art can clearly understand that the methods of the above embodiments can be implemented by means of software plus necessary general-purpose hardware platforms. Of course, they can also be implemented by hardware, but in many cases the former is a better implementation method. Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, can be embodied in the form of a software product. This computer software product is stored in a storage medium (such as ROM / RAM, magnetic disk, optical disk) as described above, and includes several instructions to cause a terminal device to execute the methods described in the various embodiments of this application.
[0077] The above are merely preferred embodiments of this application and do not limit the patent scope of this application. Any equivalent structural or procedural transformations made using the content of this application's specification and drawings, or direct or indirect applications in other related technical fields, are similarly included within the patent protection scope of this application.
Claims
1. A region of interest processing method, characterized by, The method for processing the region of interest includes: The original image is segmented based on a deep learning segmentation model to obtain a binary mask image representing the target region, and the original image is then converted into a grayscale image. Based on the effective pixel positions in the binary mask image, the pixel values at the corresponding positions in the grayscale image are extracted to determine the grayscale value of the target region; The binary mask image is dilated to obtain a dilated binary image. The difference between the dilated binary image and the binary mask image is used as a background region mask. Based on the effective pixel positions in the background region mask, the pixel values at the corresponding positions in the grayscale image are extracted to determine the grayscale value of the background region. A target segmentation threshold is determined based on the grayscale values of the target region and the background region. The grayscale image is then segmented using the target segmentation threshold to obtain a re-segmented binary image. Non-target region content in the re-segmented binary image is removed based on the dilated binary image to obtain the target binary image.
2. The region of interest processing method as described in claim 1, characterized in that, After obtaining the target binary image, the process also includes: Extract all connected components from the target binary image, and extract the skeleton of each connected component to obtain a skeleton point set; Perform a distance transformation on each connected component to obtain a distance-transformed graph; Traverse the set of skeleton points, determine the distance value corresponding to each skeleton point according to the distance transformation diagram, and filter out the extreme distance points. The coarseness value of the connected component is calculated based on the distance extreme points.
3. The region of interest processing method as described in claim 1, characterized in that, Before extracting all connected components from the target binary image, the method further includes: The target binary image is subjected to morphological optimization processing, which includes hole filling, opening operation, and / or closing operation.
4. A method for processing regions of interest, characterized in that, The method for processing the region of interest includes: Extract all connected components from the target binary image, and extract the skeleton of each connected component to obtain a set of skeleton points; Perform a distance transformation on each connected component to obtain a distance-transformed graph; Traverse the set of skeleton points, determine the distance value corresponding to each skeleton point according to the distance transformation diagram, and filter out the extreme distance points. The coarseness value of the connected component is calculated based on the distance extreme points.
5. The region of interest processing method as described in claim 4, characterized in that, The calculation of the coarseness value of the connected component based on the distance extreme point includes: Extract the set of contour points of the connected component, and search for candidate contour points within a preset neighborhood range of the distance extreme point; Calculate the direction vector of the skeleton line near the extreme point; Based on the vector relationship between the direction vector and the candidate contour points, target contour points located on both sides of the skeleton line are selected. Calculate the distance between the target contour points on both sides, and use it as the thickness value of the connected region at the extreme point of the distance.
6. The region of interest processing method as described in claim 4, characterized in that, After calculating the coarseness value of the connected component based on the distance extreme point, the method further includes: Compare and record the maximum and minimum thickness values of each connected component to obtain the global maximum and minimum thickness values.
7. A region of interest processing apparatus, characterized in that, The region of interest processing device includes: An image processing module is used to segment the original image to obtain a binary mask image representing the target region, and to convert the original image into a grayscale image; The calculation module extracts the pixel value at the corresponding position in the grayscale image based on the effective pixel position in the binary mask image to determine the grayscale value of the target region; the calculation module is also used to dilate the binary mask image to obtain an dilated binary image, use the difference between the dilated binary image and the binary mask image as a background region mask, and extract the pixel value at the corresponding position in the grayscale image based on the effective pixel position in the background region mask to determine the grayscale value of the background region; The segmentation optimization module determines a target segmentation threshold based on the grayscale values of the target region and the background region, segments the grayscale image using the target segmentation threshold to obtain a re-segmented binary image, and removes non-target region content from the re-segmented binary image based on the dilated binary image to obtain the target binary image.
8. The region of interest processing apparatus as described in claim 7, characterized in that, It also includes a coarse measurement module, which is used for: Extract all connected components from the target binary image, and extract the skeleton of each connected component to obtain a skeleton point set; Perform a distance transformation on each connected component to obtain a distance-transformed graph; Traverse the set of skeleton points, determine the distance value corresponding to each skeleton point according to the distance transformation diagram, and filter out the extreme distance points. The coarseness value of the connected component is calculated based on the distance extreme points.
9. A region of interest processing device, characterized in that, The region of interest processing device includes a processor, a memory, and a region of interest processing program stored in the memory and executable by the processor, wherein when the region of interest processing program is executed by the processor, it implements the steps of the region of interest processing method as described in any one of claims 1 to 6.
10. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a region of interest processing program, wherein when the region of interest processing program is executed by a processor, it implements the steps of the region of interest processing method as described in any one of claims 1 to 6.