Image segmentation method and device, computer device and readable storage medium
Patent Information
- Application Number
- CN202511055105.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-07-30
- Publication Date
- 2026-10-27
- Estimated Expiration
- 2045-07-30
AI Technical Summary
[0003]传统技术中,将图像进行等比例分块,会降低目标对象的检测率,且增加了目标对象的误检率
[0041]第五方面,本申请还提供了一种计算机程序产品。所述计算机程序产品,包括计算机程序,该计算机程序被处理器执行时实现上述任意实施例中图像分割的步骤。
Smart Images

Figure CN121259012B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of image processing technology, and in particular to an image segmentation method, apparatus, computer device, computer-readable storage medium, and computer program product. Background Technology
[0002] With the rapid development of information technology, image acquisition has become increasingly convenient. However, images typically involve large amounts of data, and directly processing the entire image often faces limitations in computing resources, low processing efficiency, and the inability to fully extract local image features. This is especially true for ultra-high-definition images, and in practical applications, the requirements for detecting and recognizing small targets are becoming increasingly stringent.
[0003] In traditional techniques, dividing an image into proportional blocks reduces the detection rate of target objects and increases the false detection rate. Furthermore, in cases of detailed object segmentation, such as identifying cyclists or lying down, the detection rate remains low while the false detection rate is high. Therefore, the accuracy of representing image block information needs improvement. Summary of the Invention
[0004] Therefore, it is necessary to provide an image segmentation method, apparatus, computer device, computer-readable storage medium, and computer program product that can improve the accuracy of information expression in response to the above-mentioned technical problems.
[0005] In a first aspect, this application provides an image segmentation method, the method comprising:
[0006] Obtain a first reference size and a second reference size when the calibration object and the camera are at different distances; the first reference size is smaller than the second reference size, the calibration image captured by the camera contains the calibration object at different positions, and the initial image captured by the camera contains the target object;
[0007] A reference block size is determined based on the target object, and a difference calculation is performed based on the size difference between the first reference size and the second reference size, and the size difference between the size of the initial image and the first reference size, to obtain a relative size difference; based on the relative size difference, the reference block size is enlarged into multiple block sizes;
[0008] The initial image is divided according to the multiple block sizes to obtain image blocks of the multiple block sizes.
[0009] In one embodiment, the reference block size includes a reference image block size and a reference overlapping region size; determining the reference block size based on the target object includes:
[0010] In the initial image, obtain the size of the furthest target object;
[0011] The size of the farthest target object is reduced according to the overlap ratio to obtain the reference overlap region size; wherein, the reference overlap region size is the overlap region size between the reference image block and the next image block of the reference image block;
[0012] If the size of the farthest target object is smaller than the minimum target size, then the size of the reference image patch is determined based on the model input size; the minimum target size is the minimum size used for object recognition.
[0013] If the size of the farthest target object is greater than the minimum target size, then the size of the farthest target object is adjusted based on the size difference between the model input size and the minimum target size to obtain the reference image block size.
[0014] In one embodiment, the block size includes the image block size;
[0015] The step of enlarging the reference block size into multiple block sizes based on the relative size difference includes:
[0016] Based on the relative size difference, the difference between the size of the (i-1)th image block and the first reference size is adjusted to obtain the i-th change value; where i is a positive integer greater than 1, and the size of the (i-1)th image block includes the size of the first image block, which is the size of the reference image block;
[0017] Based on the i-th change value, the first reference size is increased to obtain the i-th adjusted reference size;
[0018] Based on the size difference between the model input size and the target minimum size, the i-th adjusted reference size is enlarged to obtain the size of the i-th image block.
[0019] In one embodiment, the size of the i-th block further includes the size of the i-th overlapping region; the method further includes:
[0020] Based on the overlap ratio, a portion of the adjusted reference size of the i-th region is selected to obtain the size of the i-th overlapping region;
[0021] Wherein, the size of the i-th overlapping region is the size of the overlapping region between the i-th image block and the next image block of the i-th image block.
[0022] In one embodiment, the (i-1)th image block and the i-th image block are divided based on their respective first corner point and second corner point, where the first corner point and the second corner point are diagonal positions of the same image block, and i is a positive integer greater than 1;
[0023] The step of dividing the initial image according to the multiple block sizes to obtain image blocks of the multiple block sizes includes:
[0024] Displace the second corner point of the (i-1)th image block in the reference direction according to the size of the i-th overlapping region to obtain the first corner point of the i-th image block;
[0025] Displace the first corner point corresponding to the i-th image block in the reference direction according to the size of the i-th image block to obtain the second corner point corresponding to the i-th image block;
[0026] If the second corner point corresponding to the i-th image block is located within the initial image, then the initial image is segmented according to the first corner point of the i-th image block and the second corner point corresponding to the i-th image block to obtain the i-th image block.
[0027] In one embodiment, the method further includes:
[0028] If the second corner point corresponding to the i-th image block is located outside the initial image, then a new second corner point corresponding to the i-th image block is determined based on the boundary of the initial image;
[0029] Displace the new second corner point corresponding to the i-th image block in the reference direction according to the size of the i-th image block to obtain the new first corner point corresponding to the i-th image block;
[0030] The initial image is segmented based on the new first corner point and the new second corner point corresponding to the i-th image block to obtain the i-th image block.
[0031] In one embodiment, the method further includes:
[0032] By using the target object recognition model, the target object is detected in each of the image blocks to obtain the region where the target object is located in each of the image blocks;
[0033] The image is obtained by combining the coordinates of the target object regions of each image block in the initial image;
[0034] The target objects in the restored image are deduplicated to obtain the regions of interest for each target object.
[0035] Secondly, this application also provides an image segmentation apparatus, comprising:
[0036] The size acquisition module is used to acquire a first reference size and a second reference size when the calibration object and the camera are at different distances; the first reference size is smaller than the second reference size, the calibration image captured by the camera contains the calibration object at different positions, and the initial image captured by the camera contains the target object;
[0037] The segmentation module determines a reference block size based on the target object, and performs a difference calculation based on the size difference between the first reference size and the second reference size, and the size difference between the size of the initial image and the first reference size, to obtain a relative size difference; based on the relative size difference, the reference block size is enlarged into multiple block sizes;
[0038] An adjustment module is used to divide the initial image according to the multiple block sizes to obtain image blocks of the multiple block sizes.
[0039] Thirdly, this application also provides a computer device. The computer device includes a memory and a processor, the memory storing a computer program, and the processor executing the computer program to implement the image segmentation steps in any of the above embodiments.
[0040] Fourthly, this application also provides a computer-readable storage medium. The computer-readable storage medium stores a computer program thereon, which, when executed by a processor, implements the image segmentation steps in any of the above embodiments.
[0041] Fifthly, this application also provides a computer program product. The computer program product includes a computer program that, when executed by a processor, implements the image segmentation steps in any of the above embodiments.
[0042] The aforementioned image segmentation method, apparatus, computer device, computer-readable storage medium, and computer program product acquire a first reference size and a second reference size when the calibration object and the camera are at different distances; the first reference size is smaller than the second reference size, and the initial image acquired by the camera contains the calibration object at different positions. Therefore, the scale representation in the initial image captured by the camera can be clearly defined through the first reference size and the second reference size. Then, a reference block size is determined based on the target object to clarify the size suitable for the target object to be used for information expression. A relative size difference is obtained by calculating the difference between the first and second reference sizes and the size difference between the initial image size and the first reference size. This relative size difference represents the relative magnitude of size change when the target object is at different distances from the camera, clarifying the magnitude of image size change during the segmentation process. Then, based on the relative size difference, the reference block size is enlarged into multiple block sizes to accommodate the size of the target object at different positions. Finally, the initial image is segmented according to the multiple block sizes to obtain image blocks of the multiple block sizes. This achieves adaptive adjustment of the image block size according to the block size of the target object at the corresponding position, allowing different target objects in the same initial image to adaptively express information according to their own size, and preventing target objects of different block sizes from influencing each other, thus making the information expressed by each image block more accurate. Attached Figure Description
[0043] To more clearly illustrate the technical solutions in the embodiments of this application or related technologies, the drawings used in the description of the embodiments of this application or related technologies will be briefly introduced below. Obviously, the drawings described below are only some embodiments of this application. For those skilled in the art, other related drawings can be obtained based on these drawings without creative effort.
[0044] Figure 1 This is an application environment diagram of the image segmentation method in one embodiment;
[0045] Figure 2 This is a flowchart illustrating an image segmentation method in one embodiment;
[0046] Figure 3 This is a flowchart illustrating the scaling up of block sizes in one embodiment;
[0047] Figure 4 This is a structural block diagram of an image segmentation device in one embodiment;
[0048] Figure 5 This is an internal structural diagram of a computer device in one embodiment. Detailed Implementation
[0049] To make the objectives, technical solutions, and advantages of this application clearer, the following detailed description is provided in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative and not intended to limit the scope of this application.
[0050] In one example, this solution is used in a hyperconverged edge agent with multiple cameras. This hyperconverged edge agent needs to detect and recognize targets with a radius of 24 meters. In this case, the minimum target size is 32*32, and it supports simultaneous processing of 3 video streams, with at least 3 AI application scenarios per stream. In this scenario, the size difference between close-range and distant targets is very large. Therefore, without image segmentation, it is difficult to meet the requirements.
[0051] For example, using large-sized image inputs for deep learning-based object detection methods requires numerous convolution and pooling operations, significantly increasing detection time and severely impacting efficiency. Randomly or proportionally dividing the image into blocks results in a single object being divided into multiple blocks, reducing the detection rate and increasing the false positive rate, especially for finer object segmentation, such as identifying cyclists or lying down. Furthermore, a smaller input size is unsuitable for detecting small objects at long distances to meet resource and speed requirements. Therefore, this solution necessitates image segmentation to facilitate image recognition.
[0052] The image segmentation method provided in this application embodiment can be applied to, for example... Figure 1 In the application environment shown, terminal 102 communicates with camera 104 via a network. A data storage system can store the data that camera 104 needs to process. The data storage system can be integrated into terminal 102 or placed in the cloud or on another network server.
[0053] The terminal 102 can be, but is not limited to, various personal computers, laptops, smartphones, tablets, IoT devices, and portable wearable devices. IoT devices can include smart speakers, smart TVs, smart air conditioners, smart in-vehicle systems, and projection devices. Portable wearable devices can include smartwatches, smart bracelets, and head-mounted displays. Head-mounted displays can be virtual reality (VR) devices, augmented reality (AR) devices, and smart glasses. The camera 104 can be a standalone physical server, a server cluster or distributed system composed of multiple physical servers, or a cloud server providing cloud computing services.
[0054] In one exemplary embodiment, such as Figure 2As shown, an image segmentation method is provided, which can be applied to... Figure 1 Taking the camera in the image as an example, the explanation includes steps 202 to 206. Wherein:
[0055] Step 202: Obtain the first reference size and the second reference size when the calibration object and the camera are at different distances.
[0056] In this system, the first reference size is smaller than the second reference size. The calibration images captured by the camera contain calibration objects at different locations, and the initial images captured by the camera contain the target object. The calibration objects are used to perform scale calibration on the images captured by the camera; these calibration objects at different locations can be calibration points or different squares on a chessboard. The dimensions of the calibration objects are known, and the distances between calibration objects at different locations are also determined.
[0057] The first reference dimension and the second reference dimension are the dimensions of calibration objects at different depths in the calibration image. Since the first reference dimension is smaller than the second reference dimension, the calibration object at the first reference dimension is relatively farther from the camera, while the calibration object at the second reference dimension is relatively closer to the camera. Both the first and second reference dimensions may include dimensions in the horizontal direction and dimensions in the vertical direction.
[0058] In some examples, the first reference size is the size of the calibration object with the largest depth information in the calibration image, that is, the size of the calibration object farthest from the camera in the calibration image; the second reference size is the size of the calibration object with the smallest depth information in the calibration image, that is, the size of the calibration object closest to the camera in the calibration image.
[0059] The calibration objects at different locations are the same type of calibration objects at different locations in the calibration image; different locations refer to different depth information. The same type of calibration objects can be completely identical objects or different objects with similar features.
[0060] The initial image is an image that needs to be adaptively segmented according to the target object. The initial image can be an image directly captured by the camera, or an image captured by a similar type of camera at the same location. Since the calibration image and the initial image are both captured by the same camera or a similar type of camera at the same location, the distance change patterns of the calibration image and the initial image are matched.
[0061] The target object is the type of object that needs to be determined based on image detection; the target object is adaptively adjusted according to scene requirements, and the characteristics of the target object are different in different scenes. When using this embodiment, the block size of different types of target objects will be adaptively adjusted according to the actual size of the target object to reduce the false detection rate of the target object.
[0062] In some embodiments, obtaining a first reference size and a second reference size when the calibration object and the camera are at different distances includes: converting the actual size of the calibration object into the first reference size and the second reference size when the calibration object and the camera are at different distances. This allows for the efficient acquisition of a pair of reference sizes for calibration objects of the same shape at different depths before image acquisition, enabling the determination of relative size differences. Thus, the first reference size and the second reference size are obtained based on depth-of-field calibration using the camera; wherein, a calibration image containing a checkerboard pattern can be printed out, and calibration can be performed at near and far distances to obtain the first reference size and the second reference size.
[0063] Step 204: Determine the reference block size based on the target object, and calculate the difference based on the size difference between the first reference size and the second reference size, and the size difference between the size of the initial image and the first reference size to obtain the relative size difference; based on the relative size difference, enlarge the reference block size into multiple block sizes.
[0064] The size difference is a size value determined based on the difference between two sizes. The sizes of the first reference size, the second reference size, and the initial image can all include both horizontal and vertical dimensions; and the size difference includes both horizontal and vertical size differences. The size difference between the first and second reference sizes represents the size change of any object in the initial image when the depth changes, thus forming the adjustment dimension within the image. "Any object" includes the target object. Correspondingly, the size difference between the initial image size and the first reference size represents the size change between the initial image as a whole and the first reference size, thus forming the adjustment dimension between the image and the actual object.
[0065] The dimensional difference between the first reference dimension and the second reference dimension includes, but is not limited to, the difference between the first reference dimension and the second reference dimension or the absolute value of the difference, which may include the difference between two dimensions in the horizontal direction or the difference between two dimensions in the vertical direction. The dimensional difference between the initial image and the first reference dimension includes, but is not limited to, the difference between the initial image and the first reference dimension or the absolute value of the difference, which may include the difference between two dimensions in the horizontal direction or the difference between two dimensions in the vertical direction.
[0066] Relative size difference is the relative difference between two size differences, representing the relative magnitude of size change of a target object at different distances from the camera. Relative size difference can be the ratio of two size differences, including relative size differences in two horizontal directions and relative size differences in two vertical directions. For example, the relative size difference can be calculated by comparing the size difference between a first reference size and a second reference size, and the size difference between the initial image size and the first reference size.
[0067] The block size includes at least the size of each image block, and may also include local dimensions within the image block. Local dimensions within the image block include, but are not limited to, the size of repeating regions within each image block or the adjusted reference size of the target object within the image block.
[0068] The reference block size is the block size to be enlarged, used to adaptively adjust the block size according to the size and position of the target object. The reference block size can be the smallest size for dividing the initial image into blocks. In this case, the reference block size can be enlarged multiple times by relative size differences to obtain at least one block size for each enlargement. At this time, each enlarged at least one block size can belong to multiple block sizes.
[0069] The reference block size may not be the smallest size of the initial image for block division. In this case, the reference block size can be enlarged multiple times by relative size differences to obtain at least one block size for each enlargement. Then, the reference block size can be reduced multiple times to obtain at least one block size for each reduction. At this time, the at least one block size for each enlargement and the at least one block size for each reduction can belong to multiple block sizes.
[0070] Step 206: Divide the initial image according to multiple block sizes to obtain image blocks of multiple block sizes.
[0071] An image patch is an image composed of local regions of an initial image at different patch sizes. The size of each patch is negatively correlated with the depth information of the target object contained in the initial image, while the size of the image patch is positively correlated with the patch size; the greater the depth information of the target object, the smaller the patch size and the smaller the image patch size; the smaller the depth information of the target object, the larger the patch size and the larger the image patch size.
[0072] In one embodiment, image blocks of each segment size can be acquired from the initial image according to the location of the target object or the parts contained in the target object, to obtain multiple image blocks of different segment sizes.
[0073] In the above image segmentation method, a first reference size and a second reference size are obtained when the calibration object and the camera are at different distances; the first reference size is smaller than the second reference size, and the initial image captured by the camera contains calibration objects at different positions. Therefore, the scale representation in the initial image captured by the camera can be clearly defined using the first and second reference dimensions. Then, a reference block size is determined based on the target object, thus clarifying the size suitable for the target object to be used for information expression. A relative size difference is obtained by calculating the size difference between the first and second reference dimensions, and the size difference between the initial image size and the first reference dimension. This relative size difference represents the relative magnitude of size change when the target object is at different distances from the camera, clarifying the magnitude of image size change during segmentation. Based on the relative size difference, the reference block size is then enlarged into multiple block sizes to accommodate the size of the target object at different positions. Finally, the initial image is segmented according to these multiple block sizes, resulting in image blocks of multiple block sizes. This achieves adaptive adjustment of the image block size according to the block size of the target object at the corresponding position, allowing different target objects in the same initial image to adaptively express information according to their own size, and preventing mutual interference between target objects of different block sizes, thus making the information expressed by each image block more accurate.
[0074] In some embodiments, the reference block size includes a reference image block size and a reference overlapping region size; determining the reference block size based on the target object includes: obtaining the size of the farthest target object in the initial image; reducing the size of the farthest target object according to the overlap ratio to obtain the reference overlapping region size; wherein, the reference overlapping region size is the overlapping region size between the reference image block and the next image block of the reference image block; if the size of the farthest target object is smaller than the target minimum size, then the reference image block size is determined based on the model input size; the target minimum size is the minimum size used for object recognition; if the size of the farthest target object is larger than the target minimum size, then the size of the farthest target object is adjusted based on the size difference between the model input size and the target minimum size to obtain the reference image block size.
[0075] The size of the farthest target object is the size of the target object with the largest depth information in the initial image. The farthest target object is the smallest target object in the initial image.
[0076] The overlap ratio is a proportional value used to set the size of the overlapping area between two consecutively adjacent image blocks based on the size of the target object in the initial image. The overlap ratio can include both horizontal and vertical overlap ratios. When the size of the furthest target object is reduced according to the overlap ratio, the image block at the reference overlapping area size may not cover the entire target object, but rather a portion of it. In this case, if the target object is located at the boundary between two adjacent image blocks, at least a portion of the target object is considered an overlapping area, facilitating reconstruction into the corresponding image. For example, at a certain overlap ratio value, two adjacent image blocks each contain the complete target object; at another overlap ratio value, two adjacent image blocks each contain a portion of the same area of the target object.
[0077] The reference overlapping region size is the size of the overlapping region contained in the reference image block; the reference overlapping region size is used to represent the redundancy information between the reference image block and other image blocks, so as to avoid information loss through redundancy. The reference image block is an image block divided from the initial image, and the reference image block contains at least part of the structure of the target object.
[0078] In one example, if the overlap ratio is 20%, then the overlapping area between the reference image block and the next image block of the reference image block occupies 20% of the reference image block, and the size of the reference overlapping area is 20% of the size of the reference image block.
[0079] The minimum target size is the minimum image size required for the target object recognition process. The minimum target size can be the minimum image size that the recognition model supports for recognition; or it can be the size threshold by which the recognition model identifies image blocks, combining and restoring the complete target object based on the minimum target size image blocks.
[0080] The model input size is the basic size for image recognition; the model input size can involve both vertical and horizontal dimensions; the size difference between the vertical model input size and the minimum target size is used to adjust the size of the farthest target object in the vertical direction; the size difference between the horizontal model input size and the minimum target size is used to adjust the size of the farthest target object in the horizontal direction; and the vertical and horizontal dimensions can be the same or different.
[0081] The size difference between the model input size and the minimum target size is used to represent the relative scale between the model input size and the minimum target size. This allows the size of the farthest target object to be closer to the size of the target object that can be accurately detected, so that the image patch of the reference image patch size can more accurately reflect the information of the target object.
[0082] In some embodiments, reducing the size of the farthest target object according to the overlap ratio to obtain the reference overlap region size includes: using the product of the overlap ratio and the size of the farthest target object as the reference overlap region size; wherein the overlap ratio is a positive number less than 1.
[0083] In some embodiments, if the size of the farthest target object is smaller than the minimum target size, the reference image patch size is determined based on the model input size. This includes: if the size of the farthest target object in the horizontal direction is smaller than the minimum target size, the reference image patch size in the horizontal direction is determined based on the model input size in the horizontal direction; if the size of the farthest target object in the vertical direction is smaller than the minimum target size, the reference image patch size in the vertical direction is determined based on the model input size in the vertical direction. Therefore, by comparing the horizontal and vertical directions separately, the reference image patch size can be determined more precisely.
[0084] In some embodiments, if the size of the farthest target object is larger than the minimum target size, the size of the farthest target object is reduced based on the size difference between the minimum target size and the size of the initial image to obtain the reference image patch size. This includes: if the size of the farthest target object in the horizontal direction is larger than the minimum target size in the horizontal direction, the size of the farthest target object in the horizontal direction is reduced based on the size difference between the minimum target size in the horizontal direction and the size of the initial image to obtain the reference image patch size in the horizontal direction; if the size of the farthest target object in the vertical direction is larger than the minimum target size in the vertical direction, the size of the farthest target object in the vertical direction is reduced based on the size difference between the minimum target size in the vertical direction and the size of the initial image to obtain the reference image patch size in the vertical direction. Therefore, by comparing the horizontal and vertical directions separately, the reference image patch size can be determined more precisely.
[0085] In this embodiment, the reference overlapping region size is set for the size of the farthest target object, ensuring that the sizes of target objects within the image patch are compatible. When the target object of the farthest size is composed of image patches of the same size, this reference size guarantees accurate identification of the target object. Specifically, if the size of the farthest target object is smaller than the minimum target size, the reference image patch size is determined based on the model input size, ensuring that the image patch matches the size requirements for target object detection. This allows each image patch to be directly and accurately identified, or combined and then accurately identified. If the size of the farthest target object is larger than the minimum target size, the size of the farthest target object is adjusted based on the size difference between the model input size and the minimum target size to obtain the reference image patch size. This ensures that the reference image patch size balances the compatibility between the initial image size and the minimum target size, guaranteeing the accuracy of image patch detection.
[0086] In some embodiments, the block size includes the image block size;
[0087] like Figure 3 As shown, based on the relative size differences, the reference block size is enlarged into multiple block sizes, including:
[0088] Step 302: Based on the relative size difference, adjust the difference between the size of the (i-1)th image block and the first reference size to obtain the i-th change value.
[0089] Where i is a positive integer greater than 1, the size of the (i-1)th image patch includes the size of the first image patch, and the size of the first image patch is the size of the reference image patch. The difference between the size of the (i-1)th image patch and the first reference size is used to represent the size difference between the previous image patch size and the first reference size of the farthest target, and is used to determine the size change that the i-th image patch needs to be adjusted.
[0090] The i-th change value is obtained by converting the difference between the size of the (i-1)-th image patch and the first reference size, with the relative size difference as a reference. Since the relative size difference can clearly define the magnitude of image size change during the segmentation process, and the size of the (i-1)-th image patch can represent the relative difference between the size of the (i-1)-th image patch and the first reference size, it can reflect the size difference between the i-th image patch and the first reference size in the initial image, making the size change of the i-th image patch more targeted. Because the change value is calculated for each image patch, and the target objects contained in two adjacent image patches are closer, the change value of the i-th image patch relative to the first reference size can be estimated more accurately.
[0091] Among them, the i-th image block and the (i-1)-th image block are the closest image blocks containing the target object; in the initial image, the image region between the i-th image block and the (i-1)-th image block may contain at least part of the structure of the target object, or may contain other objects besides the target object.
[0092] In some embodiments, adjusting the difference between the size of the (i-1)th image block and the first reference size based on the relative size difference to obtain the i-th change value includes: weighting the relative size difference and the difference between the size of the (i-1)th image block and the first reference size to obtain the i-th change value.
[0093] In some embodiments, adjusting the difference between the size of the (i-1)th image block and the first reference size based on the relative size difference to obtain the i-th change value includes: weighting the relative size difference and the difference between the size of the (i-1)th image block and the first reference size to obtain the i-th change value. The weighting can be a multiplication process; and the adjustment process can be performed separately in the horizontal and vertical directions.
[0094] Step 304: Increase the first reference dimension according to the i-th change value to obtain the i-th adjusted reference dimension.
[0095] The i-th adjusted reference dimension is the sum of the i-th change value and the first reference dimension. It is used to represent the size change of the target object at different positions without considering the actual size of the target object. The i-th change value includes the change value in the vertical direction and the change value in the horizontal direction. The i-th adjusted reference dimension can be obtained by increasing the first reference dimension by the change value in the vertical direction and the change value in the horizontal direction.
[0096] Step 306: Based on the size difference between the model input size and the target minimum size, enlarge the i-th adjusted reference size to obtain the size of the i-th image block.
[0097] The size difference between the model input size and the target minimum size is used to represent the relative scale between the model input size and the target minimum size of the target object. This allows the i-th adjusted reference size to be relatively balanced with the target object, so that the i-th image patch can more accurately reflect the information of the target object.
[0098] In this embodiment, the difference between the size of the (i-1)th image patch and the first reference size is adjusted according to the relative size difference to obtain the i-th change value. This is used to adaptively estimate the image patch change value for target objects at different positions in the initial image. Then, based on the i-th change value, the first reference size is increased to obtain the i-th adjusted reference size for more accurate analysis. Based on the size difference between the model input size and the minimum target size, the i-th adjusted reference size is enlarged to obtain the i-th image patch size. Here, i is a positive integer greater than 1.
[0099] In some embodiments, the size of the i-th block further includes the size of the i-th overlapping region; the method further includes: selecting a portion of the size of the i-th adjusted reference size according to the overlap ratio to obtain the size of the i-th overlapping region; wherein the size of the i-th overlapping region is the size of the overlapping region between the i-th image block and the next image block of the i-th image block.
[0100] The next image block after the i-th image block is the image block adjacent to the i-th image block; when different parts of a target object are distributed between the i-th image block and the (i+1)-th image block, the (i+1)-th image block is the next image block after the i-th image block. The size of the i-th overlapping region is smaller than the i-th adjusted reference size.
[0101] In one embodiment, selecting a portion of the i-th adjusted reference size based on the overlap ratio to obtain the size of the i-th overlapping region includes: using the product of the overlap ratio and the i-th adjusted reference size as the reference overlapping region size; wherein the overlap ratio is a positive number less than 1.
[0102] In this embodiment, the adjusted reference size is the image within the range of the initial image, while the overlapping area is the area shared by different image blocks. Therefore, the size of the i-th overlapping area is determined by the overlap ratio and the i-th adjusted reference size, so that when different parts of the target object are distributed in two image blocks at the same time, they can be stitched into a complete target object, thereby ensuring accurate identification of the complete target object.
[0103] In some embodiments, the (i-1)th image block and the i-th image block are divided based on their respective first and second corner points, where the first and second corner points are diagonal positions of the same image block, and i is a positive integer greater than 1. Dividing the initial image according to multiple block sizes to obtain image blocks of multiple block sizes includes: moving the second corner point of the (i-1)th image block towards a reference direction according to the size of the i-th overlapping region to obtain the first corner point of the i-th image block; moving the first corner point corresponding to the i-th image block towards the reference direction according to the size of the i-th image block to obtain the second corner point corresponding to the i-th image block; if the second corner point corresponding to the i-th image block is located within the initial image, then dividing the initial image according to the first corner point and the second corner point corresponding to the i-th image block to obtain the i-th image block.
[0104] The reference direction indicates the order in which image blocks are determined within the initial image. The reference direction is the direction in which the current image block moves away from the previous image block. The first and second corner points are diagonally opposite corner points of each image block, and their positions can be determined to identify each image block. The first and second corner points can be coordinate points. In one example, the first corner point is located at the top-left corner of the image block, and the second corner point is located at the bottom-right corner of the image block.
[0105] In some embodiments, the second corner point of the (i-1)th image block is displaced according to the size of the i-th overlapping region to obtain the first corner point of the i-th image block. This includes: displacing the second corner point of the (i-1)th image block horizontally according to the size of the i-th overlapping region in the horizontal direction, and displacing the second corner point of the (i-1)th image block vertically according to the size of the i-th overlapping region in the vertical direction. Thus, by sequentially displacing the overlapping regions in the horizontal and vertical directions, the probability of information loss of the target object is reduced by utilizing the redundant information of the overlapping regions.
[0106] In some embodiments, displacing the first corner point corresponding to the i-th image block according to the size of the i-th image block to obtain the second corner point corresponding to the i-th image block includes: displacing the first corner point corresponding to the i-th image block horizontally according to the size of the i-th image block in the horizontal direction, and displacing the first corner point corresponding to the i-th image block vertically according to the size of the i-th image block in the vertical direction to obtain the second corner point corresponding to the i-th image block.
[0107] In some embodiments, when the coordinates of the first corner point and the second corner point corresponding to the i-th image block are both located within the initial image, the second corner point corresponding to the i-th image block is located within the initial image.
[0108] In some embodiments, the initial image is segmented according to the first corner point of the i-th image block and the second corner point corresponding to the i-th image block to obtain the i-th image block, including: determining and segmenting the image region where the i-th image block is located in the initial image according to the coordinates of the first corner point of the i-th image block and the second corner point corresponding to the i-th image block to obtain the i-th image block.
[0109] In this embodiment, each image block has its own first corner point and second corner point. Since the first and second corner points are located diagonally opposite each other within the same image block, the entire range of the image block can be represented by these two corner points, allowing for the representation of the image block's position with a smaller amount of data. Furthermore, the position of the image blocks is gradually adjusted according to the size of the overlapping region, ensuring that the (i-1)th image block overlaps with the ith image block. The formation process of the overlapping region is controlled by the two sets of corner points of each image block. Based on the displacement of the overlapping region, the image block is further divided according to its size, thus clearly defining independent image blocks.
[0110] In some embodiments, the method further includes: if the second corner point corresponding to the i-th image block is located outside the initial image, then determining a new second corner point corresponding to the i-th image block based on the boundary of the initial image; displacing the new second corner point corresponding to the i-th image block in a reference direction according to the size of the i-th image block to obtain a new first corner point corresponding to the i-th image block; and segmenting the initial image based on the new first corner point and the new second corner point corresponding to the i-th image block to obtain the i-th image block.
[0111] The boundary of the initial image is the side position of the initial image, used to prevent image patches from reaching areas outside the initial image. The new first corner point and the new second corner point are the updated corner points of the i-th image patch.
[0112] In some embodiments, determining a new second corner point corresponding to the i-th image block based on the boundary of the initial image includes: determining the coordinates of the new second corner point corresponding to the i-th image block based on the boundary coordinates of the initial image. Specifically, if the second corner point corresponding to the i-th image block in the horizontal direction is located outside the initial image, then a new second corner point corresponding to the i-th image block in the horizontal direction is determined; if the second corner point corresponding to the i-th image block in the vertical direction is located outside the initial image, then a new second corner point corresponding to the i-th image block in the vertical direction is determined.
[0113] In some embodiments, segmenting the initial image based on the new first corner point of the i-th image block and the new second corner point corresponding to the i-th image block to obtain the i-th image block includes: determining and segmenting the image region where the i-th image block is located in the initial image based on the coordinates of the new first corner point of the i-th image block and the new second corner point corresponding to the i-th image block to obtain the i-th image block.
[0114] In this embodiment, if the second corner point corresponding to the i-th image block is located outside the initial image, the second corner point is first determined using the boundary of the initial image. Then, the new second corner point is displaced along the reference direction to determine the corresponding i-th image block. Therefore, not only will the image blocks not exceed the boundary of the initial image, but the overlapping areas between image blocks can also be adaptively adjusted to better reflect the information of the image blocks.
[0115] In some embodiments, the method further includes: detecting target objects in each image block using a target object recognition model to obtain the region where the target object is located in each image block; combining the coordinates of the region where the target object is located in each image block in the initial image to obtain a restored image; and performing deduplication processing on the target objects in the restored image to obtain the region of interest for each target object.
[0116] A recognition model is a neural network model used to detect target objects. A recognition model can be a YOLO model.
[0117] In some embodiments, image blocks and an initial image are batch-fed into a convolutional neural network for inference to obtain target bounding boxes after the target objects are segmented. These target bounding boxes represent the regions where the target objects are located. Based on the coordinates of each image block in the initial image, each bounding box is restored to the original image to obtain the restored image. Then, non-maximum suppression is used to remove duplicates, resulting in the final target bounding boxes, which represent the regions of interest for each target object.
[0118] In some embodiments, deduplication by NMS (non-maximum suppression) includes: if the intersection-union ratio of the target object region in the i-th image block with any target object region in the preceding i-th image blocks exceeds a threshold, then the target object region in the i-th image block is marked as duplicate; otherwise, the target object region in the i-th image block is retained.
[0119] In this embodiment, the target object is first detected based on image blocks, and the target object in each image block is identified, thereby forming the target object region of each image block; then, the target object regions of each image block are combined according to the coordinates under the initial image, so that the image blocks can be combined and the target objects distributed in different image blocks can be combined completely; finally, since there are duplicate regions in the image blocks, deduplication processing is performed to ensure the accuracy of target object detection.
[0120] In one embodiment, adaptive image segmentation technology has emerged to overcome the shortcomings of fixed segmentation. This type of technology can dynamically determine the size and shape of segments based on local image features, such as texture complexity, edge density, and grayscale variations. Edge detection-based adaptive segmentation methods first extract edge information from the image using edge detection algorithms, and then segment the image into sub-blocks of different shapes and sizes according to the edge distribution, making the edge distribution within each sub-block relatively uniform, thus better preserving image details. However, this method has high computational complexity and is highly dependent on the accuracy of edge detection; errors in edge detection can lead to unsatisfactory segmentation results. With the development of artificial intelligence technology, the powerful feature extraction capabilities of convolutional neural networks are utilized to train models to learn the feature distribution of images, thereby achieving more intelligent image segmentation. Some image segmentation models based on fully convolutional neural networks can directly perform end-to-end segmentation prediction on the input image, achieving good segmentation results in complex scenes. However, they have high resource requirements.
[0121] To address this issue, step 202 specifically includes performing depth calibration on the camera. The camera's checkerboard pattern is printed out, and calibration is performed for near and far objects. Based on the calibration, the actual size of the calibrated object at the closest and farthest distances is calculated, resulting in a first reference size smaller than a second reference size. Step 204 specifically includes calculating the length and width of the target object in the current scene that needs to be segmented, as well as the length and width of overlapping regions at different distances. Step 206 specifically includes segmenting the initial image according to multiple segmentation sizes, obtaining image blocks of multiple segmentation sizes. Finally, the segmented images and the initial image are batch-fed into a convolutional neural network for inference to obtain the target bounding boxes after segmentation. The target bounding boxes are then restored to the initial image based on the coordinates in the initial image, resulting in the restored image. Finally, non-maximum suppression is applied to the target objects in the restored image to remove duplicates, obtaining the final target bounding boxes.
[0122] In this embodiment, different segmentation methods can be selected based on the size level of different target objects in different application scenarios. This adaptively solves the problem of poor performance when using the same segmentation method for targets with large size differences at long and short distances in the same scene, and also solves the problem of difficulty in detecting small targets.
[0123] In one example, step 202 includes: performing depth calibration on the camera. The camera's chessboard pattern is printed out, and after calibration at both near and far distances, the actual width and height of the chessboard can be obtained. , In the calibration image, the second reference dimension includes the nearest height and width, respectively. , The first reference dimension includes the furthest height and width, which are respectively , .
[0124] Step 204 specifically includes: calculating the actual target size at the closest and furthest distances based on calibration, and the known height and width of the target. , The corresponding expression is:
[0125] / (
[0126] / (
[0127] / (
[0128] / (
[0129] in, The vertical dimension of the nearest target object. The vertical dimension of the nearest target object; The vertical dimension of the furthest target object. The horizontal dimension of the furthest target object.
[0130] Step 204 specifically includes: calculating the length and width of the target blocks to be divided in the current scene, as well as the length and width of overlapping regions at different distances, setting the minimum size of the target to be detected to be m*m, and the input size of the convolutional neural network model to be n*n; the initial image size is... , ;
[0131] At this point, the reference image block is the image block in the first row and first column. The determination of the size of the reference image block and the size of the reference overlapping area specifically includes:
[0132] a. If the height of the farthest target object is less than the minimum target size. If the input image size *m* is used for the convolutional neural network, it still won't meet the minimum target size requirement. Therefore, the height of the first row of image blocks will be based on the input image size *n* of the convolutional neural network. The overlapping region is α*. If the width of the furthest target object is less than the minimum target size. If the input image size *m* is used for the convolutional neural network, it still cannot meet the minimum target size requirement. Therefore, the width of the first row of image blocks is based on the input image size *n* of the convolutional neural network. The overlapping region is α*. , α* .
[0133] Here, α is a settable overlap ratio. A value less than 1 represents the size of the overlap region, meaning that if the target stands on an image patch, it will be divided into two equal parts by the image patches on either side. The overlap region will maintain the integrity of the target. If α = 1, the target will be precisely divided into complete parts by the image patches on either side. This ensures that the overlap region is a localized, relatively small, and complete segment. However, a value greater than 1 will result in an excessively large overlap region, increasing the number of image patches and consuming more resources.
[0134] b. If The height of the first row of image blocks is ;if Then the width of the first row of image blocks is: The overlapping regions are α* , α* .
[0135] Furthermore, the image block heights obtained from image blocks other than the reference image block are... With width and overlapping areas With width Calculated using the following formula. Based on the relative size differences, the reference segment size is enlarged into multiple segment sizes, including:
[0136]
[0137]
[0138]
[0139]
[0140]
[0141]
[0142] in, and These are the relative dimensional differences in the vertical and horizontal directions, respectively. and These are the differences between the size of the (i-1)th image block in the vertical direction and the size of the first reference size in the horizontal direction, respectively. and These are the i-th changes in the vertical and horizontal directions, respectively; This is the i-th adjusted reference size; It is the size difference between the model input size and the target minimum size.
[0143] Finally, this step also includes displacing the second corner point of the (i-1)th image block in the reference direction according to the size of the i-th overlapping region to obtain the first corner point of the i-th image block; displacing the first corner point of the i-th image block in the reference direction according to the size of the i-th image block to obtain the second corner point of the i-th image block; if the second corner point of the i-th image block is located within the initial image, then the initial image is segmented according to the first corner point of the i-th image block and the second corner point of the i-th image block to obtain the i-th image block.
[0144] Furthermore, this embodiment also includes a tail processing step, which is used to obtain a new second corner point corresponding to the i-th image block and a new first corner point corresponding to the i-th image block. If the last segmented region is smaller than the height or width of the image block, the offset is increased forward to satisfy the length and width of the image block. Then, the image block is segmented according to the length, width, and overlap ratio of the image block.
[0145] In one embodiment, the first corner point is the top-left point, and the second corner point is the bottom-right point. First, based on the bottom-right point of the previous image patch, the top-left point of the current image patch is calculated. Then, based on the top-left point of the current image patch, the bottom-right point of the current image patch is calculated, thus forming the current image patch. If a leftward movement is required, it may exceed the boundary of the initial image at the top-left corner. If it does, the new bottom-right point of the next image patch, i.e., the new second corner point, is determined based on the boundary of the initial image at the top-left corner. If it does not exceed the boundary, the displacement continues. For example, with the top-right corner of the original image as the origin (0, 0), the top-left point of each image patch region is calculated (…). , ) and the bottom right point ( , Taking a point as an example, the process of calculating and updating the offset between the first corner point and the second corner point can be represented by the following expression:
[0146]
[0147]
[0148]
[0149]
[0150] Based on the coordinates above and the original image, the image can be divided into multiple image blocks. There can be i image blocks or more than i image blocks.
[0151] In this expression, The situation, and In the case of obtaining the first corner point, the following steps are performed: and Let x and y coordinates be the second corner points of the (i-1)th image block; and where are the x and y coordinates of the first corner point of the i-th image patch; where the x and y coordinates can be calculated separately. In this expression, The situation, and In this case, the steps to obtain the new second corner point are performed. In this expression, in ,as well as In the case of [condition], stop updating the corner points of the i-th image block.
[0152] Finally, the image patches and the original image are fed into a convolutional neural network for inference to obtain the target bounding boxes after the target image patches. The bounding boxes after the target image patches are then restored to the initial image using coordinates to obtain the restored image. Non-maximum suppression is then used to remove duplicates, resulting in the final target bounding boxes.
[0153] For example, the width and height of the actual chessboard are obtained in advance as 1 meter and 0.75 meters respectively; the height and width of the nearest point in the calibration image are 320 and 450 respectively, and the height and width of the farthest point are 58 and 52 respectively. Let the minimum size of the target to be detected be 32*32, the input image size of the deep learning model is 416*416, the size of the initial image is 3840 and 2160, and the overlap ratio α=0.5; it is known that the height and width of the vehicle as the target object are 1.5 meters and 4.5 meters respectively. According to the formula, 4 image blocks are required, but 3 of them have the same value, so only 2 blocks are obtained in the end. The coordinates d of the obtained rectangular boxes are (1) (0, 0), (3042, 1508); (2) (0, 0) (3840, 2160); (3) (0, 0) (3840, 2160); (4) (0, 0) (3840, 2160). Then, the regions of interest (0, 0) and (3042, 1508) of the two sizes are detected respectively to obtain the regions of interest of the corresponding vehicles.
[0154] It should be understood that although the steps in the flowcharts of the embodiments described above are shown sequentially according to the arrows, these steps are not necessarily executed in the order indicated by the arrows. Unless explicitly stated herein, there is no strict order restriction on the execution of these steps, and they can be executed in other orders. Moreover, at least some steps in the flowcharts of the embodiments described above may include multiple steps or multiple stages. These steps or stages are not necessarily completed at the same time, but can be executed at different times. The execution order of these steps or stages is not necessarily sequential, but can be performed alternately or in turn with other steps or at least some of the steps or stages of other steps.
[0155] Based on the same inventive concept, this application also provides an image segmentation apparatus for implementing the image segmentation method described above. The solution provided by this apparatus is similar to the implementation scheme described in the above method; therefore, the specific limitations in one or more image segmentation apparatus embodiments provided below can be found in the limitations of the image segmentation method described above, and will not be repeated here.
[0156] In one exemplary embodiment, such as Figure 4 As shown, an image segmentation apparatus is provided, comprising:
[0157] The size acquisition module 402 is used to acquire a first reference size and a second reference size when the calibration object and the camera are at different distances; the first reference size is smaller than the second reference size, the calibration image captured by the camera contains the calibration object at different positions, and the initial image captured by the camera contains the target object;
[0158] The segmentation module 404 determines a reference block size based on the target object, and performs a difference calculation based on the size difference between the first reference size and the second reference size, and the size difference between the size of the initial image and the first reference size, to obtain a relative size difference; based on the relative size difference, the reference block size is enlarged into multiple block sizes;
[0159] The adjustment module 406 is used to divide the initial image according to the multiple block sizes to obtain image blocks of the multiple block sizes.
[0160] In one embodiment, the reference block size includes the reference image block size and the reference overlapping region size; the segmentation module 404 is used for:
[0161] In the initial image, obtain the size of the furthest target object;
[0162] The size of the farthest target object is reduced according to the overlap ratio to obtain the reference overlap region size; wherein, the reference overlap region size is the overlap region size between the reference image block and the next image block of the reference image block;
[0163] If the size of the farthest target object is smaller than the minimum target size, then the size of the reference image patch is determined based on the model input size; the minimum target size is the minimum size used for object recognition.
[0164] If the size of the farthest target object is greater than the minimum target size, then the size of the farthest target object is adjusted based on the size difference between the model input size and the minimum target size to obtain the reference image block size.
[0165] In one embodiment, the block size includes the image block size; the segmentation module 404 is configured to:
[0166] Based on the relative size difference, the difference between the size of the (i-1)th image block and the first reference size is adjusted to obtain the i-th change value; where i is a positive integer greater than 1, and the size of the (i-1)th image block includes the size of the first image block, which is the size of the reference image block;
[0167] Based on the i-th change value, the first reference size is increased to obtain the i-th adjusted reference size;
[0168] Based on the size difference between the model input size and the target minimum size, the i-th adjusted reference size is enlarged to obtain the size of the i-th image block.
[0169] In one embodiment, the size of the i-th block further includes the size of the i-th overlapping region; the segmentation module 404 is used for:
[0170] Based on the overlap ratio, a portion of the adjusted reference size of the i-th region is selected to obtain the size of the i-th overlapping region;
[0171] Wherein, the size of the i-th overlapping region is the size of the overlapping region between the i-th image block and the next image block of the i-th image block.
[0172] In one embodiment, the (i-1)th image block and the i-th image block are divided based on their respective first and second corner points, where the first and second corner points are diagonal positions of the same image block, and i is a positive integer greater than 1; the segmentation module 404 is based on:
[0173] Displace the second corner point of the (i-1)th image block in the reference direction according to the size of the i-th overlapping region to obtain the first corner point of the i-th image block;
[0174] Displace the first corner point corresponding to the i-th image block in the reference direction according to the size of the i-th image block to obtain the second corner point corresponding to the i-th image block;
[0175] If the second corner point corresponding to the i-th image block is located within the initial image, then the initial image is segmented according to the first corner point of the i-th image block and the second corner point corresponding to the i-th image block to obtain the i-th image block.
[0176] In one embodiment, the segmentation module 404 is based on:
[0177] If the second corner point corresponding to the i-th image block is located outside the initial image, then a new second corner point corresponding to the i-th image block is determined based on the boundary of the initial image;
[0178] Displace the new second corner point corresponding to the i-th image block in the reference direction according to the size of the i-th image block to obtain the new first corner point corresponding to the i-th image block;
[0179] The initial image is segmented based on the new first corner point and the new second corner point corresponding to the i-th image block to obtain the i-th image block.
[0180] In one embodiment, the adjustment module 406 is configured to:
[0181] By using the target object recognition model, the target object is detected in each of the image blocks to obtain the region where the target object is located in each of the image blocks;
[0182] The image is obtained by combining the coordinates of the target object regions of each image block in the initial image;
[0183] The target objects in the restored image are deduplicated to obtain the regions of interest for each target object.
[0184] Each module in the aforementioned image segmentation device can be implemented entirely or partially through software, hardware, or a combination thereof. These modules can be embedded in or independent of the processor in a computer device, or stored in the memory of a computer device as software, so that the processor can call and execute the operations corresponding to each module.
[0185] In one exemplary embodiment, a computer device is provided, which may be a terminal, and its internal structure diagram may be as follows: Figure 5 As shown, the computer device includes a processor, memory, input / output interfaces, a communication interface, a display unit, and an input device. The processor, memory, and input / output interfaces are connected via a system bus, and the communication interface, display unit, and input device are also connected to the system bus via the input / output interfaces. The processor provides computational and control capabilities. The memory includes non-volatile storage media and internal memory. The non-volatile storage media stores the operating system and computer programs. The internal memory provides an environment for the operation of the operating system and computer programs stored in the non-volatile storage media. The input / output interfaces are used for exchanging information between the processor and external devices. The communication interface is used for wired or wireless communication with external terminals; wireless communication can be achieved through Wi-Fi, mobile cellular networks, Near Field Communication (NFC), or other technologies. When executed by the processor, the computer program implements an image segmentation method. The display unit is used to form a visually visible image and can be a display screen, a projection device, or a virtual reality imaging device. The display screen can be an LCD screen or an e-ink screen. The input device of the computer device can be a touch layer covering the display screen, or buttons, trackballs, or touchpads set on the casing of the computer device, or external keyboards, touchpads, or mice, etc.
[0186] Those skilled in the art will understand that Figure 5The structure shown is merely a block diagram of a portion of the structure related to the present application and does not constitute a limitation on the computer device to which the present application is applied. Specific computer devices may include more or fewer components than those shown in the figure, or combine certain components, or have different component arrangements.
[0187] In one embodiment, a computer device is also provided, including a memory and a processor, wherein the memory stores a computer program, and the processor executes the computer program to implement the steps in the above method embodiments.
[0188] In one embodiment, a computer-readable storage medium is provided having a computer program stored thereon that, when executed by a processor, implements the steps in the above method embodiments.
[0189] In one embodiment, a computer program product is provided, including a computer program that, when executed by a processor, implements the steps in the above method embodiments.
[0190] It should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, data stored, data displayed, etc.) involved in this application are all information and data authorized by the user or fully authorized by all parties, and the collection, use and processing of the relevant data must comply with relevant regulations.
[0191] Those skilled in the art will understand that all or part of the processes in the methods of the above embodiments can be implemented by a computer program instructing related hardware. The computer program can be stored in a non-volatile computer-readable storage medium, and when executed, it can include the processes of the embodiments of the above methods. Any references to memory, databases, or other media used in the embodiments provided in this application can include at least one of non-volatile memory and volatile memory. Non-volatile memory can include read-only memory (ROM), magnetic tape, floppy disk, flash memory, optical memory, high-density embedded non-volatile memory, resistive random access memory (ReRAM), magnetic random access memory (MRAM), ferroelectric random access memory (FRAM), phase change memory (PCM), graphene memory, etc. Volatile memory can include random access memory (RAM) or external cache memory, etc. By way of illustration and not limitation, RAM can take many forms, such as Static Random Access Memory (SRAM) or Dynamic Random Access Memory (DRAM). The databases involved in the embodiments provided in this application may include at least one type of relational database and non-relational database. Non-relational databases may include, but are not limited to, blockchain-based distributed databases. The processors involved in the embodiments provided in this application may be general-purpose processors, central processing units, graphics processing units, digital signal processors, programmable logic devices, quantum computing-based data processing logic devices, artificial intelligence (AI) processors, etc., and are not limited to these.
[0192] The technical features of the above embodiments can be combined in any way. For the sake of brevity, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this application.
[0193] The embodiments described above are merely illustrative of several implementation methods of this application, and while the descriptions are specific and detailed, they should not be construed as limiting the scope of this patent application. It should be noted that those skilled in the art can make various modifications and improvements without departing from the concept of this application, and these all fall within the protection scope of this application. Therefore, the protection scope of this application should be determined by the appended claims.
Claims
1. An image segmentation method, characterized in that, The method includes: Obtain a first reference size and a second reference size when the calibration object and the camera are at different distances; the first reference size is smaller than the second reference size, the calibration image captured by the camera contains the calibration object at different positions, and the initial image captured by the camera contains the target object; the first reference size and the second reference size are different reference block sizes, and the reference block size is the block size to be enlarged, used to adjust the block size according to the size and position of the target object; A reference block size is determined based on the target object, and a relative size difference is calculated based on the size difference between the first reference size and the second reference size, and the size difference between the size of the initial image and the first reference size. Based on the relative size difference, the reference block size is enlarged into multiple block sizes. The relative size difference is the relative difference between the two size differences, representing the relative magnitude of size change when the target object and the camera are at different distances. The relative size difference is used to enlarge the reference block size multiple times, resulting in at least one enlarged block size each time, and each enlarged block size belongs to the multiple block sizes. The initial image is divided according to the multiple block sizes to obtain image blocks of the multiple block sizes.
2. The method according to claim 1, characterized in that, The reference block size includes the reference image block size and the reference overlapping region size; determining the reference block size based on the target object includes: In the initial image, obtain the size of the furthest target object; The size of the farthest target object is reduced according to the overlap ratio to obtain the reference overlap region size; wherein, the reference overlap region size is the overlap region size between the reference image block and the next image block of the reference image block; If the size of the farthest target object is smaller than the minimum target size, then the size of the reference image patch is determined based on the model input size; the minimum target size is the minimum size used for object recognition. If the size of the farthest target object is greater than the minimum target size, then the size of the farthest target object is adjusted based on the size difference between the model input size and the minimum target size to obtain the reference image block size.
3. The method according to claim 1, characterized in that, The block size includes the image block size; The step of enlarging the reference block size into multiple block sizes based on the relative size difference includes: Based on the relative size difference, the difference between the size of the (i-1)th image block and the first reference size is adjusted to obtain the i-th change value; where i is a positive integer greater than 1, and the size of the (i-1)th image block includes the size of the first image block, which is the reference image block size; Based on the i-th change value, the first reference size is increased to obtain the i-th adjusted reference size; Based on the size difference between the model input size and the target minimum size, the i-th adjusted reference size is enlarged to obtain the size of the i-th image block.
4. The method according to claim 3, characterized in that, The size of the i-th block also includes the size of the i-th overlapping region; the method further includes: Based on the overlap ratio, a portion of the adjusted reference size of the i-th region is selected to obtain the size of the i-th overlapping region; Wherein, the size of the i-th overlapping region is the size of the overlapping region between the i-th image block and the next image block of the i-th image block.
5. The method according to claim 4, characterized in that, The (i-1)th image block and the ith image block are divided based on their respective first corner point and second corner point, where the first corner point and the second corner point are diagonal positions of the same image block, and i is a positive integer greater than 1; The step of dividing the initial image according to the multiple block sizes to obtain image blocks of the multiple block sizes includes: Displace the second corner point of the (i-1)th image block in the reference direction according to the size of the i-th overlapping region to obtain the first corner point of the i-th image block; Displace the first corner point corresponding to the i-th image block in the reference direction according to the size of the i-th image block to obtain the second corner point corresponding to the i-th image block; If the second corner point corresponding to the i-th image block is located within the initial image, then the initial image is segmented according to the first corner point of the i-th image block and the second corner point corresponding to the i-th image block to obtain the i-th image block.
6. The method according to claim 5, characterized in that, The method further includes: If the second corner point corresponding to the i-th image block is located outside the initial image, then a new second corner point corresponding to the i-th image block is determined based on the boundary of the initial image; Displace the new second corner point corresponding to the i-th image block in the reference direction according to the size of the i-th image block to obtain the new first corner point corresponding to the i-th image block; The initial image is segmented based on the new first corner point and the new second corner point corresponding to the i-th image block to obtain the i-th image block.
7. The method according to claim 1, characterized in that, The method further includes: By using the target object recognition model, the target object is detected in each of the image blocks to obtain the region where the target object is located in each of the image blocks; The image is obtained by combining the coordinates of the target object regions of each image block in the initial image; The target objects in the restored image are deduplicated to obtain the regions of interest for each target object.
8. An image segmentation apparatus, characterized in that, The device includes: The size acquisition module is used to acquire a first reference size and a second reference size when the calibration object and the camera are at different distances; the first reference size is smaller than the second reference size, the calibration image captured by the camera contains the calibration object at different positions, and the initial image captured by the camera contains the target object; the first reference size and the second reference size are different reference block sizes, and the reference block size is the block size to be enlarged, used to adjust the block size according to the size and position of the target object; The segmentation module determines a reference block size based on the target object, and performs a difference calculation based on the size difference between the first reference size and the second reference size, and the size difference between the size of the initial image and the first reference size, to obtain a relative size difference; based on the relative size difference, the reference block size is enlarged into multiple block sizes; the relative size difference is the relative difference between the two size differences, representing the relative magnitude of size change when the target object is at different distances from the camera; the relative size difference is used to enlarge the reference block size multiple times to obtain at least one block size each time, and each enlarged at least one block size belongs to the multiple block sizes; An adjustment module is used to divide the initial image according to the multiple block sizes to obtain image blocks of the multiple block sizes.
9. A computer device comprising a memory and a processor, wherein the memory stores a computer program, characterized in that, When the processor executes the computer program, it implements the steps of the method according to any one of claims 1 to 7.
10. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by a processor, it implements the steps of the method according to any one of claims 1 to 7.
Citation Information
Patent Citations
Image processing method, computer equipment and readable storage medium
CN110390679A
Sample image generation method and device, electronic equipment and storage medium
CN113642612A