Image segmentation method and device, medium and equipment

Through edge detection and grayscale histogram analysis, the segmentation threshold is determined, which solves the problem of inaccurate segmentation caused by the high proportion of foreground or background in the image in the existing technology, achieves accurate segmentation of color images, and expands image segmentation technology. scope of application.

CN118587229APending Publication Date: 2024-09-03WEILAI MOBILE TECH CO LTD

Patent Information

Application Number
CN202310194378.9
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2023-03-02
Publication Date
2024-09-03

AI Technical Summary

Technical Problem

The existing multi-peak method threshold segmentation technology cannot accurately segment the image when the proportion of foreground or background in the image is too high. The reason is that the area with too small proportion cannot form a peak on the histogram, which affects the calculation of the segmentation threshold, resulting in incorrect segmentation. precise.

Method used

Using an image segmentation method based on edge detection, the edge area image of the target to be segmented is obtained through the edge detection algorithm, the grayscale histogram of the edge area is calculated, the segmentation threshold is determined, and then the image is segmented, avoiding segmentation caused by a small foreground proportion. Inaccuracy issues.

Benefits of technology

It effectively solves the impact of uneven proportion of segmentation targets in the image on segmentation accuracy, realizes the segmentation of color images, and greatly improves the application scope of image segmentation technology.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118587229A
    Figure CN118587229A
Patent Text Reader

Abstract

The invention relates to the technical field of image processing, particularly provides an image segmentation method and device, a medium and equipment, and aims to solve the technical problem of how to reduce the influence of non-uniform proportion of a segmentation target in an image on segmentation accuracy. In order to achieve the purpose, the image segmentation method provided by the invention comprises the steps of obtaining a to-be-segmented grayscale image based on preprocessing of an input to-be-segmented image; based on an edge detection algorithm, obtaining an edge region image of a to-be-segmented target in the to-be-segmented grayscale image; traversing the marginal region image to obtain a gray histogram of the marginal region image; determining a segmentation threshold value of the to-be-segmented target based on the gray level histogram; and segmenting the to-be-segmented image based on the segmentation threshold to obtain a segmented region image.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to image processing technology, and specifically provides an image segmentation method, device, medium and equipment. Background Art

[0002] Multi-(double) peak threshold segmentation is a commonly used technique in image processing. The method is to divide the image into two or more parts by calculating multiple peaks of the image histogram and setting a threshold between adjacent peaks. However, this method cannot accurately segment images with too high a background or foreground (segmentation target) because the area with too small a proportion in the image cannot form a peak in the histogram statistics. Therefore, the calculation of the histogram is affected, and the segmentation threshold cannot be accurately obtained, so the image cannot be accurately segmented, and the application scope is limited. Summary of the invention

[0003] In order to overcome the above-mentioned defects, the present invention is proposed to provide an image segmentation method, device, medium and equipment that solve or at least partially solve the technical problem of how to reduce the impact of uneven proportions of segmentation targets in an image on segmentation accuracy.

[0004] In a first aspect, the present invention provides an image segmentation method, comprising:

[0005] Based on the preprocessing of the input image to be segmented, a grayscale image to be segmented is obtained;

[0006] Based on the edge detection algorithm, an edge region image of the target to be segmented in the grayscale image to be segmented is obtained;

[0007] Traversing the edge region image to obtain a grayscale histogram of the edge region image;

[0008] Based on the grayscale histogram, determining a segmentation threshold of the target to be segmented;

[0009] The image to be segmented is segmented based on the segmentation threshold to obtain a segmented region image.

[0010] In a technical solution of the above-mentioned image segmentation method,

[0011] The step of obtaining a grayscale image to be segmented based on preprocessing the input image to be segmented includes:

[0012] Perform grayscale processing on the input image to be segmented to obtain an initial grayscale image to be segmented;

[0013] The initial grayscale image to be segmented is smoothed and denoised to obtain a final grayscale image to be segmented.

[0014] In a technical solution of the above-mentioned image segmentation method,

[0015] The step of obtaining an edge region image of the target to be segmented in the grayscale image to be segmented based on an edge detection algorithm includes:

[0016] Extracting an initial edge mask image of the target to be segmented in the grayscale image to be segmented by using an edge detection algorithm;

[0017] Performing an etching process on the initial edge mask image to obtain a main edge mask image;

[0018] Performing dilation processing on the main edge mask image to obtain a main edge expansion area mask image;

[0019] The main edge expansion area mask image is fused with the grayscale image to be segmented to obtain an edge area image of the object to be segmented.

[0020] In a technical solution of the above-mentioned image segmentation method,

[0021] The step of fusing the main edge expansion region mask image with the grayscale image to be segmented to obtain the edge region image of the target to be segmented includes:

[0022] Setting the 0-value area of ​​the main edge expansion area mask image to a negative value;

[0023] Multiplying the main edge expansion region mask image with the grayscale image to be segmented to obtain an edge region image of the target to be segmented, wherein all regions except the edge region in the edge region image are negative values;

[0024] Determining the segmentation threshold of the target to be segmented based on the grayscale histogram includes:

[0025] Removing the negative pixel values ​​in the grayscale histogram to obtain a processed grayscale histogram;

[0026] Sort the peaks in the processed grayscale histogram from large to small to obtain a peak sequence;

[0027] According to the required segmentation threshold number n, the first n+1 peaks in the peak sequence are taken and the pixel value corresponding to each peak is obtained;

[0028] Sort the obtained pixel values ​​from small to large to obtain a pixel sequence;

[0029] The median of adjacent pixel values ​​in the pixel sequence is taken to obtain segmentation thresholds of the n objects to be segmented.

[0030] In a technical solution of the above-mentioned image segmentation method,

[0031] The method further includes: performing smoothing processing on the grayscale histogram to obtain a final processed grayscale histogram.

[0032] In a technical solution of the above-mentioned image segmentation method,

[0033] The method segments the image to be segmented based on the segmentation threshold to obtain a segmented region image, including:

[0034] Segmenting the grayscale image to be segmented by the segmentation threshold to obtain a plurality of segmented region images;

[0035] For each segmented region image, a segmented region mask image having the same size as the grayscale image to be segmented is established;

[0036] The segmented region mask image is fused with the image to be segmented to obtain a final segmented region image.

[0037] In a technical solution of the above-mentioned image segmentation method,

[0038] The step of fusing the segmented region mask image with the image to be segmented to obtain a final segmented region image includes:

[0039] Setting other regions except the segmented region in the segmented region mask image to negative values;

[0040] The segmentation region mask image is multiplied by the image to be segmented to obtain a final segmentation region image.

[0041] In a second aspect, the present invention provides an image segmentation device, comprising a memory, one or more processors, and one or more applications, wherein the one or more applications are stored in the memory, and when the one or more applications are configured to be called by the one or more processors, the one or more processors execute any method described in the first aspect.

[0042] In a third aspect, the present invention provides a computer-readable storage medium storing a plurality of program codes, wherein the program codes are suitable for being loaded and run by a processor to execute the method as described in any one of the first aspects.

[0043] In a fourth aspect, the present invention provides an electronic device, comprising the apparatus as described in the second aspect.

[0044] The above one or more technical solutions of the present invention have at least one or more of the following beneficial effects:

[0045] In the technical solution for implementing the present invention, the edge of the target to be segmented in the image is determined by edge detection technology, the edge and the area around the edge are obtained, and then the histogram of the area is calculated to obtain the multi-peak position, and then the segmentation threshold is determined by adjacent peaks, thereby realizing multi-threshold segmentation, which effectively solves the problem that the uneven proportion of the segmented target in the image will affect the calculation of the histogram peak; and by performing threshold segmentation on the edge area, color image segmentation can be realized, which greatly improves the application scope of image segmentation technology. BRIEF DESCRIPTION OF THE DRAWINGS

[0046] The disclosure of the present invention will become more easily understood with reference to the accompanying drawings. It is easy for those skilled in the art to understand that these drawings are only for illustrative purposes and are not intended to limit the scope of protection of the present invention. In addition, similar numbers in the figures are used to represent similar components, among which:

[0047] Figure 1 is a schematic flow chart of main steps of an image segmentation method according to an embodiment of the present invention;

[0048] Figure 2 It is a schematic diagram of the overall process flow of an image segmentation method according to an embodiment of the present invention. DETAILED DESCRIPTION

[0049] Some embodiments of the present invention are described below with reference to the accompanying drawings. It should be understood by those skilled in the art that these embodiments are only used to explain the technical principles of the present invention and are not intended to limit the protection scope of the present invention.

[0050] In the description of the present invention, "module" and "processor" may include hardware, software or a combination of the two. A module may include hardware circuits, various suitable sensors, communication ports, and memories, and may also include software parts, such as program codes, or a combination of software and hardware. The processor may be a central processing unit, a microprocessor, an image processor, a digital signal processor, or any other suitable processor. The processor has data and / or signal processing functions. The processor may be implemented in software, hardware, or a combination of the two. Non-temporary computer-readable storage media include any suitable medium that can store program codes, such as a magnetic disk, a hard disk, an optical disk, a flash memory, a read-only memory, a random access memory, and the like. The term "A and / or B" means all possible combinations of A and B, such as only A, only B, or A and B. The term "at least one A or B" or "at least one of A and B" has a similar meaning to "A and / or B", and may include only A, only B, or A and B. The singular terms "one" and "the" may also include plural forms.

[0051] At present, multi-peak threshold segmentation in image processing cannot correctly segment images with a large difference in the proportion of foreground and background. The reason is that it uses the grayscale of the entire image for statistics when calculating the histogram. If the background proportion is too large, for example, the background area accounts for 99% and the foreground area accounts for 1%, the statistical grayscale histogram peaks all belong to the background area, and the foreground area is too small to form a peak on the histogram. Therefore, this result cannot be used to determine the segmentation threshold. Based on this, the present invention proposes a multi-threshold segmentation method based on edge detection, which can avoid the problem of inaccurate segmentation caused by the foreground (segmentation target) accounting for too small a proportion.

[0052] See attached Figure 1 , Figure 1 FIG. 1 is a flow chart of the main steps of an image segmentation method according to an embodiment of the present invention. Figure 1 As shown, an image segmentation method in an embodiment of the present invention mainly includes the following steps S101 to S105.

[0053] Step S101: obtaining a grayscale image to be segmented based on preprocessing of the input image to be segmented;

[0054] In this embodiment, the input image to be segmented can be a color image or a grayscale image directly; if it is a color image, the color image can be grayscaled first and converted into a grayscale image of equal size. The original color image is composed of three colors, RGB (that is, each pixel has three values). After the image is grayed, each pixel has only one value (0-255) to represent the depth of the color, so as to facilitate subsequent segmentation histogram processing.

[0055] In one embodiment, preprocessing the image to be segmented also includes smoothing and denoising the converted grayscale image to be segmented. A low-pass filter may be used to eliminate isolated noise points in the image (which may affect the accuracy of subsequent edge detection) to obtain a smooth grayscale image to be segmented.

[0056] Step S102: Based on an edge detection algorithm, an edge region image of the target to be segmented in the grayscale image to be segmented is obtained;

[0057] In this embodiment, the edge of the target to be segmented in the grayscale image to be segmented is determined by edge detection technology, thereby obtaining an edge region image, wherein the edge detection technology used may be a gradient method, a Canny edge detection method, or the like.

[0058] In one embodiment, after the edge of the target to be segmented in the grayscale image to be segmented is determined by edge detection technology, the edge needs to be processed to obtain an edge area image. In the present invention, the processing method includes image corrosion and image expansion to obtain the edge and the area around the edge, that is, the edge area image. Specifically, edge image processing can be achieved by establishing a mask image: the edge of the target to be segmented is obtained by edge detection technology, and an initial edge mask image is established; the initial edge mask image is corroded to remove isolated small edges and major edge noise, and then the main edge is restored and expanded by expansion, and the expansion takes equal-sized areas on both sides of the edge to obtain an expanded edge mask image, and the final edge mask image is multiplied by the original grayscale image to be segmented to obtain the final edge area image. In the present invention, the 0-value area of ​​the final edge mask image is set to a negative value, so that the other areas except the edge area in the obtained edge area image are negative values.

[0059] For example, the input image A to be segmented is converted into a grayscale image B (with the same length and width), and the noise that affects edge detection is eliminated through a low-pass filter to obtain a smooth image C; the edge detection method is then used to obtain the edge mask D of the image; the isolated small edges are then removed through an erosion operation, leaving a large edge mask E; the edge is then expanded through dilation to obtain a mask F of the edge and nearby areas; the 0 value area of ​​the mask is changed to -1, and then the mask is multiplied with the original image to obtain the final edge area image.

[0060] Step S103: traverse the edge area image to obtain a grayscale histogram of the edge area image;

[0061] In this embodiment, the grayscale histogram is used to count the edge area image. The grayscale histogram is a function of the grayscale level, which describes the number of pixels with the grayscale level in the image: wherein the horizontal axis is the grayscale level (usually 0-255), i.e., the pixel value, and the vertical axis is the frequency of occurrence of the grayscale level, which describes the grayscale distribution in the image and can intuitively show the proportion of each grayscale level in the image, i.e., the pixel proportion. In the present invention, the proportion of each pixel in the edge area image is obtained.

[0062] Step S104: determining a segmentation threshold of the target to be segmented based on the grayscale histogram;

[0063] In this embodiment, in the grayscale histogram, the edge area is found and the multi-peak position is obtained, and the segmentation threshold is determined by the adjacent peaks; specifically, the peak sizes in the grayscale histogram are sorted, and the pixels corresponding to these peaks are sorted using the largest first n+1 peaks according to the needs (threshold number n), and the median between adjacent pixels is a segmentation threshold.

[0064] In one embodiment, in the edge area image used, except for the edge area, other areas are negative values. Therefore, a grayscale histogram is performed on the edge area image. Except for the edge area, other areas are in the negative part. Therefore, the part with negative values ​​in the grayscale histogram is first removed, and the grayscale histogram of the remaining part is sorted by peak size to form a peak sequence; according to the required number of segmentation thresholds n, the first n+1 peaks in the peak sequence are taken and the pixel values ​​corresponding to each peak are obtained; the obtained pixel values ​​are sorted from small to large to obtain a pixel sequence; the median between adjacent pixel values ​​in the pixel sequence is taken to obtain n medians, that is, n segmentation thresholds for the targets to be segmented can be obtained.

[0065] For example, remove the part of the histogram with negative pixel values ​​(x coordinates). For the part of the histogram with pixel values ​​greater than or equal to 0, first perform a histogram smoothing operation, and then sort the pixel proportions (y coordinates) from large to small. According to the actual segmentation requirements (the number of segmentation thresholds n), take the first n+1 y values, record the corresponding n+1 x values, and sort them from small to large. For the sorted x values, take the median between two adjacent x values ​​to obtain n medians, which are the segmentation thresholds.

[0066] Step S105: Segment the image to be segmented based on the segmentation threshold to obtain a segmented region image.

[0067] In this embodiment, if the image to be segmented needs to be segmented into n+1 parts, then the number of segmentation thresholds is n, and the grayscale image to be segmented is segmented by the segmentation thresholds. The n segmentation thresholds divide the grayscale range (0 to 255) into n+1 parts, and n+1 segmentation area images are obtained. The original image to be segmented is segmented by these n+1 segmentation area images to obtain the final n+1 segmentation area images.

[0068] In one embodiment, a segmentation region mask image of the same size as the grayscale image to be segmented is established for each segmentation region image, and the segmentation region mask image sets other regions except the segmentation region to negative values; the segmentation region mask image is multiplied with the image to be segmented. Since all the color images except the segmentation region are negative values, the segmentation region image is finally obtained. Correspondingly, n+1 segmentation region mask images are established to obtain n+1 segmentation region images of the final color image. That is, the position of the target area is recorded through threshold segmentation, and then a mask of the same size as the original input image is formed. Applying it to the original image can obtain the segmentation result of the original color image. Compared with the existing threshold segmentation that can only perform segmentation on the grayscale image, the application range is greatly improved. The segmentation of color images can also be extended to custom threshold segmentation. For example, for color image A to be converted into grayscale image B, an array G of the same size as the grayscale image B is established, and the threshold is set to 50. For pixel points on the grayscale image B with pixel values ​​greater than or equal to 50, the same coordinate points in array G are set to 1, and the rest are -1. The data G is then multiplied by the color image A to obtain the matrix H. The points with non-negative values ​​in the matrix H are the segmentation results of the color image A, thereby realizing the segmentation of color images from grayscale images.

[0069] For example, Figure 2 As shown, performing image segmentation on the color image A to be segmented may specifically include the following steps:

[0070] S201, obtaining a color image A to be segmented, and converting it into a grayscale image B of the same size;

[0071] S202, pass the grayscale image B through a low-pass filter to remove isolated noise points, thereby obtaining a smoothed image C;

[0072] S203, establish a matrix D of the same size as the smoothed image C, use an edge detection method (gradient method, Canny edge detection method, etc.) to obtain the edge of the smoothed image C, and for the points belonging to the edge in the smoothed image C, set 1 at the same position in the matrix D, and set 0 for the points not belonging to the edge;

[0073] S204, establish a matrix F of the same size as the matrix D, use the erosion operation in the morphological processing to remove the isolated and small edges in the matrix D, and obtain an image E of the same size, and then use the dilation operation to process the matrix E, expand the edge in the matrix E (take the same size of area on both sides of the edge to ensure that the foreground / background have similar effects on the histogram), obtain the edge and its surrounding area, and set the points belonging to the area in the matrix E to 1 in the matrix F, and the rest to -1;

[0074] S205, multiplying the matrix F by the grayscale image B, and performing histogram statistics on the obtained results;

[0075] S206, removing the negative pixel values ​​(x coordinates) in the histogram, and performing a histogram smoothing operation on the pixel values ​​of the histogram that are greater than or equal to 0;

[0076] S207, sort the pixel proportions (y coordinates) from large to small, take the first n+1 y values ​​according to the actual segmentation requirements (number of segmentation thresholds n), record the corresponding n+1 x values, sort them from small to large, and take the median between the adjacent x values ​​of the sorted x values ​​to obtain n medians, which are the segmentation thresholds;

[0077] S208, n segmentation thresholds divide the grayscale range (0-255) into n+1 parts. For each segmented area, a matrix G (G1, G2, G3, ... Gn+1) of the same size as the grayscale image B is established. For the points in the grayscale image B belonging to the area, the values ​​of the corresponding coordinate positions in the matrix G are set to 1, and the rest are set to -1;

[0078] S209, multiplying the matrix G by the color image A to be segmented to obtain a result image H. The area in the image H where the pixel value is greater than or equal to 0 is the area after the color image is segmented. The n thresholds finally divide the color image A to be segmented into n+1 parts.

[0079] Based on the above steps S101 to S105, the embodiment of the present invention determines the edge of the target to be segmented in the image through edge detection technology, obtains the edge and the area around the edge, and then obtains the multi-peak position by calculating the histogram of the area, and then determines the segmentation threshold through adjacent peaks, thereby realizing multi-threshold segmentation, which effectively solves the problem that the uneven proportion of the segmented target in the image will affect the calculation of the histogram peak; and by performing threshold segmentation on the edge area, color image segmentation can be realized, which greatly improves the application scope of image segmentation technology.

[0080] It should be pointed out that although the various steps in the above embodiments are described in a specific order, those skilled in the art can understand that in order to achieve the effects of the present invention, different steps do not have to be performed in such an order. They can be performed simultaneously (in parallel) or in other orders. These changes are within the scope of protection of the present invention.

[0081] Furthermore, the present invention also provides an image segmentation device, comprising a memory, one or more processors, and one or more applications, wherein the one or more applications are stored in the memory, and when the one or more applications are configured to be called by the one or more processors, the one or more processors execute the method described in the technical solution of steps S101-S105 above.

[0082] The device in the embodiment of the present invention mainly includes a memory and a processor. The memory can be configured to store a program for executing the image segmentation method of the above method embodiment, and the processor can be configured to execute the program in the memory, which includes but is not limited to the program for executing the image segmentation method of the above method embodiment. For ease of explanation, only the part related to the embodiment of the present invention is shown. For specific technical details not disclosed, please refer to the method part of the embodiment of the present invention.

[0083] In one embodiment, an image segmentation device may include:

[0084] An input module, used for inputting an image to be segmented;

[0085] A preprocessing module is used to preprocess the input image to be segmented to obtain a grayscale image to be segmented;

[0086] An edge extraction module is used to obtain an edge region image of the target to be segmented in the grayscale image to be segmented by using an edge detection algorithm;

[0087] A histogram statistics module, used for traversing the edge region image to obtain a grayscale histogram of the edge region image;

[0088] A threshold calculation module, used to determine the segmentation threshold of the target to be segmented based on the grayscale histogram;

[0089] The segmentation execution module is used to segment the image to be segmented based on the segmentation threshold to obtain a segmented area image.

[0090] In the embodiment of the present invention, the image segmentation device may be a control device formed by various electronic devices. In some possible implementations, the device may include multiple storage devices and multiple processors. The program for executing the image segmentation method of the above method embodiment may be divided into multiple subprograms, each of which may be loaded and run by a processor to execute different steps of the image segmentation method of the above method embodiment. Specifically, each subprogram may be stored in different memories, and each processor may be configured to execute programs in one or more memories to jointly implement the image segmentation method of the above method embodiment, that is, each processor executes different steps of the image segmentation method of the above method embodiment to jointly implement the image segmentation method of the above method embodiment.

[0091] The above-mentioned multiple processors may be processors deployed on the same device. For example, the above-mentioned computer device may be a high-performance device composed of multiple processors, and the above-mentioned multiple processors may be processors configured on the high-performance device. In addition, the above-mentioned multiple processors may also be processors deployed on different devices. For example, the above-mentioned computer device may be a server cluster, and the above-mentioned multiple processors may be processors on different servers in the server cluster.

[0092] The image segmentation device is used to perform Figure 1 The image segmentation method embodiment shown in the figure has similar technical principles, technical problems solved and technical effects produced. Technicians in this technical field can clearly understand that for the convenience and conciseness of description, the specific working process and related instructions of the control device can refer to the contents described in the embodiment of the image segmentation method, which will not be repeated here.

[0093] Furthermore, the present invention also provides an electronic device, including the image segmentation device of the above embodiment. For ease of description, only the part related to the embodiment of the present invention is shown, and for the specific technical details not disclosed, please refer to the method part of the embodiment of the present invention.

[0094] The control device in the embodiment of the present invention mainly includes a memory and a processor. The memory can be configured to store a program for executing the image segmentation method of the above method embodiment, and the processor can be configured to execute the program in the memory, which includes but is not limited to the program for executing the image segmentation method of the above method embodiment. For ease of explanation, only the part related to the embodiment of the present invention is shown. For specific technical details not disclosed, please refer to the method part of the embodiment of the present invention.

[0095] It is understood by those skilled in the art that the present invention implements all or part of the processes in the method of the above embodiment, and can also be completed by instructing the relevant hardware through a computer program, and the computer program can be stored in a computer-readable storage medium, and the computer program can implement the steps of the above-mentioned various method embodiments when executed by the processor. Among them, the computer program includes computer program code, and the computer program code can be in source code form, object code form, executable file or some intermediate form. The computer-readable storage medium may include: any entity or device, medium, U disk, mobile hard disk, disk, optical disk, computer memory, read-only memory, random access memory, electric carrier signal, telecommunication signal and software distribution medium that can carry the computer program code. It should be noted that the content contained in the computer-readable storage medium can be appropriately increased or decreased according to the requirements of legislation and patent practice in the jurisdiction. For example, in some jurisdictions, according to legislation and patent practice, computer-readable storage media do not include electric carrier signals and telecommunication signals.

[0096] Furthermore, the present invention also provides a computer-readable storage medium. In a computer-readable storage medium embodiment according to the present invention, the computer-readable storage medium can be configured to store a program for executing the image segmentation method of the above-mentioned method embodiment, and the program can be loaded and run by a processor to implement the above-mentioned image segmentation method. For ease of explanation, only the parts related to the embodiment of the present invention are shown. For specific technical details not disclosed, please refer to the method part of the embodiment of the present invention. The computer-readable storage medium can be a storage device formed by various electronic devices. Optionally, the computer-readable storage medium in the embodiment of the present invention is a non-temporary computer-readable storage medium.

[0097] Further, it should be understood that since the setting of each module is only for illustrating the functional units of the device of the present invention, the physical devices corresponding to these modules may be the processor itself, or a part of the software in the processor, a part of the hardware, or a part of the combination of software and hardware. Therefore, the number of each module in the figure is only schematic.

[0098] Those skilled in the art will appreciate that the modules in the device can be adaptively split or merged. Such splitting or merging of specific modules will not cause the technical solution to deviate from the principle of the present invention, and therefore, the technical solutions after splitting or merging will fall within the protection scope of the present invention.

[0099] So far, the technical solutions of the present invention have been described in conjunction with the preferred embodiments shown in the accompanying drawings. However, it is easy for those skilled in the art to understand that the protection scope of the present invention is obviously not limited to these specific embodiments. Without departing from the principle of the present invention, those skilled in the art can make equivalent changes or substitutions to the relevant technical features, and the technical solutions after these changes or substitutions will fall within the protection scope of the present invention.

Claims

1. An image segmentation method, It is characterized in that include: Based on the preprocessing of the input image to be segmented, a grayscale image to be segmented is obtained; Based on the edge detection algorithm, an edge region image of the target to be segmented in the grayscale image to be segmented is obtained; Traversing the edge region image to obtain a grayscale histogram of the edge region image; Based on the grayscale histogram, determining a segmentation threshold of the target to be segmented; The image to be segmented is segmented based on the segmentation threshold to obtain a segmented region image.

2. An image segmentation method according to claim 1, It is characterized in that The step of obtaining a grayscale image to be segmented based on preprocessing the input image to be segmented includes: Perform grayscale processing on the input image to be segmented to obtain an initial grayscale image to be segmented; The initial grayscale image to be segmented is subjected to smoothing and denoising processing to obtain a final grayscale image to be segmented.

3. The image segmentation method according to claim 1, It is characterized in that The step of obtaining an edge region image of the target to be segmented in the grayscale image to be segmented based on an edge detection algorithm includes: Extracting an initial edge mask image of the target to be segmented in the grayscale image to be segmented by using an edge detection algorithm; Performing an etching process on the initial edge mask image to obtain a main edge mask image; Performing dilation processing on the main edge mask image to obtain a main edge expansion area mask image; The main edge expansion area mask image is fused with the grayscale image to be segmented to obtain an edge area image of the object to be segmented.

4. An image segmentation method according to claim 3, It is characterized in that The step of fusing the main edge expansion region mask image with the grayscale image to be segmented to obtain the edge region image of the target to be segmented includes: Setting the 0-value area of ​​the main edge expansion area mask image to a negative value; Multiplying the main edge expansion region mask image with the grayscale image to be segmented to obtain an edge region image of the target to be segmented, wherein all regions except the edge region in the edge region image are negative values; Determining the segmentation threshold of the target to be segmented based on the grayscale histogram includes: Removing the negative pixel values ​​in the grayscale histogram to obtain a processed grayscale histogram; Sort the peaks in the processed grayscale histogram from large to small to obtain a peak sequence; According to the required segmentation threshold number n, the first n+1 peaks in the peak sequence are taken and the pixel value corresponding to each peak is obtained; Sort the obtained pixel values ​​from small to large to obtain a pixel sequence; The median of adjacent pixel values ​​in the pixel sequence is taken to obtain segmentation thresholds of the n objects to be segmented.

5. An image segmentation method according to claim 4, It is characterized in that The method further includes: performing smoothing processing on the grayscale histogram to obtain a final processed grayscale histogram.

6. An image segmentation method according to any one of claims 1 to 5, It is characterized in that The method segments the image to be segmented based on the segmentation threshold to obtain a segmented region image, including: Segmenting the grayscale image to be segmented by the segmentation threshold to obtain a plurality of segmented region images; For each segmented region image, a segmented region mask image having the same size as the grayscale image to be segmented is established; The segmented region mask image is fused with the image to be segmented to obtain a final segmented region image.

7. An image segmentation method according to claim 6, It is characterized in that The step of fusing the segmented region mask image with the image to be segmented to obtain a final segmented region image includes: Setting other regions except the segmented region in the segmented region mask image to negative values; The segmentation region mask image is multiplied by the image to be segmented to obtain a final segmentation region image.

8. An image segmentation device, It is characterized in that The method comprises a memory, one or more processors, and one or more applications, wherein the one or more applications are stored in the memory, and when the one or more applications are configured to be called by the one or more processors, the one or more processors execute the method as described in any one of claims 1 to 7.

9. A computer-readable storage medium, It is characterized in that A plurality of program codes are stored, and the program codes are suitable for being loaded and run by a processor to execute the method according to any one of claims 1 to 7.

10. An electronic device, It is characterized in that The device comprises an apparatus as claimed in claim 8.

Citation Information

Patent Citations

  • Color image segmentation method and system

    CN101699511A

  • Unstructured road detection method based on adaptive edge registration

    CN102436644A

  • Method and system for navicular identification

    CN103514448A

  • Lung image segmentation method and device and lung lesion area identification equipment

    CN110766713A

  • Medical image segmentation method

    CN114764810A

Cited By

  • Anti-collision beam weld defect detection method and system based on image processing

    CN120598960A