Image boundary determination method and device, equipment and storage medium

By acquiring the color channel sub-image of the color image, edge enhancement and downsampling are performed, and combined with multi-directional gradient information, the problem of inaccurate and flexible image boundary extraction in the prior art is solved, and a more accurate image boundary extraction effect is achieved.

CN119027438APending Publication Date: 2024-11-26CASI VISION TECH (BEIJING) CO LTD +1
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202410931746.8
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-07-11
Publication Date
2024-11-26

AI Technical Summary

Technical Problem

The prior art has problems of inaccurate and flexible enough in image boundary extraction, resulting in poor boundary extraction effect.

Method used

By acquiring sub-images of each color channel of the color image, edge enhancement processing and target downsampling processing are performed, and the boundary region of the image is determined in combination with multi-directional edge gradient information.

Benefits of technology

It realizes more accurate and flexible image boundary extraction, obtains richer edge information, and improves the accuracy and efficiency of image processing.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119027438A_ABST
    Figure CN119027438A_ABST
Patent Text Reader

Abstract

The invention provides an image boundary determination method and device, equipment and a storage medium, and the method comprises the steps: obtaining a sub-image of each color channel of a to-be-processed color image, determining a target image based on each sub-image, carrying out the edge enhancement processing of each target image, and obtaining each corresponding enhanced image, performing target down-sampling processing on each enhanced image to obtain each corresponding down-sampled image, determining edge gradient information of the down-sampled image in multiple preset directions for each down-sampled image, and determining the edge gradient information of the down-sampled image in multiple preset directions based on the edge gradient information corresponding to each down-sampled image. And determining target gradient information corresponding to the to-be-processed color image, and determining a boundary region of the to-be-processed color image according to the target gradient information. By adopting the method, the image boundary is accurately and flexibly extracted.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present disclosure relates to the field of image processing technology, and in particular to an image boundary determination method, device, equipment and storage medium. Background Art

[0002] Extracting the boundaries of objects in an image is a critical step in image processing tasks such as object detection and image segmentation. At present, the commonly used image boundary extraction methods have certain limitations when calculating the edge gradient of the image, resulting in inaccurate and inflexible boundary extraction. Therefore, how to accurately and flexibly extract image boundaries has become a technical problem that needs to be solved urgently. Summary of the invention

[0003] The present disclosure provides an image boundary determination method, device, equipment and storage medium to at least solve the above technical problems existing in the prior art.

[0004] According to a first aspect of the present disclosure, a method for determining an image boundary is provided, the method comprising:

[0005] Obtaining sub-images of each color channel of the color image to be processed, and determining a target image based on each of the sub-images;

[0006] Performing edge enhancement processing on each of the target images to obtain corresponding enhanced images;

[0007] Performing target downsampling processing on each enhanced image to obtain corresponding downsampled images;

[0008] For each downsampled image, determining edge gradient information of a plurality of preset directions of the downsampled image;

[0009] Determining target gradient information corresponding to the color image to be processed based on edge gradient information corresponding to each downsampled image;

[0010] The boundary area of ​​the color image to be processed is determined according to the target gradient information.

[0011] In one possible implementation manner, the acquiring of sub-images of each color channel of the color image to be processed, and determining the target image based on each of the sub-images, includes:

[0012] Extracting sub-images of each color channel of the color image to be processed;

[0013] Use each sub-image as the target image; or,

[0014] The sub-images are reorganized based on the preset weights corresponding to the sub-images to generate a plurality of single-channel images as the target image.

[0015] In one possible implementation, the reorganizing the sub-images based on the preset weights corresponding to the sub-images to generate a plurality of single-channel images as the target image includes:

[0016] Superimposing pixels at corresponding positions of a group of sub-images according to preset weights corresponding to the sub-images to obtain a plurality of superimposed images, wherein each group of sub-images includes at least two sub-images of different color channels;

[0017] The pixel value of each pixel point in each superimposed image is mapped into a preset pixel range, wherein the maximum pixel in the preset pixel range is less than or equal to the maximum pixel value in each sub-image, and the minimum pixel in the preset pixel range is greater than or equal to 0.

[0018] In one possible implementation manner, performing edge enhancement processing on each of the target images to obtain corresponding enhanced images includes:

[0019] For each of the target images, the pixel value of each pixel point in the target image whose pixel value is not greater than the reference pixel value is reset to a first preset pixel value, and the absolute value of the pixel difference between the reference pixel value and the pixel value of each pixel point in the target image whose pixel value is greater than the reference pixel value is calculated, and the absolute value of the pixel difference is reset to the pixel value of the corresponding pixel point, so as to obtain an intermediate processed image corresponding to each of the target images;

[0020] Based on the mapping parameters, the pixel values ​​of the pixel points of each intermediate processed image are placed within a preset pixel range to obtain the corresponding enhanced images, wherein the maximum pixel in the preset pixel range is less than or equal to the second preset pixel value, and the minimum pixel in the preset pixel range is greater than or equal to the first preset pixel value.

[0021] In one possible implementation manner, the step of setting the pixel values ​​of the pixels of each intermediate processed image within a preset pixel range based on the mapping parameters to obtain the corresponding enhanced images includes:

[0022] Obtaining the maximum pixel value and the minimum pixel value corresponding to each of the target images;

[0023] For each of the target images, a pixel difference between a maximum pixel value and a minimum pixel value corresponding to the target image is calculated, and a ratio of the second preset pixel value to the pixel difference is used as a mapping parameter of an intermediate processing image corresponding to the target image;

[0024] For each intermediate processed image, the product of the pixel value of each pixel point of the intermediate processed image and the mapping parameter is reset to the pixel value of the corresponding pixel point to obtain each corresponding enhanced image.

[0025] In one possible implementation manner, performing target downsampling processing on each enhanced image to obtain each corresponding downsampled image includes:

[0026] For each enhanced image, the enhanced image is divided into a plurality of overlapping sub-images according to a preset downsampling ratio, and there is an overlapping area between any two overlapping sub-images;

[0027] The pixel average value of each overlapping sub-image is calculated, and the pixel value of each pixel point in the overlapping sub-image is reset to the pixel average value of the overlapping sub-image, so as to obtain the downsampled image corresponding to the enhanced image.

[0028] In one possible implementation manner, before determining edge gradient information of multiple preset directions of each downsampled image, the method further includes:

[0029] Perform filtering on each downsampled image.

[0030] In one possible implementation manner, for each downsampled image, determining edge gradient information of multiple preset directions of the downsampled image includes:

[0031] For each downsampled image, a convolution kernel corresponding to each preset direction is used to perform a preset number of convolution processes on the downsampled image to obtain a gradient vector of the downsampled image in each preset direction as edge gradient information.

[0032] In one possible implementation manner, determining the target gradient information corresponding to the color image to be processed based on the edge gradient information corresponding to each downsampled image includes:

[0033] For each downsampled image, determining a gradient magnitude and a gradient direction corresponding to the downsampled image based on a gradient vector of the downsampled image in each preset direction;

[0034] Merging the gradient amplitudes corresponding to the downsampled images, and using the merged gradient amplitude as the target gradient amplitude, and using the gradient direction with the largest corresponding gradient amplitude as the target gradient direction;

[0035] The target gradient magnitude and the target gradient direction are determined as the target gradient information corresponding to the color image to be processed.

[0036] In one possible implementation manner, determining the boundary area of ​​the color image to be processed according to the target gradient information includes:

[0037] For each pixel in the color image to be processed, if the gradient amplitude of the pixel is greater than the gradient amplitude of the adjacent pixel of the pixel in the target gradient direction, the pixel is determined as a preliminary edge pixel;

[0038] If the gradient amplitude of the pixel point is not greater than the gradient amplitude of the adjacent pixel point of the pixel point in the target gradient direction, the pixel point is determined as a non-edge pixel point;

[0039] Based on the preliminary edge pixels and the preset gradient threshold, target edge pixels in the color image to be processed are determined, and an image region composed of the target edge pixels is determined as a boundary region of the color image to be processed.

[0040] In one possible implementation manner, determining the target edge pixel points in the color image to be processed based on the preliminary edge pixel points and the preset gradient threshold includes:

[0041] For each pixel point in the color image to be processed, if the gradient amplitude of the pixel point is greater than a first preset gradient threshold, the pixel point is determined as a target edge pixel point;

[0042] If the gradient amplitude of the pixel point is less than a second preset gradient threshold, the pixel point is determined as a non-edge pixel point;

[0043] If the gradient amplitude of the pixel point is greater than or equal to the second preset gradient threshold and less than or equal to the first preset gradient threshold, determine whether there is a preliminary edge pixel point among the adjacent pixels of the pixel point. If so, determine the pixel point as a target edge pixel point; if not, determine the pixel point as a non-edge pixel point.

[0044] According to a second aspect of the present disclosure, there is provided an image boundary determination device, the device comprising:

[0045] A target image determination module, used to obtain sub-images of each color channel of the color image to be processed, and determine the target image based on each of the sub-images;

[0046] An image enhancement module, used to perform edge enhancement processing on each of the target images to obtain corresponding enhanced images;

[0047] A downsampling module is used to perform target downsampling processing on each enhanced image to obtain corresponding downsampled images;

[0048] A first gradient determination module, configured to determine, for each downsampled image, edge gradient information of the downsampled image in a plurality of preset directions;

[0049] A second gradient determination module, configured to determine target gradient information corresponding to the color image to be processed based on edge gradient information corresponding to each downsampled image;

[0050] The boundary determination module is used to determine the boundary area of ​​the color image to be processed according to the target gradient information.

[0051] In one possible implementation, the target image determination module is specifically used to extract sub-images of each color channel of the color image to be processed; use each sub-image as the target image; or, reorganize each sub-image based on preset weights corresponding to each sub-image to generate multiple single-channel images as the target image.

[0052] In one possible implementation, the target image determination module is specifically used to superimpose pixels at corresponding positions of a group of sub-images according to preset weights corresponding to each sub-image to obtain multiple superimposed images, each group of sub-images including at least two sub-images with different color channels; and map the pixel value of each pixel point in each superimposed image to a preset pixel range, the maximum pixel of the preset pixel range is less than or equal to the maximum pixel value in each sub-image, and the minimum pixel of the preset pixel range is greater than or equal to 0.

[0053] In one possible implementation, the image enhancement module is specifically used to reset the pixel value of each pixel point in the target image whose pixel value is not greater than the reference pixel value to a first preset pixel value for each of the target images, and to calculate the absolute value of the pixel difference between the reference pixel value and the pixel value of each pixel point in the target image whose pixel value is greater than the reference pixel value, and to reset the absolute value of the pixel difference to the pixel value of the corresponding pixel point, so as to obtain an intermediate processed image corresponding to each of the target images; based on the mapping parameters, the pixel values ​​of the pixel points of each of the intermediate processed images are within a preset pixel range, so as to obtain corresponding enhanced images, wherein the maximum pixel in the preset pixel range is less than or equal to the second preset pixel value, and the minimum pixel in the preset pixel range is greater than or equal to the first preset pixel value.

[0054] In one possible implementation, the image enhancement module is specifically used to obtain the maximum pixel value and the minimum pixel value corresponding to each of the target images; for each of the target images, calculate the pixel difference between the maximum pixel value and the minimum pixel value corresponding to the target image, and use the ratio of the second preset pixel value to the pixel difference as the mapping parameter of the intermediate processed image corresponding to the target image; for each intermediate processed image, reset the product of the pixel value of each pixel point of the intermediate processed image and the mapping parameter to the pixel value of the corresponding pixel point, so as to obtain the corresponding enhanced images.

[0055] In one possible implementation, the downsampling module is specifically used to divide each enhanced image into multiple overlapping sub-images according to a preset downsampling ratio, and there is an overlapping area between any two overlapping sub-images; calculate the pixel average of each overlapping sub-image, and reset the pixel value of each pixel in the overlapping sub-image to the pixel average of the overlapping sub-image, so as to obtain the downsampled image corresponding to the enhanced image.

[0056] In one possible implementation manner, the downsampling module is further used to perform filtering processing on each downsampled image.

[0057] According to a third aspect of the present disclosure, there is provided an electronic device, including:

[0058] at least one processor; and

[0059] a memory communicatively connected to the at least one processor; wherein,

[0060] The memory stores instructions that can be executed by the at least one processor, and the instructions are executed by the at least one processor to enable the at least one processor to perform the method described in the present disclosure.

[0061] According to a fourth aspect of the present disclosure, a non-transitory computer-readable storage medium storing computer instructions is provided, wherein the computer instructions are used to cause the computer to execute the method described in the present disclosure.

[0062] The image boundary determination method, device, equipment and storage medium disclosed in the present invention obtain sub-images of each color channel of the color image to be processed and determine the target image based on each sub-image, perform edge enhancement processing on each target image to obtain corresponding enhanced images, perform target downsampling processing on each enhanced image to obtain corresponding downsampled images, determine edge gradient information of multiple preset directions of the downsampled image for each downsampled image, determine target gradient information corresponding to the color image to be processed based on the edge gradient information corresponding to each downsampled image, and determine the boundary area of ​​the color image to be processed based on the target gradient information. Richer edge information is obtained by performing edge extraction on each channel image of the color image to be processed, and more accurate image edges are determined by combining target downsampling and multi-directional gradient information, thereby achieving accurate and flexible extraction of image boundaries.

[0063] It should be understood that the content described in this section is not intended to identify the key or important features of the embodiments of the present disclosure, nor is it intended to limit the scope of the present disclosure. Other features of the present disclosure will become easily understood through the following description. BRIEF DESCRIPTION OF THE DRAWINGS

[0064] The above and other objects, features and advantages of the exemplary embodiments of the present disclosure will become readily understood by reading the detailed description below with reference to the accompanying drawings. In the accompanying drawings, several embodiments of the present disclosure are shown in an exemplary and non-limiting manner, in which:

[0065] In the drawings, the same or corresponding reference numerals represent the same or corresponding parts.

[0066] Figure 1 A schematic diagram of a process of determining an image boundary provided by an embodiment of the present disclosure is shown;

[0067] Figure 2 A schematic diagram of image splitting provided by an embodiment of the present disclosure is shown;

[0068] Figure 3 A schematic diagram of a gradient determination process provided by an embodiment of the present disclosure is shown;

[0069] Figure 4 A schematic diagram of an image boundary determination process provided by an embodiment of the present disclosure is shown;

[0070] Figure 5 A schematic diagram of a structure of an image boundary determination device provided by an embodiment of the present disclosure is shown;

[0071] Figure 6 A schematic diagram of the structure of an electronic device provided by an embodiment of the present disclosure is shown. DETAILED DESCRIPTION

[0072] In order to make the purpose, features, and advantages of the present disclosure more obvious and easy to understand, the technical solutions in the embodiments of the present disclosure will be clearly and completely described below in conjunction with the drawings in the embodiments of the present disclosure. Obviously, the described embodiments are only part of the embodiments of the present disclosure, not all of the embodiments. Based on the embodiments in the present disclosure, all other embodiments obtained by those skilled in the art without creative work are within the scope of protection of the present disclosure.

[0073] The commonly used image boundary extraction methods currently have certain limitations when obtaining image edge gradients, resulting in inaccurate and inflexible boundary extraction. Therefore, in order to accurately and flexibly extract image boundaries, the present disclosure provides an image boundary determination method, device, equipment and storage medium. The image boundary determination method provided by the present disclosure can be applied to any electronic device that can perform image processing, including but not limited to computers, mobile phones and tablet computers.

[0074] The technical solution of the embodiment of the present disclosure will be described below in conjunction with the drawings in the embodiment of the present disclosure.

[0075] Figure 1A schematic diagram of a process of determining an image boundary provided by an embodiment of the present disclosure is shown. Figure 1 As shown, the method includes:

[0076] S101, obtaining sub-images of each color channel of a color image to be processed, and determining a target image based on each of the sub-images.

[0077] In the present disclosure, the color image to be processed can be a color image of any scene that requires image boundary recognition acquired by an image acquisition device. For example, in a medical imaging scenario, the boundaries of an organ or tumor can be identified to help doctors accurately locate the lesion area, so an image acquisition device can be used to acquire a color image of the organ. For another example, in an autonomous driving system, identifying image boundaries can be used to determine important environmental features such as roads and lane lines, which helps with vehicle positioning, path planning, and obstacle detection. Therefore, an image acquisition device can be used to acquire a color image of the environment in which the vehicle is traveling. The image acquisition device can be a device such as a camera or a mobile phone camera.

[0078] Since color images contain rich and detailed image information, for example, the color, lighting, shadow, and material of the target in the image, that is, color images contain richer edge information, the edge features of the image can be captured more accurately based on color images.

[0079] In a possible implementation manner, the step of acquiring sub-images of each color channel of the color image to be processed and determining the target image based on each of the sub-images includes steps A1-A2:

[0080] Step A1, extracting sub-images of each color channel of the color image to be processed.

[0081] In the present disclosure, the sub-images of the three color channels of RGB (red, green and blue) of the color image to be processed can be separated. Specifically, two nested loops can be used to traverse each pixel of the color image to be processed, and the value of each channel can be extracted into a corresponding single-channel image, or the split function in opencv can be used to perform three-channel separation on the color image to be processed.

[0082] Figure 2 FIG. 4 shows a schematic diagram of image splitting provided by an embodiment of the present disclosure, such as Figure 2 As shown, Figure 2 Figure (a) is a color image P to be processed. Figure 2 The middle (b) figure is a sub-image of the B (blue) color channel of the color image P to be processed obtained by splitting the color image P to be processed. Figure 2 The middle (c) figure is a sub-image of the G (green) color channel of the color image P to be processed obtained by splitting the color image P to be processed. Figure 2 The middle figure (d) is a sub-image of the R (red) color channel of the color image P to be processed obtained by decomposing the color image P to be processed.

[0083] Step A2, taking each sub-image as a target image; or, recombining each sub-image based on a preset weight corresponding to each sub-image, to generate a plurality of single-channel images as the target image.

[0084] In the present disclosure, the sub-images of the three RGB color channels of the color image to be processed can all be used as target images, or any two different sub-images can be combined to generate a single-channel image as the target image, or three sub-images can be combined to generate a single-channel image as the target image.

[0085] In the present disclosure, the step of recombining the sub-images based on the preset weights corresponding to the sub-images to generate a plurality of single-channel images as the target image may include steps B1-B2:

[0086] Step B1, superimposing pixels at corresponding positions of a group of sub-images according to preset weights corresponding to the sub-images to obtain a plurality of superimposed images, wherein each group of sub-images includes at least two sub-images of different color channels.

[0087] In the present disclosure, the preset weight can be set according to the actual application requirements. For example, the sub-image of the G color channel and the sub-image of the R color channel can be superimposed to generate a superimposed image. If the edge of the sub-image of the G color channel is clearer, in order to more accurately determine the boundary of the color image to be processed, the weight of the sub-image of the G color channel can be set to be larger, for example, the weight of the sub-image of the G color channel is set to 0.8, and the weight of the sub-image of the R color channel is set to 0.5. Then, the product of the pixel value of each pixel point of the sub-image of the G color channel and 0.8 is reset to the pixel value of the corresponding pixel point, and the product of the pixel value of each pixel point of the sub-image of the R color channel and 0.5 is reset to the pixel value of the corresponding pixel point, and then the pixel values ​​of the pixel points at the corresponding positions in the sub-image of the G color channel with the reset pixel value and the sub-image of the R color channel with the reset pixel value are added to obtain the corresponding superimposed image after the sub-image of the G color channel is superimposed on the sub-image of the R color channel.

[0088] Step B2, mapping the pixel value of each pixel point in each superimposed image to a preset pixel range, wherein the maximum pixel in the preset pixel range is less than or equal to the maximum pixel value in each sub-image, and the minimum pixel in the preset pixel range is greater than or equal to 0.

[0089] In the present disclosure, the preset pixel range may be 0-255. Specifically, for each superimposed image, the difference between the maximum pixel value and the minimum pixel value in the superimposed image is obtained, the ratio of 255 to the difference is calculated, and then the product of the pixel value of each pixel point in the superimposed image and the ratio is reset to the pixel value of the corresponding pixel point, thereby obtaining a superimposed image with a pixel value range of 0-255.

[0090] S102, performing edge enhancement processing on each of the target images to obtain corresponding enhanced images.

[0091] In the present disclosure, contrast stretching can be performed on each target image to achieve edge feature enhancement. In a possible implementation, performing edge enhancement processing on each target image to obtain corresponding enhanced images may include steps C1-C2:

[0092] Step C1, for each of the target images, reset the pixel value of each pixel point in the target image whose pixel value is not greater than the reference pixel value to a first preset pixel value, and calculate the absolute value of the pixel difference between the reference pixel value and the pixel value of each pixel point in the target image whose pixel value is greater than the reference pixel value, and reset the absolute value of the pixel difference to the pixel value of the corresponding pixel point, so as to obtain an intermediate processed image corresponding to each target image.

[0093] In the present disclosure, the reference pixel value may be a pre-specified pixel value. If there is no pre-specified pixel value, the minimum pixel value in the target image may be set as the reference pixel value. The first preset pixel value may be set to 0 in general.

[0094] Step C2, based on the mapping parameters, the pixel values ​​of the pixel points of each intermediate processed image are placed within a preset pixel range to obtain corresponding enhanced images, wherein the maximum pixel in the preset pixel range is less than or equal to the second preset pixel value, and the minimum pixel in the preset pixel range is greater than or equal to the first preset pixel value.

[0095] In the present disclosure, the second preset pixel value is generally set to 255.

[0096] In the present disclosure, the step of setting the pixel values ​​of the pixels of each intermediate processed image within a preset pixel range based on the mapping parameters to obtain the corresponding enhanced images may include steps D1-D3:

[0097] Step D1, obtaining the maximum pixel value and the minimum pixel value corresponding to each of the target images.

[0098] Step D2, for each of the target images, calculate the pixel difference between the maximum pixel value and the minimum pixel value corresponding to the target image, and use the ratio of the second preset pixel value to the pixel difference as the mapping parameter of the intermediate processed image corresponding to the target image.

[0099] Step D3: for each intermediate processed image, reset the product of the pixel value of each pixel point of the intermediate processed image and the mapping parameter to the pixel value of the corresponding pixel point to obtain the corresponding enhanced images.

[0100] In the present disclosure, edge enhancement processing is performed on each target image to enhance the edge display effect of each target image, which is beneficial to extract the edge area of ​​the color image to be processed.

[0101] S103, performing target downsampling processing on each enhanced image to obtain corresponding downsampled images.

[0102] In the present disclosure, target downsampling processing is performed on each enhanced image, which can reduce the image size while retaining the main image edge features.

[0103] S104: for each downsampled image, determine edge gradient information of the downsampled image in multiple preset directions.

[0104] In the present disclosure, for each downsampled image, a convolution kernel corresponding to each preset direction may be used to perform convolution processing on the downsampled image for a preset number of times to obtain a gradient vector of the downsampled image in each preset direction as edge gradient information.

[0105] The preset number of times can be set to 2 or 3 as required. The preset direction can be the horizontal direction, vertical direction, right oblique upward direction, and right oblique downward direction of the image. A corresponding convolution kernel can be set for each preset direction. For example, the gradient convolution kernel corresponding to the horizontal direction can be set to the convolution kernel a shown in Table 1, the gradient convolution kernel corresponding to the vertical direction can be set to the convolution kernel b shown in Table 2, the gradient convolution kernel corresponding to the right oblique upward direction can be set to the convolution kernel c shown in Table 3, and the gradient convolution kernel corresponding to the right oblique downward direction can be set to the convolution kernel d shown in Table 4.

[0106] Table 1: Convolution kernel a

[0107]

[0108]

[0109] Table 2: Convolution kernel b

[0110] -2 -4 -2 0 0 0 2 4 2

[0111] Table 3: Convolution kernel c

[0112] 0 2 4 -2 0 2 -4 -2 0

[0113] Table 4: Convolution kernel d

[0114] -4 -2 0 -2 0 2 0 2 4

[0115] S105 , determining target gradient information corresponding to the color image to be processed based on edge gradient information corresponding to each downsampled image.

[0116] S106: Determine a boundary area of ​​the color image to be processed according to the target gradient information.

[0117] By adopting this method, sub-images of each color channel of the color image to be processed are obtained and the target image is determined based on each sub-image, edge enhancement processing is performed on each target image to obtain corresponding enhanced images, target downsampling processing is performed on each enhanced image to obtain corresponding downsampled images, and for each downsampled image, edge gradient information of multiple preset directions of the downsampled image is determined, and target gradient information corresponding to the color image to be processed is determined based on the edge gradient information corresponding to each downsampled image, and the boundary area of ​​the color image to be processed is determined according to the target gradient information. Richer edge information is obtained by performing edge extraction on each channel image of the color image to be processed, and more accurate image edges are determined by combining target downsampling and multi-directional gradient information, so as to achieve accurate and flexible extraction of image boundaries.

[0118] In a possible implementation manner, performing target downsampling processing on each enhanced image to obtain each corresponding downsampled image may include steps E1-E2:

[0119] Step E1: for each enhanced image, divide the enhanced image into a plurality of overlapping sub-images according to a preset downsampling ratio, and there is an overlapping area between any two overlapping sub-images.

[0120] In the present disclosure, the preset downsampling ratio includes the size of each overlapping sub-image and the proportion of the overlapping area between any two sub-images. The size of the overlapping sub-image and the proportion of the overlapping area between any two sub-images can be controlled by setting the preset downsampling ratio, thereby controlling the degree of downsampling.

[0121] Step E2, calculating the pixel average value of each overlapping sub-image, and resetting the pixel value of each pixel point in the overlapping sub-image to the pixel average value of the overlapping sub-image, to obtain the downsampled image corresponding to the enhanced image.

[0122] In the present disclosure, by downsampling the enhanced image, the main image edge features can be retained while reducing the image size, thereby reducing the image processing data volume and computational complexity, reducing the consumption of computing resources, and improving the image processing efficiency. In the present disclosure, when downsampling is performed, the edge of the enhanced image can be zero-filled so that the redundant pixels on the edge are filled with zero, so that the image size can be maintained, or the redundant pixels on the edge of the enhanced image can be truncated so that the output image size is reduced, or the pixels on the edge of the enhanced image can be expanded to retain more image edge information.

[0123] In the present disclosure, the downsampled image may also be filtered, for example, the downsampled image may be subjected to median filtering. Specifically, the median of the pixel values ​​in the neighborhood of each pixel point in the downsampled image may be calculated, and the median may be reset to the pixel value of the pixel point. By performing median filtering on the downsampled image, the edge features of the image may be retained while removing the local irregular noise of the downsampled image, which is more conducive to accurately extracting the boundary of the color image to be processed.

[0124] In one possible implementation, Figure 3 A schematic diagram of a gradient determination process provided by an embodiment of the present disclosure is shown. Figure 3 As shown, the determining of the target gradient information corresponding to the color image to be processed based on the edge gradient information corresponding to each downsampled image may include:

[0125] S301 : for each downsampled image, determine a gradient magnitude and a gradient direction corresponding to the downsampled image based on a gradient vector of the downsampled image in each preset direction.

[0126] For example, if the gradient vectors in each preset direction are G down (vertically downward) = (0, -1), G rightdown (lower right direction) = (1, -1), G right (horizontally right) = (1,0), G rightup (upper right direction) = (1,1), then the gradient magnitude vector sum corresponding to the downsampled image is:

[0127] G sum =G down (vertically downward)+G rightdown (Downright)+G right (Horizontal Right)+G rightup (upper right direction) = (0+1+1+1, -1-1+0+1) = (3, -1)

[0128]

[0129] In the present disclosure, the inverse tangent function atan2() function can be used to calculate the gradient direction. For example, the gradient amplitude is The corresponding gradient direction is atan2(-1,3).

[0130] S302, merging the gradient amplitudes corresponding to the downsampled images, and taking the merged gradient amplitude as the target gradient amplitude, and taking the gradient direction with the largest corresponding gradient amplitude as the target gradient direction.

[0131] In the present disclosure, the gradient amplitude of the downsampled image can be added pixel by pixel and then averaged to obtain an overall gradient amplitude as the target gradient amplitude. Alternatively, the gradient amplitude of the downsampled image can be weighted averaged pixel by pixel to obtain an overall gradient amplitude as the target gradient amplitude.

[0132] S303: Determine the target gradient amplitude and the target gradient direction as target gradient information corresponding to the color image to be processed.

[0133] In the present disclosure, by calculating the gradient information in multiple preset directions, the edge structure in the image can be described more comprehensively and accurately, thereby more accurately determining the boundary of the color image to be processed.

[0134] In the present disclosure, the target gradient amplitude may also be normalized so that the gradient amplitude is in the range of 0 to 255, so that the result of boundary determination is easier to visualize. Specifically, a first difference between the gradient amplitude and the minimum gradient amplitude in the image may be calculated, and a second difference between the maximum gradient amplitude and the minimum gradient amplitude in the image may be calculated, and the product of the ratio of the first difference to the second difference and 255 may be used as the normalized gradient amplitude.

[0135] In one possible implementation, Figure 4 FIG. 4 shows a schematic diagram of an image boundary determination process provided by an embodiment of the present disclosure. Figure 4 As shown, determining the boundary area of ​​the color image to be processed according to the target gradient information includes:

[0136] S401, for each pixel in the color image to be processed, if the gradient amplitude of the pixel is greater than the gradient amplitude of the adjacent pixel of the pixel in the target gradient direction, the pixel is determined as a preliminary edge pixel.

[0137] In the present disclosure, each pixel can be detected along the gradient direction. If the gradient amplitude of the pixel point is greater than the gradient amplitude of the adjacent pixel point of the pixel point in the target gradient direction, then the pixel point may be an edge pixel point and needs to be retained to further determine whether it is an edge pixel point. Otherwise, the pixel point is not an edge pixel point and needs to be suppressed, so that only the pixel point with the largest gradient is retained.

[0138] S402: If the gradient amplitude of the pixel point is not greater than the gradient amplitude of the adjacent pixel points of the pixel point in the target gradient direction, the pixel point is determined as a non-edge pixel point.

[0139] S403, based on the preliminary edge pixels and the preset gradient threshold, determining the target edge pixels in the color image to be processed, and determining the image area composed of the target edge pixels as the boundary area of ​​the color image to be processed.

[0140] In the present disclosure, the step of determining the target edge pixel points in the color image to be processed based on the preliminary edge pixel points and the preset gradient threshold may include steps F1-F3:

[0141] Step F1: for each pixel in the color image to be processed, if the gradient amplitude of the pixel is greater than a first preset gradient threshold, the pixel is determined as a target edge pixel.

[0142] Step F2: if the gradient amplitude of the pixel point is less than a second preset gradient threshold, the pixel point is determined as a non-edge pixel point.

[0143] The first preset gradient threshold and the second preset gradient threshold can be set according to actual needs, and the first preset gradient threshold is greater than the second preset gradient threshold.

[0144] Step F3, if the gradient amplitude of the pixel point is greater than or equal to the second preset gradient threshold and less than or equal to the first preset gradient threshold, determine whether there is a preliminary edge pixel point among the adjacent pixels of the pixel point, if so, determine the pixel point as the target edge pixel point, if not, determine the pixel point as a non-edge pixel point.

[0145] In the present disclosure, if the gradient amplitude of a pixel point is greater than or equal to the second preset gradient threshold and less than or equal to the first preset gradient threshold, the pixel point may be an edge pixel. At this time, for further confirmation, it is necessary to detect whether there are preliminary edge pixels around the pixel point. If there are preliminary edge pixels, it can be indicated that the pixel point is a weak edge pixel point. The pixel point can be classified as an edge pixel point, so that the determined image boundary is more continuous.

[0146] Based on the same inventive concept, according to the image boundary determination method provided by the above embodiment of the present disclosure, correspondingly, another embodiment of the present disclosure further provides an image boundary determination device, whose structural schematic diagram is shown as follows: Figure 5 As shown, specifically including:

[0147] The target image determination module 501 is used to obtain sub-images of each color channel of the color image to be processed, and determine the target image based on each of the sub-images;

[0148] An image enhancement module 502 is used to perform edge enhancement processing on each of the target images to obtain corresponding enhanced images;

[0149] The downsampling module 503 is used to perform target downsampling processing on each enhanced image to obtain corresponding downsampled images;

[0150] A first gradient determination module 504 is used to determine edge gradient information of multiple preset directions of each downsampled image;

[0151] A second gradient determination module 505, configured to determine target gradient information corresponding to the color image to be processed based on edge gradient information corresponding to each downsampled image;

[0152] The boundary determination module 506 is used to determine the boundary area of ​​the color image to be processed according to the target gradient information.

[0153] The device is used to obtain sub-images of each color channel of the color image to be processed and determine the target image based on each sub-image, perform edge enhancement processing on each target image to obtain the corresponding enhanced images, perform target downsampling processing on each enhanced image to obtain the corresponding downsampled images, determine the edge gradient information of multiple preset directions of the downsampled image for each downsampled image, determine the target gradient information corresponding to the color image to be processed based on the edge gradient information corresponding to each downsampled image, and determine the boundary area of ​​the color image to be processed based on the target gradient information. Richer edge information is obtained by performing edge extraction on each channel image of the color image to be processed, and more accurate image edges are determined by combining target downsampling and multi-directional gradient information, thereby achieving accurate and flexible extraction of image boundaries.

[0154] In one possible implementation, the target image determination module 501 is specifically used to extract sub-images of each color channel of the color image to be processed; use each sub-image as the target image; or, reorganize each sub-image based on the preset weights corresponding to each sub-image to generate multiple single-channel images as the target image.

[0155] In one possible implementation, the target image determination module 501 is specifically used to superimpose pixels at corresponding positions of a group of sub-images according to preset weights corresponding to each sub-image to obtain multiple superimposed images, each group of sub-images including at least two sub-images with different color channels; and map the pixel value of each pixel point in each superimposed image to a preset pixel range, the maximum pixel of the preset pixel range is less than or equal to the maximum pixel value in each sub-image, and the minimum pixel of the preset pixel range is greater than or equal to 0.

[0156] In one possible implementation, the image enhancement module 502 is specifically used to reset the pixel value of each pixel point in the target image whose pixel value is not greater than the reference pixel value to a first preset pixel value for each of the target images, and to calculate the absolute value of the pixel difference between the reference pixel value and the pixel value of each pixel point in the target image whose pixel value is greater than the reference pixel value, and to reset the absolute value of the pixel difference to the pixel value of the corresponding pixel point, so as to obtain an intermediate processed image corresponding to each of the target images; based on the mapping parameters, the pixel values ​​of the pixel points of each of the intermediate processed images are within a preset pixel range, so as to obtain corresponding enhanced images, wherein the maximum pixel in the preset pixel range is less than or equal to the second preset pixel value, and the minimum pixel in the preset pixel range is greater than or equal to the first preset pixel value.

[0157] In one possible implementation, the image enhancement module 502 is specifically used to obtain the maximum pixel value and the minimum pixel value corresponding to each of the target images; for each of the target images, calculate the pixel difference between the maximum pixel value and the minimum pixel value corresponding to the target image, and use the ratio of the second preset pixel value to the pixel difference as the mapping parameter of the intermediate processed image corresponding to the target image; for each intermediate processed image, reset the product of the pixel value of each pixel point of the intermediate processed image and the mapping parameter to the pixel value of the corresponding pixel point, so as to obtain the corresponding enhanced images.

[0158] In one possible implementation, the downsampling module 503 is specifically used to divide each enhanced image into multiple overlapping sub-images according to a preset downsampling ratio, and there is an overlapping area between any two overlapping sub-images; calculate the pixel average of each overlapping sub-image, and reset the pixel value of each pixel in the overlapping sub-image to the pixel average of the overlapping sub-image, so as to obtain the downsampled image corresponding to the enhanced image.

[0159] In one possible implementation manner, the first gradient determination module 504 is specifically configured to perform convolution processing on each downsampled image for a preset number of times using a convolution kernel corresponding to each preset direction to obtain a gradient vector of the downsampled image in each preset direction as edge gradient information.

[0160] In one possible implementation manner, the second gradient determination module 505 is specifically configured to determine, for each downsampled image, a gradient magnitude and a gradient direction corresponding to the downsampled image based on a gradient vector of the downsampled image in each preset direction; merge the gradient magnitudes corresponding to the downsampled images, and use the merged gradient magnitude as a target gradient magnitude, and use the gradient direction with the largest corresponding gradient magnitude as a target gradient direction; and determine the target gradient magnitude and target gradient direction as target gradient information corresponding to the color image to be processed.

[0161] In one possible implementation, the boundary determination module 506 is specifically used to, for each pixel point in the color image to be processed, determine the pixel point as a preliminary edge pixel point if the gradient amplitude of the pixel point is greater than the gradient amplitude of the adjacent pixel points of the pixel point in the target gradient direction; if the gradient amplitude of the pixel point is not greater than the gradient amplitude of the adjacent pixel points of the pixel point in the target gradient direction, determine the pixel point as a non-edge pixel point; based on the preliminary edge pixel points and a preset gradient threshold, determine the target edge pixel points in the color image to be processed, and determine the image area composed of the target edge pixel points as the boundary area of ​​the color image to be processed.

[0162] In one possible implementation, the boundary determination module 506 is specifically used to, for each pixel point in the color image to be processed, determine the pixel point as a target edge pixel point if the gradient amplitude of the pixel point is greater than a first preset gradient threshold; determine the pixel point as a non-edge pixel point if the gradient amplitude of the pixel point is less than a second preset gradient threshold; and determine whether there is a preliminary edge pixel point among the adjacent pixels of the pixel point if the gradient amplitude of the pixel point is greater than or equal to the second preset gradient threshold and less than or equal to the first preset gradient threshold; if so, determine the pixel point as a target edge pixel point; if not, determine the pixel point as a non-edge pixel point.

[0163] According to an embodiment of the present disclosure, the present disclosure also provides an electronic device and a readable storage medium.

[0164] Figure 6A schematic block diagram of an example electronic device 600 that can be used to implement an embodiment of the present disclosure is shown. The electronic device is intended to represent various forms of digital computers, such as laptop computers, desktop computers, workstations, personal digital assistants, servers, blade servers, mainframe computers, and other suitable computers. The electronic device can also represent various forms of mobile devices, such as personal digital processing, cellular phones, smart phones, wearable devices, and other similar computing devices. The components shown herein, their connections and relationships, and their functions are merely examples and are not intended to limit the implementation of the present disclosure described and / or required herein.

[0165] like Figure 6 As shown, the device 600 includes a computing unit 601, which can perform various appropriate actions and processes according to a computer program stored in a read-only memory (ROM) 602 or a computer program loaded from a storage unit 608 into a random access memory (RAM) 603. In the RAM 603, various programs and data required for the operation of the device 600 can also be stored. The computing unit 601, the ROM 602, and the RAM 603 are connected to each other via a bus 604. An input / output (I / O) interface 605 is also connected to the bus 604.

[0166] A number of components in the device 600 are connected to the I / O interface 605, including: an input unit 606, such as a keyboard, a mouse, etc.; an output unit 607, such as various types of displays, speakers, etc.; a storage unit 608, such as a disk, an optical disk, etc.; and a communication unit 609, such as a network card, a modem, a wireless communication transceiver, etc. The communication unit 609 allows the device 600 to exchange information / data with other devices through a computer network such as the Internet and / or various telecommunication networks.

[0167] The computing unit 601 may be a variety of general and / or special processing components with processing and computing capabilities. Some examples of the computing unit 601 include, but are not limited to, a central processing unit (CPU), a graphics processing unit (GPU), various dedicated artificial intelligence (AI) computing chips, various computing units running machine learning model algorithms, digital signal processors (DSPs), and any appropriate processors, controllers, microcontrollers, etc. The computing unit 601 performs the various methods and processes described above, such as the image boundary determination method. For example, in some embodiments, the image boundary determination method may be implemented as a computer software program, which is tangibly contained in a machine-readable medium, such as a storage unit 608. In some embodiments, part or all of the computer program may be loaded and / or installed on the device 600 via the ROM 602 and / or the communication unit 609. When the computer program is loaded into the RAM 603 and executed by the computing unit 601, one or more steps of the image boundary determination method described above may be performed. Alternatively, in other embodiments, the computing unit 601 may be configured to perform the image boundary determination method in any other appropriate manner (e.g., by means of firmware).

[0168] Various implementations of the systems and techniques described above herein can be implemented in digital electronic circuit systems, integrated circuit systems, field programmable gate arrays (FPGAs), application specific integrated circuits (ASICs), application specific standard products (ASSPs), systems on chips (SOCs), complex programmable logic devices (CPLDs), computer hardware, firmware, software, and / or combinations thereof. These various implementations can include: being implemented in one or more computer programs that can be executed and / or interpreted on a programmable system including at least one programmable processor, which can be a special purpose or general purpose programmable processor that can receive data and instructions from a storage system, at least one input device, and at least one output device, and transmit data and instructions to the storage system, the at least one input device, and the at least one output device.

[0169] The program code for implementing the method of the present disclosure may be written in any combination of one or more programming languages. These program codes may be provided to a processor or controller of a general-purpose computer, a special-purpose computer, or other programmable data processing device, so that the program code, when executed by the processor or controller, enables the functions / operations specified in the flow chart and / or block diagram to be implemented. The program code may be executed entirely on the machine, partially on the machine, partially on the machine and partially on a remote machine as a stand-alone software package, or entirely on a remote machine or server.

[0170] In the context of the present disclosure, a machine-readable medium may be a tangible medium that may contain or store a program for use by or in conjunction with an instruction execution system, device, or equipment. A machine-readable medium may be a machine-readable signal medium or a machine-readable storage medium. A machine-readable medium may include, but is not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, device, or equipment, or any suitable combination of the foregoing. A more specific example of a machine-readable storage medium may include an electrical connection based on one or more lines, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.

[0171] To provide interaction with a user, the systems and techniques described herein can be implemented on a computer having: a display device (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor) for displaying information to the user; and a keyboard and pointing device (e.g., a mouse or trackball) through which the user can provide input to the computer. Other types of devices can also be used to provide interaction with the user; for example, the feedback provided to the user can be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user can be received in any form (including acoustic input, voice input, or tactile input).

[0172] The systems and techniques described herein may be implemented in a computing system that includes back-end components (e.g., as a data server), or a computing system that includes middleware components (e.g., an application server), or a computing system that includes front-end components (e.g., a user computer with a graphical user interface or a web browser through which a user can interact with implementations of the systems and techniques described herein), or a computing system that includes any combination of such back-end components, middleware components, or front-end components. The components of the system may be interconnected by any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include: a local area network (LAN), a wide area network (WAN), and the Internet.

[0173] A computer system may include a client and a server. The client and the server are generally remote from each other and usually interact through a communication network. The relationship of client and server is generated by computer programs running on respective computers and having a client-server relationship with each other. The server may be a cloud server, a server of a distributed system, or a server combined with a blockchain.

[0174] It should be understood that the various forms of processes shown above can be used to reorder, add or delete steps. For example, the steps recorded in this disclosure can be executed in parallel, sequentially or in different orders, as long as the desired results of the technical solutions disclosed in this disclosure can be achieved, and this document does not limit this.

[0175] In addition, the terms "first" and "second" are used for descriptive purposes only and should not be understood as indicating or implying relative importance or implicitly indicating the number of technical features indicated. Thus, a feature defined as "first" or "second" may explicitly or implicitly include at least one of the features. In the description of the present disclosure, the meaning of "plurality" is two or more, unless otherwise clearly and specifically defined.

[0176] The above is only a specific embodiment of the present disclosure, but the protection scope of the present disclosure is not limited thereto. Any person skilled in the art who is familiar with the technical field can easily think of changes or substitutions within the technical scope disclosed in the present disclosure, which should be included in the protection scope of the present disclosure. Therefore, the protection scope of the present disclosure should be based on the protection scope of the claims.

Claims

1. A method for determining image boundaries, It is characterized in that The method comprises: Obtaining sub-images of each color channel of the color image to be processed, and determining a target image based on each of the sub-images; Performing edge enhancement processing on each of the target images to obtain corresponding enhanced images; Performing target downsampling processing on each enhanced image to obtain corresponding downsampled images; For each downsampled image, determining edge gradient information of a plurality of preset directions of the downsampled image; Determining target gradient information corresponding to the color image to be processed based on edge gradient information corresponding to each downsampled image; The boundary area of ​​the color image to be processed is determined according to the target gradient information.

2. The method according to claim 1, It is characterized in that The step of acquiring sub-images of each color channel of the color image to be processed and determining the target image based on each of the sub-images includes: Extracting sub-images of each color channel of the color image to be processed; Use each sub-image as the target image; or, The sub-images are reorganized based on the preset weights corresponding to the sub-images to generate a plurality of single-channel images as the target image.

3. The method according to claim 2, It is characterized in that The step of recombining the sub-images based on the preset weights corresponding to the sub-images to generate a plurality of single-channel images as the target image includes: Superimposing pixels at corresponding positions of a group of sub-images according to preset weights corresponding to the sub-images to obtain a plurality of superimposed images, wherein each group of sub-images includes at least two sub-images of different color channels; The pixel value of each pixel point in each superimposed image is mapped into a preset pixel range, wherein the maximum pixel in the preset pixel range is less than or equal to the maximum pixel value in each sub-image, and the minimum pixel in the preset pixel range is greater than or equal to 0.

4. The method according to claim 1, It is characterized in that The performing edge enhancement processing on each of the target images to obtain corresponding enhanced images includes: For each of the target images, the pixel value of each pixel point in the target image whose pixel value is not greater than the reference pixel value is reset to a first preset pixel value, and the absolute value of the pixel difference between the reference pixel value and the pixel value of each pixel point in the target image whose pixel value is greater than the reference pixel value is calculated, and the absolute value of the pixel difference is reset to the pixel value of the corresponding pixel point, so as to obtain an intermediate processed image corresponding to each of the target images; Based on the mapping parameters, the pixel values ​​of the pixel points of each intermediate processed image are placed within a preset pixel range to obtain the corresponding enhanced images, wherein the maximum pixel in the preset pixel range is less than or equal to the second preset pixel value, and the minimum pixel in the preset pixel range is greater than or equal to the first preset pixel value.

5. The method according to claim 4, It is characterized in that The method of setting the pixel values ​​of the pixels of each intermediate processed image within a preset pixel range based on the mapping parameters to obtain the corresponding enhanced images includes: Obtaining the maximum pixel value and the minimum pixel value corresponding to each of the target images; For each of the target images, a pixel difference between a maximum pixel value and a minimum pixel value corresponding to the target image is calculated, and a ratio of the second preset pixel value to the pixel difference is used as a mapping parameter of an intermediate processing image corresponding to the target image; For each intermediate processed image, the product of the pixel value of each pixel point of the intermediate processed image and the mapping parameter is reset to the pixel value of the corresponding pixel point to obtain each corresponding enhanced image.

6. The method according to claim 1, It is characterized in that The step of performing target downsampling processing on each enhanced image to obtain corresponding downsampled images includes: For each enhanced image, the enhanced image is divided into a plurality of overlapping sub-images according to a preset downsampling ratio, and there is an overlapping area between any two overlapping sub-images; The pixel average value of each overlapping sub-image is calculated, and the pixel value of each pixel point in the overlapping sub-image is reset to the pixel average value of the overlapping sub-image, so as to obtain the downsampled image corresponding to the enhanced image.

7. The method according to claim 6, It is characterized in that Before determining edge gradient information of multiple preset directions of each downsampled image, the method further includes: Perform filtering on each downsampled image.

8. An image boundary determination device, It is characterized in that The device comprises: A target image determination module, used to obtain sub-images of each color channel of the color image to be processed, and determine the target image based on each of the sub-images; An image enhancement module, used to perform edge enhancement processing on each of the target images to obtain corresponding enhanced images; A downsampling module is used to perform target downsampling processing on each enhanced image to obtain corresponding downsampled images; A first gradient determination module, configured to determine, for each downsampled image, edge gradient information of the downsampled image in a plurality of preset directions; A second gradient determination module, configured to determine target gradient information corresponding to the color image to be processed based on edge gradient information corresponding to each downsampled image; The boundary determination module is used to determine the boundary area of ​​the color image to be processed according to the target gradient information.

9. An electronic device, It is characterized in that include: at least one processor; as well as a memory communicatively connected to the at least one processor; wherein, The memory stores instructions that can be executed by the at least one processor, and the instructions are executed by the at least one processor to enable the at least one processor to perform the method according to any one of claims 1 to 7.

10. A non-transitory computer-readable storage medium storing computer instructions, It is characterized in that The computer instructions are used to make a computer execute the method according to any one of claims 1-7.