A high-speed image cutting method and device

Through image preprocessing technology, including downsampling, denoising and morphological processing, the problem of difficult to balance image segmentation speed and accuracy in high-speed imaging environments is solved, and the rapid processing and high accuracy of large-scale data flows are achieved. for complex and dynamic image segmentation tasks.

CN118735952BActive Publication Date: 2025-01-07Aerospace Cyber ​​Industry Technology Research Institute +2
View PDF 3 Cites 0 Cited by

Patent Information

Application Number
CN202411232592.X
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-09-04
Publication Date
2025-01-07
Estimated Expiration
2044-09-04

AI Technical Summary

Technical Problem

Existing image segmentation technologies are difficult to balance speed and accuracy in high-speed imaging environments, especially when dealing with transparent or translucent objects and dynamic environments, and traditional algorithms are difficult to adapt to complex or dynamic changing backgrounds.

Method used

Using image preprocessing technology, including downsampling, denoising and contrast enhancement, the edge profile of the target object is determined and the minimum external rectangle is calculated to achieve high-speed images through pixel gradient calculation, non-maximum suppression, dual-threshold detection and morphological processing. Cut.

Benefits of technology

While maintaining high segmentation accuracy, it improves the speed and efficiency of image processing, and can quickly process large-scale data flows, suitable for complex and dynamic high-speed imaging systems.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118735952B_ABST
    Figure CN118735952B_ABST
Patent Text Reader

Abstract

The present invention relates to a high-speed image cutting method and device, and belongs to the field of image processing technology. The method first performs image preprocessing on the original image, then calculates the pixel gradient in the preprocessed image and performs non-maximum suppression processing on the pixel gradient, performs double threshold detection on the processed pixel gradient, determines the edge position of the target in the image, and obtains the edge detection result of the target; performs morphological enhancement processing on the edge of the target in the edge detection result to obtain a morphologically enhanced image, and at the same time performs edge contour traversal on the enhanced image to determine the minimum bounding rectangle of the target in the image, and performs non-maximum suppression processing on the bounding rectangle to obtain the detection frame of the target; maps the pixel coordinate position of the detection frame of the target to the original image for image cropping to obtain the target image. The present invention can realize rapid processing of large-scale data streams while maintaining high segmentation accuracy, effectively improving the accuracy and efficiency of image processing.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of image processing, and in particular to a high-speed image cutting method and device. Background Art

[0002] In high-speed imaging systems, quickly and accurately segmenting target areas from continuous image streams is critical to improving overall analysis efficiency and accuracy. These systems are widely used in a variety of fields, including industrial inspection, biomedical imaging, security monitoring, and traffic management. In these applications, the speed and quality of image segmentation directly affect the effectiveness of subsequent processing steps, such as target tracking, behavior analysis, or automated inspection.

[0003] Although existing image segmentation techniques perform well in many common scenarios, they are often limited by many factors in high-speed imaging environments, especially in the following aspects:

[0004] (1) It is difficult to balance speed and accuracy: Many high-precision segmentation techniques, such as deep learning-based methods, have excellent accuracy, but they are computationally intensive and are not suitable for real-time processing of large-scale data. Traditional fast segmentation algorithms, such as threshold processing and region growing, often cannot adapt to complex or dynamically changing backgrounds;

[0005] (2) Difficulty in processing transparent or semi-transparent objects: In many practical application scenarios, such as biological tissue imaging or certain industrial material detection, the target object may appear transparent or semi-transparent, which makes it difficult for traditional threshold and color-based segmentation methods to distinguish the target from the background;

[0006] Dynamic environment adaptability: High-speed imaging systems often face challenges with rapidly changing ambient lighting, background, and targets. These factors may make it impossible for traditional algorithms to stably identify and track targets. Summary of the invention

[0007] In order to solve the above-mentioned problems in the prior art, the present invention provides a high-speed image cutting method and device, which can realize rapid processing of large-scale data streams while maintaining high segmentation accuracy, thereby effectively improving the accuracy and efficiency of image processing.

[0008] In a first aspect, the present invention provides a high-speed image cutting method, comprising:

[0009] Performing image preprocessing on the original image to obtain a preprocessed image;

[0010] Calculate the pixel gradient in the preprocessed image and perform non-maximum suppression on the pixel gradient, perform double threshold detection on the pixel gradient after non-maximum suppression, determine the edge position of the target in the image, and obtain the edge detection result of the target;

[0011] Performing morphological enhancement processing on the edge of the target object in the edge detection result of the target object to obtain a morphologically enhanced image;

[0012] Traverse the edge contour of the morphologically enhanced image to determine the minimum bounding rectangle of the target in the image, and perform non-maximum suppression processing on the minimum bounding rectangle to obtain the detection frame of the target;

[0013] The pixel coordinate position corresponding to the detection frame of the target object is mapped to the original image, and the image is cropped according to the mapping position of the detection frame in the original image to obtain the target image.

[0014] Furthermore, the performing image preprocessing on the original image to obtain the preprocessed image includes:

[0015] Downsample the original image and convert the original image of size M×N into a The downsampled image, where s is the downsampling factor, and is the image size after downsampling;

[0016] The downsampled image is convolved with a Gaussian filter to eliminate random noise in the downsampled image, as shown in the following formula:

[0017] ,

[0018] in, is the Gaussian kernel function: , σ represents the standard deviation, exp represents the exponential function, I represents the downsampled image, represents the denoised image, k represents the Gaussian kernel size, and (x, y) represents the image coordinates;

[0019] The histogram equalization method is used to enhance the image features and obtain the preprocessed image .

[0020] Furthermore, the step of calculating pixel gradients in the preprocessed image and performing non-maximum suppression processing on the pixel gradients includes:

[0021] Compute preprocessed image Find the first-order partial derivative matrix in the x- and y-directions:

[0022] ,

[0023] in, represents the first-order partial derivative matrix in the x direction, Represents the first-order partial derivative matrix in the y direction;

[0024] Compute preprocessed image The gradient direction and magnitude of each pixel in :

[0025] ,

[0026] ,

[0027] Among them, M(x,y) is the gradient amplitude of the pixel, indicating the gradient strength of the pixel, and θ(x,y) is the gradient direction of the pixel;

[0028] Preprocess the image The gradient magnitude of the current pixel is compared with the gradient magnitude of the two pixels along the positive and negative gradient directions. If the gradient magnitude of the current pixel is greater than the gradient magnitude of the two pixels along the positive and negative gradient directions, the current pixel point is retained as an edge point, otherwise the current pixel point will be suppressed.

[0029] Furthermore, the double threshold detection is performed on the pixel gradient after the non-maximum suppression process to determine the edge position of the target object in the image and obtain the edge detection result of the target object, including:

[0030] Compare the gradient magnitude of the pixel at the edge point with a first threshold and a second threshold respectively, wherein the first threshold is less than the second threshold;

[0031] If the gradient magnitude of a pixel is less than a first threshold, the corresponding pixel is removed; if the gradient magnitude of a pixel is greater than the first threshold and less than a second threshold, the corresponding pixel is marked as a weak edge; if the gradient magnitude of a pixel is greater than the second threshold, the corresponding pixel is marked as a strong edge;

[0032] Find a strong edge within the preset range of the weak edge. If there is a strong edge within the preset range, keep the corresponding weak edge, otherwise delete the corresponding weak edge.

[0033] Based on preprocessed image The strong edges and weak edges in the output are the edge detection results of the target object.

[0034] Furthermore, the performing morphological enhancement processing on the edge of the target object in the edge detection result of the target object to obtain a morphologically enhanced image includes:

[0035] The edge of the target object in the edge detection result is corroded and expanded to enhance the continuity and integrity of the edge, and the gaps and breakpoints in the edge are filled to enhance the clarity and continuity of the edge contour to obtain a morphologically enhanced image.

[0036] Furthermore, the edge contour traversal of the morphologically enhanced image is performed to determine the minimum bounding rectangle of the target object in the image, and non-maximum suppression processing is performed on the minimum bounding rectangle to obtain a detection frame of the target object, including:

[0037] Traverse the edge contours of the target object in the morphological enhancement image to determine multiple minimum circumscribed rectangles;

[0038] The areas of multiple minimum bounding rectangles are calculated, and the minimum bounding rectangle with the largest area is retained from the multiple minimum bounding rectangles as the detection frame of the target object.

[0039] Furthermore, mapping the pixel coordinate position corresponding to the detection frame of the target object to the original image, and performing image cropping according to the mapping position of the detection frame in the original image to obtain the target image includes:

[0040] Multiply the pixel coordinates of the target object's detection frame by the downsampling factor to obtain the mapping coordinates.

[0041] The detection frame of the target object is mapped to the original image according to the mapping coordinate position, and the image is cropped according to the position of the detection frame mapped in the original image to obtain the target image.

[0042] Furthermore, the method further comprises: performing high-speed image cutting based on FPGA transmission of pre-processed images;

[0043] The high-speed image cutting based on FPGA transmission pre-processed image includes:

[0044] The buffer unit uses a demultiplexer to sequentially store the first row and the second row of input preprocessed image pixels into blocks 1 and 2 of a block random access memory, respectively; when the third row of image pixel data starts to fill block 3, the multiplexer is used to simultaneously transmit the pixel data in blocks 1, 2 and 3, and one column of pixels is transmitted to the edge detection unit per clock; when the pixel data in blocks 1, 2 and 3 are all transmitted, the demultiplexer is used to sequentially store the fourth row and the fifth row of preprocessed image pixels into blocks 1 and 2 of a block random access memory, respectively; when the sixth row of image pixel data starts to fill block 3, the multiplexer is used to simultaneously transmit the pixel data in blocks 1, 2 and 3; the storage and transmission process of the preprocessed image pixels is repeated until all pixels of the preprocessed image are transmitted to the edge detection unit;

[0045] The edge detection unit calculates the pixel gradients of the preprocessed image in the x direction and the y direction within the period with three clocks as a cycle, and screens out the gradient amplitudes of the pixel gradients that are less than the first threshold value through the first threshold value and the second threshold value;

[0046] After the preprocessed image is transmitted and all pixels have completed the gradient amplitude screening, the row buffer and column buffer are used to perform bit-by-bit AND operations on the image area and the structural element in the sliding window, and the minimum value of each pixel in the sliding window is obtained to obtain the eroded image, and the maximum value of each pixel in the sliding window is obtained to obtain the expanded image;

[0047] The convex points of the edge contour of the target object in the expanded image are calculated by the rotating caliper method, and the bounding rectangle of the target object is determined according to the coordinates of the convex points. The bounding rectangle of the target object is processed by non-maximum suppression to obtain a detection frame, which is mapped to the original image for image cropping to obtain the target image.

[0048] Furthermore, the edge detection unit calculates the pixel gradients of the preprocessed image in the x direction and the y direction within the period with three clocks as a period, including:

[0049] The edge detection unit uses the rank property of the 3×3 operator to optimize the gradient calculation. When the first clock arrives, the first column c1 of the x-direction operator is multiplied and added with the preprocessed image pixels to calculate the gradient in the x-direction. :

[0050] ,

[0051] in, represents the gradient amplitude in the x direction calculated when the first clock arrives, and S(1,1) represents the first element of the first column c1 of the x-direction operator;

[0052] When the second clock arrives, the second column c2 of the x-direction operator is multiplied and added with the preprocessed image pixels to calculate the gradient in the x-direction :

[0053] ,

[0054] When the third clock arrives, the third column c3 of the x-direction operator is multiplied and added with the preprocessed image pixels to calculate the gradient in the x-direction :

[0055] ,

[0056] With three clocks as one cycle, calculate the total gradient in the x direction within the cycle :

[0057] ,

[0058] Based on the gradient calculation method in the x direction within the cycle, the total gradient in the y direction within the cycle is calculated .

[0059] In a second aspect, the present invention provides a high-speed image cutting device, comprising:

[0060] An image preprocessing module is used to perform image preprocessing on the original image to obtain a preprocessed image;

[0061] The edge detection module is used to calculate the pixel gradient in the preprocessed image and perform non-maximum suppression processing on the pixel gradient, perform double threshold detection on the pixel gradient after non-maximum suppression processing, determine the edge position of the target object in the image, and obtain the edge detection result of the target object;

[0062] A morphological processing module is used to perform morphological enhancement processing on the edge of the target object in the edge detection result of the target object to obtain a morphologically enhanced image;

[0063] The detection frame calculation module is used to traverse the edge contour of the morphological enhancement image, determine the minimum bounding rectangle of the target object in the image, and perform non-maximum suppression processing on the minimum bounding rectangle to obtain the detection frame of the target object;

[0064] The image cropping module is used to map the pixel coordinate position corresponding to the detection frame of the target object to the original image, and to crop the image according to the mapping position of the detection frame in the original image to obtain the target image.

[0065] The beneficial effect of the present invention is that by pre-processing the original image such as downsampling, denoising, and contrast enhancement, the amount of data processing in the subsequent image processing steps is reduced, and the image processing speed is improved. At the same time, by pre-processing the image and performing gradient calculation, non-maximum suppression, dual threshold detection, and morphological processing in sequence, the edge contour of the target object in the image can be quickly and accurately located. Then, the detection frame of the target object is determined by calculating the minimum circumscribed rectangle of the edge contour, and finally the target image is cropped according to the mapping position of the detection frame in the original image to achieve high-speed image cutting. While maintaining high segmentation accuracy, it is possible to achieve rapid processing of large-scale data streams, effectively improving the accuracy and efficiency of image processing. In addition, the present invention also proposes an FPGA parallel processing design scheme for an image segmentation method. On the basis of the original image segmentation method, the multi-tasking capability of the FPGA itself is used to further improve the edge detection speed of the image. BRIEF DESCRIPTION OF THE DRAWINGS

[0066] Figure 1 A flow chart of the high-speed image cutting method provided by the present invention;

[0067] Figure 2 This is a flowchart of image preprocessing provided by the present invention;

[0068] Figure 3 The edge detection flow chart provided by the present invention;

[0069] Figure 4 This is an example diagram of high-speed image segmentation provided by the present invention;

[0070] Figure 5A flow chart of a method for high-speed image cutting based on FPGA transmission pre-processed images provided by the present invention;

[0071] Figure 6 This is a module schematic diagram of the high-speed image cutting device provided by the present invention. DETAILED DESCRIPTION

[0072] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.

[0073] Embodiment 1:

[0074] Reference Figure 1-Figure 4 , a high-speed image cutting method provided by an embodiment of the present invention includes but is not limited to the following steps:

[0075] Performing image preprocessing on the original image to obtain a preprocessed image;

[0076] Calculate the pixel gradient in the preprocessed image and perform non-maximum suppression on the pixel gradient, perform double threshold detection on the pixel gradient after non-maximum suppression, determine the edge position of the target in the image, and obtain the edge detection result of the target;

[0077] Performing morphological enhancement processing on the edge of the target object in the edge detection result of the target object to obtain a morphologically enhanced image;

[0078] Traverse the edge contour of the morphologically enhanced image to determine the minimum bounding rectangle of the target in the image, and perform non-maximum suppression processing on the minimum bounding rectangle to obtain the detection frame of the target;

[0079] The pixel coordinate position corresponding to the detection frame of the target object is mapped to the original image, and the image is cropped according to the mapping position of the detection frame in the original image to obtain the target image.

[0080] Further, in the embodiment of the present invention, referring to Figure 2 As shown, the original image is preprocessed to obtain a preprocessed image, which specifically includes the following processes:

[0081] Downsample the original image and convert the original image of size M×N into a The downsampled image, where s is the downsampling factor, and is the image size after downsampling.

[0082] The downsampled image is convolved with a Gaussian filter to eliminate random noise in the downsampled image, as shown in the following formula:

[0083] (1),

[0084] in, is the Gaussian kernel function: , σ represents the standard deviation, exp represents the exponential function, I represents the downsampled image, represents the denoised image, k represents the Gaussian kernel size, and (x, y) represents the image coordinates.

[0085] After the noise is removed, the histogram equalization method is used to enhance the image features to obtain the preprocessed image. .

[0086] Among them, histogram equalization is a commonly used image enhancement technology that improves the visual effect of an image by adjusting the contrast of the image. This method is achieved by effectively expanding the commonly used brightness, and is particularly suitable for images where the background and foreground are too bright or too dark, and can bring better detail display. For example, in X-ray image processing, histogram equalization of the image can better display the bone structure, and for overexposed or underexposed photos, it can provide better detail display.

[0087] The embodiment of the present invention can reduce the amount of data processing in subsequent steps and improve the processing speed by performing downsampling acceleration, Gaussian denoising and feature enhancement on the original image.

[0088] Further, see Figure 3 As shown in the edge detection flow chart, in the embodiment of the present invention, the pixel gradients in the preprocessed image are calculated and non-maximum suppression processing is performed on the pixel gradients, which specifically includes the following processes:

[0089] Compute preprocessed image Find the first-order partial derivative matrix in the x- and y-directions:

[0090] (2)

[0091] in, represents the first-order partial derivative matrix in the x direction, Represents the first-order partial derivative matrix in the y direction;

[0092] Compute preprocessed image The gradient direction and magnitude of each pixel in :

[0093] (3)

[0094] (4)

[0095] Among them, M(x,y) is the gradient amplitude of the pixel, indicating the gradient strength of the pixel, and θ(x,y) is the gradient direction of the pixel.

[0096] After the gradient calculation is completed, the preprocessed image The gradient magnitude of the current pixel is compared with the gradient magnitude of the two pixels along the positive and negative gradient directions. If the gradient magnitude of the current pixel is greater than the gradient magnitude of the two pixels along the positive and negative gradient directions, the current pixel point is retained as an edge point, otherwise the current pixel point will be suppressed.

[0097] Furthermore, after completing the non-maximum suppression process, the embodiment of the present invention further performs a double threshold detection on the pixel gradient after the non-maximum suppression process to determine the edge position of the target object in the image and obtain the edge detection result of the target object. The process specifically includes:

[0098] The gradient magnitude of the pixel at the edge point is compared with a first threshold and a second threshold respectively, wherein the first threshold is smaller than the second threshold.

[0099] If the gradient magnitude of a pixel is less than a first threshold, the corresponding pixel is removed; if the gradient magnitude of a pixel is greater than the first threshold and less than a second threshold, the corresponding pixel is marked as a weak edge; if the gradient magnitude of a pixel is greater than the second threshold, the corresponding pixel is marked as a strong edge;

[0100] A strong edge is found within the preset range of the weak edge. If a strong edge exists within the preset range, the corresponding weak edge is retained, otherwise the corresponding weak edge is deleted.

[0101] Finally, based on the preprocessed image The strong edges and weak edges in the output are the edge detection results of the target object.

[0102] Furthermore, in the embodiment of the present invention, the edge of the target object in the edge detection result of the target object is subjected to morphological enhancement processing to obtain a morphologically enhanced image, which specifically includes:

[0103] The edge of the target object in the edge detection result is corroded and expanded to enhance the continuity and integrity of the edge, and the gaps and breakpoints in the edge are filled to enhance the clarity and continuity of the edge contour to obtain a morphologically enhanced image.

[0104] In the morphological processing of images, the principle of the erosion operation is to initialize a kernel (similar to a sliding window) and traverse it on the target image. If the pixel values ​​in the window are all greater than or less than the window elements, no operation is performed; otherwise, the corresponding pixel values ​​in the window are replaced with the minimum value of the pixels in the window to reduce the white area (foreground) in the image. This process can remove small objects in the image and shrink the objects. It is often used to remove noise or separate touching objects. The standard paradigm of the erosion operation includes defining the structural element (kernel) of the erosion operation, such as using np.ones((3,3), np.uint8) to define a 3x3 kernel, and performing the erosion operation through cv2.erode(image, kernel,iterations=1). The intensity of the erosion operation can be controlled by adjusting the kernel size and the number of iterations.

[0105] The dilation operation is the inverse operation of the erosion operation. Its principle is to initialize a kernel and traverse the target image. If the pixel values ​​in the window are all greater than or less than the window elements, no operation is performed; otherwise, the corresponding pixel value in the window is replaced with the maximum value of the pixel in the window to increase the white area (foreground) in the image. The dilation operation can enlarge the objects in the image and is often used to fill small holes inside the objects.

[0106] The embodiment of the present invention can improve the clarity of the target object contour in the image by further performing morphological enhancement processing on the image, thereby providing a good image foundation for subsequent accurate segmentation of the image.

[0107] Furthermore, in an embodiment of the present invention, after the morphological enhancement process is completed, the coordinate position of the detection frame is further calculated in the enhanced image, the minimum bounding rectangle of the target object in the image is determined by traversing the edge contour of the morphologically enhanced image, and the minimum bounding rectangle is subjected to non-maximum suppression process to obtain the detection frame of the target object. The process specifically includes:

[0108] The edge contours of the target object in the morphological enhancement image are traversed to determine multiple minimum bounding rectangles.

[0109] The areas of multiple minimum bounding rectangles are calculated, and the minimum bounding rectangle with the largest area is retained from the multiple minimum bounding rectangles as the detection frame of the target object.

[0110] Specifically, since there may be overlap between target object instances in the image and the edge contours of the target objects may also overlap, the embodiment of the present invention applies non-maximum suppression to the circumscribed rectangle again, and uses the area of ​​the circumscribed rectangle as the judgment condition. The remaining rectangles are eliminated on the principle of retaining the circumscribed rectangle with the largest area, and the minimum circumscribed rectangle with the largest area is retained as the detection frame.

[0111] Specifically, refer to Figure 4 The high-speed image segmentation example shown in the figure shows that the present invention performs image segmentation on an image of cell particles, where part (a) is the original image, part (b) is the enhanced image, and part (c) is the segmented target image. Figure 4 It can be seen that the method provided by the embodiment of the present invention can distinguish transparent and semi-transparent objects from backgrounds while maintaining a good segmentation effect.

[0112] Furthermore, in an embodiment of the present invention, the pixel coordinate position corresponding to the detection frame of the target object is mapped to the original image, and the image is cropped according to the mapping position of the detection frame in the original image to obtain the target image, which specifically includes:

[0113] The coordinate value of the pixel coordinate position corresponding to the detection frame of the target object is multiplied by the downsampling factor to obtain the mapping coordinate position. Since the contour map corresponding to the target object has been downsampled, the coordinate value needs to be restored by multiplying the downsampling factor during mapping.

[0114] The detection frame of the target object is mapped to the original image according to the mapping coordinate position, and the image is cropped according to the position of the detection frame mapped in the original image to obtain the target image.

[0115] The core of the image segmentation method of the embodiment of the present invention is the joint design of multiple image processing algorithms, including downsampling acceleration, image segmentation and bounding rectangle calculation. The method can achieve rapid processing of large-scale data streams while maintaining high segmentation accuracy. The method is suitable for cell particle detection in high-speed imaging systems and can quickly process target particles. At the same time, for objects with transparent textures, such as casts and epithelial cells in urine, the method of the present invention can provide excellent segmentation effects. Through the method of the embodiment of the present invention, the accuracy and efficiency of image processing can be effectively improved, and high-quality input data can be provided for subsequent image analysis and machine learning training.

[0116] Embodiment 2:

[0117] In the embodiment of the present invention, a parallel implementation scheme based on FPGA is further provided on the basis of embodiment 1. The scheme is composed of a buffer unit and an edge detection unit. The buffer unit is used to store pixel data and transmit it to the edge detection unit in an appropriate manner for edge detection. Figure 5 As shown, the FPGA-based parallel implementation scheme performs high-speed image segmentation based on FPGA transmission of pre-processed images, including the following processes:

[0118] The buffer unit uses the demultiplexer to sequentially store the first and second rows of input pre-processed image pixels into block 1 and block 2 of the block random access memory, respectively. At this time, the multiplexer will wait and remain inactive until block 2 is completely filled. When the third row of image pixel data begins to fill block 3, the multiplexer is used to simultaneously transmit the pixel data in blocks 1, 2, and 3, with one column pixel transmitted per clock (i.e. ) to the edge detection unit; when the pixel data in blocks 1, 2 and 3 are all transmitted, the demultiplexer is used to sequentially store the fourth and fifth rows of pre-processed image pixels in blocks 1 and 2 of the block random access memory, respectively. When the sixth row of image pixel data begins to fill block 3, the multiplexer is used to simultaneously transmit the pixel data in blocks 1, 2 and 3. By analogy, the above storage and transmission process of the pre-processed image pixels is repeated until all the pixels of the pre-processed image are transmitted to the edge detection unit.

[0119] The edge detection unit calculates the pixel gradients of the preprocessed image in the x and y directions within the period with three clocks as a cycle, and screens out the gradient amplitudes of the pixel gradients that are less than the first threshold value through the first threshold value and the second threshold value. The specific screening process is the same as the dual threshold detection process of the first threshold value and the second threshold value in Example 1.

[0120] Specifically, in the embodiment of the present invention, the edge detection unit uses three clock cycles to calculate the pixel gradients of the preprocessed image in the x direction and the y direction within the cycle. The process specifically includes:

[0121] The edge detection unit uses the rank property of the 3×3 operator to optimize the gradient calculation. If the rank of any matrix of the operator is 1, it means that each element of the first column has a fixed ratio c with the elements of other columns of the same kernel. The first column, second column, and third column of the operator can be represented as c1, c2, and c3 respectively. At this time, when the first clock arrives, the first column c1 of the x-direction operator is multiplied and added with the preprocessed image pixels to calculate the gradient in the x direction. :

[0122] (5)

[0123] in, Indicates the gradient magnitude in the x direction calculated when the first clock arrives.

[0124] When the second clock arrives, the second column c2 of the x-direction operator is multiplied and added with the preprocessed image pixels to calculate the gradient in the x-direction :

[0125] (6)

[0126] When the third clock arrives, the third column c3 of the x-direction operator is multiplied and added with the preprocessed image pixels to calculate the gradient in the x-direction :

[0127] (7)

[0128] With three clocks as one cycle, calculate the total gradient in the x direction within the cycle :

[0129] (8)

[0130] Similarly, based on the gradient calculation method in the x direction within the cycle, the total gradient in the y direction within the cycle is calculated .

[0131] Referring to the morphological processing process in Example 1, after the preprocessed image is transmitted and all pixels have completed gradient amplitude screening, the embodiment of the present invention uses a row buffer and a column buffer to perform a bit-by-bit AND operation on the image area in the sliding window and the structural element defined by the erosion operation, and obtains the minimum value of each pixel in the sliding window to obtain the eroded image, and obtains the maximum value of each pixel in the sliding window to obtain the dilated image.

[0132] Finally, the rotating caliper method is used to calculate the convex points of the edge contour of the target object in the expanded image, and the bounding rectangle of the target object is determined according to the coordinates of the convex points. The bounding rectangle of the target object is processed by non-maximum suppression to obtain the detection frame, and the detection frame is mapped to the original image for image cropping to obtain the target image. Among them, the rotating caliper method (also known as the rotating caliper method) is a convex hull algorithm that can solve problems related to the properties of the convex hull, such as the convex hull diameter and the minimum rectangle coverage, in linear time.

[0133] The embodiment of the present invention provides an FPGA parallel processing design scheme for an image segmentation method. Based on the original image segmentation method, the multi-tasking capability of the FPGA itself is utilized to further improve the edge detection speed of the image.

[0134] Embodiment 3:

[0135] Reference Figure 6 As shown, the embodiment of the present invention also provides a high-speed image cutting device, comprising:

[0136] An image preprocessing module is used to perform image preprocessing on the original image to obtain a preprocessed image;

[0137] The edge detection module is used to calculate the pixel gradient in the preprocessed image and perform non-maximum suppression processing on the pixel gradient, perform double threshold detection on the pixel gradient after non-maximum suppression processing, determine the edge position of the target object in the image, and obtain the edge detection result of the target object;

[0138] A morphological processing module is used to perform morphological enhancement processing on the edge of the target object in the edge detection result of the target object to obtain a morphologically enhanced image;

[0139] The detection frame calculation module is used to traverse the edge contour of the morphological enhancement image, determine the minimum bounding rectangle of the target object in the image, and perform non-maximum suppression processing on the minimum bounding rectangle to obtain the detection frame of the target object;

[0140] The image cropping module is used to map the pixel coordinate position corresponding to the detection frame of the target object to the original image, and to crop the image according to the mapping position of the detection frame in the original image to obtain the target image.

[0141] Specifically, in the embodiment of the present invention, the image preprocessing module is responsible for downsampling, denoising, and contrast enhancement of the original image. The purpose of downsampling the image is to reduce the amount of data processing in subsequent steps and improve the processing speed.

[0142] Specifically, in the embodiment of the present invention, the edge detection module is composed of a gradient calculation unit, a non-maximum suppression unit, and a dual threshold detection unit. The gradient calculation unit first obtains an image, and then calculates the first-order partial derivative matrix of the image in the x-direction and y-direction (which can be completed by fixed operator convolution, such as Sobel), and calculates the gradient direction and amplitude of each pixel in the image according to the first-order partial derivative matrix in the x-direction and y-direction. After the gradient calculation is completed, the non-maximum suppression unit compares the gradient strength of the current pixel with the two pixels along the positive and negative gradient directions. If the gradient strength of the current pixel is the largest compared with the gradient strengths of the other two pixels, the pixel point is retained as an edge point, otherwise the pixel point will be suppressed. Next, the dual threshold detection unit compares the gradient amplitude at the edge with the two thresholds. If the gradient amplitude of a pixel is smaller than the smaller threshold, it will be removed; if the gradient amplitude of a pixel is larger than the smaller threshold but smaller than the larger threshold, the pixel will be marked as a weak edge; if the gradient amplitude of a pixel is larger than the larger threshold, the pixel will be marked as a strong edge; in addition, the dual threshold detection unit will also search for a strong edge in the preset neighborhood range of the weak edge. If a strong edge exists in the preset neighborhood, the weak edge will be retained, otherwise the weak edge will be deleted, and finally the edge detection result is obtained.

[0143] The embodiment of the present invention reduces the amount of data processing in subsequent image processing steps and improves the image processing speed by preprocessing the original image such as downsampling, denoising, and contrast enhancement. At the same time, by preprocessing the image and performing gradient calculation, non-maximum suppression, dual threshold detection, and morphological processing in sequence, the edge contour of the target object in the image can be quickly and accurately located. Then, the detection frame of the target object is determined by calculating the minimum circumscribed rectangle of the edge contour, and finally the target image is cropped according to the mapping position of the detection frame in the original image, realizing high-speed image cutting. It can realize rapid processing of large-scale data streams while maintaining high segmentation accuracy, effectively improving the accuracy and efficiency of image processing.

[0144] In the description of the embodiments of the present invention, the terms "first", "second", "third", and "fourth" are used for descriptive purposes only and are not to be understood as indicating or implying relative importance or implicitly indicating the number of the indicated technical features. Thus, a feature defined as "first", "second", "third", and "fourth" may explicitly or implicitly include one or more of the features. In the description of the present invention, unless otherwise specified, "multiple" means two or more.

[0145] In the description of the embodiments of the present invention, specific features, structures, materials or characteristics may be combined in a suitable manner in any one or more embodiments or examples.

[0146] In the description of the embodiments of the present invention, the term "and / or" herein is merely a description of the association relationship of associated objects, indicating that three relationships may exist. For example, A and / or B may represent: A exists alone, A and B exist at the same time, and B exists alone. In addition, the character " / " herein generally indicates that the associated objects before and after are in an "or" relationship.

[0147] Although embodiments of the present invention have been shown and described, it will be appreciated by those skilled in the art that various changes, modifications, substitutions and variations may be made to the embodiments without departing from the principles and spirit of the present invention, and that the scope of the present invention is defined by the appended claims and their equivalents.

Claims

1. A high-speed image cutting method, characterized in that: include: Perform image preprocessing on the original image to obtain a preprocessed image; the image preprocessing includes downsampling acceleration, Gaussian denoising and feature enhancement; Calculate the pixel gradient in the preprocessed image and perform non-maximum suppression on the pixel gradient, perform double threshold detection on the pixel gradient after non-maximum suppression, determine the edge position of the target in the image, and obtain the edge detection result of the target; Performing morphological enhancement processing on the edge of the target object in the edge detection result of the target object to obtain a morphologically enhanced image; Traverse the edge contour of the morphologically enhanced image to determine the minimum bounding rectangle of the target in the image, and perform non-maximum suppression processing on the minimum bounding rectangle to obtain the detection frame of the target; Map the pixel coordinate position corresponding to the detection frame of the target object to the original image, and crop the image according to the mapping position of the detection frame in the original image to obtain the target image, including: Multiply the pixel coordinates of the target object's detection frame by the downsampling factor to obtain the mapping coordinates. The detection frame of the target object is mapped to the original image according to the mapping coordinate position, and the image is cropped according to the position of the detection frame mapped in the original image to obtain the target image; High-speed image cutting based on FPGA transmission pre-processed images, including: The buffer unit uses a demultiplexer to sequentially store the first row and the second row of input preprocessed image pixels into blocks 1 and 2 of a block random access memory, respectively; when the third row of image pixel data starts to fill block 3, the multiplexer is used to simultaneously transmit the pixel data in blocks 1, 2 and 3, and one column of pixels is transmitted to the edge detection unit per clock; when the pixel data in blocks 1, 2 and 3 are all transmitted, the demultiplexer is used to sequentially store the fourth row and the fifth row of preprocessed image pixels into blocks 1 and 2 of a block random access memory, respectively; when the sixth row of image pixel data starts to fill block 3, the multiplexer is used to simultaneously transmit the pixel data in blocks 1, 2 and 3; the storage and transmission process of the preprocessed image pixels is repeated until all pixels of the preprocessed image are transmitted to the edge detection unit; The edge detection unit calculates the pixel gradients of the preprocessed image in the x direction and the y direction within the cycle with three clocks as a cycle, and screens out the gradient amplitudes of the pixel gradients that are less than the first threshold value through the first threshold value and the second threshold value; the edge detection unit calculates the pixel gradients of the preprocessed image in the x direction and the y direction within the cycle with three clocks as a cycle, including: The edge detection unit uses the rank property of the 3×3 operator to optimize the gradient calculation. When the first clock arrives, it uses x The first column of the direction operator c 1 is multiplied and added with the preprocessed image pixels to calculate x Directional gradient : , in, Indicates the calculated value when the first clock arrives x Directional gradient magnitude; When the second clock arrives, use x The second column of the direction operator c 2 is multiplied and added with the preprocessed image pixels to calculate x Directional gradient : , When the third clock arrives, use x The third column of the direction operator c 3 is multiplied and added with the preprocessed image pixels to calculate x Directional gradient : , Take three clocks as one cycle and calculate the cycle x The total gradient of the direction : , Based on the cycle x Direction gradient calculation method, calculate the period y The total gradient of the direction ; After the preprocessed image is transmitted and all pixels have completed the gradient amplitude screening, the row buffer and column buffer are used to perform bit-by-bit AND operations on the image area and the structural element in the sliding window, and the minimum value of each pixel in the sliding window is obtained to obtain the eroded image, and the maximum value of each pixel in the sliding window is obtained to obtain the expanded image; The convex points of the edge contour of the target object in the expanded image are calculated by the rotating caliper method, and the bounding rectangle of the target object is determined according to the coordinates of the convex points. The bounding rectangle of the target object is processed by non-maximum suppression to obtain a detection frame, which is mapped to the original image for image cropping to obtain the target image.

2. The high-speed image cutting method according to claim 1, characterized in that: The performing image preprocessing on the original image to obtain a preprocessed image includes: The original image is downsampled to M×N The original image is converted to a size of The downsampled image, where s is the downsampling factor, and is the image size after downsampling; The downsampled image is convolved with a Gaussian filter to eliminate random noise in the downsampled image, as shown in the following formula: , in, is the Gaussian kernel function: , σ represents the standard deviation, exp represents the exponential function, I represents the downsampled image, represents the denoised image, k represents the Gaussian kernel size, ( x , y ) represents the image coordinates; The histogram equalization method is used to enhance the image features and obtain the preprocessed image .

3. The high-speed image cutting method according to claim 1, characterized in that: The step of calculating pixel gradients in the preprocessed image and performing non-maximum suppression processing on the pixel gradients includes: Compute preprocessed image beg x Direction and y The first-order partial derivative matrix in the direction: , in, Indicated in x The first-order partial derivative matrix in the direction, Indicated in y The first-order partial derivative matrix of the direction; Compute preprocessed image The gradient direction and magnitude of each pixel in : , , in, M ( x , y ) is the gradient amplitude of the pixel, indicating the gradient strength of the pixel, θ ( x , y ) is the gradient direction of the pixel; Preprocess the image The gradient magnitude of the current pixel is compared with the gradient magnitude of the two pixels along the positive and negative gradient directions. If the gradient magnitude of the current pixel is greater than the gradient magnitude of the two pixels along the positive and negative gradient directions, the current pixel point is retained as an edge point, otherwise the current pixel point will be suppressed.

4. The high-speed image cutting method according to claim 1, characterized in that: The double threshold detection is performed on the pixel gradient after the non-maximum suppression process to determine the edge position of the target object in the image and obtain the edge detection result of the target object, including: Compare the gradient magnitude of the pixel at the edge point with a first threshold and a second threshold respectively, wherein the first threshold is less than the second threshold; If the gradient magnitude of a pixel is less than a first threshold, the corresponding pixel is removed; if the gradient magnitude of a pixel is greater than the first threshold and less than a second threshold, the corresponding pixel is marked as a weak edge; if the gradient magnitude of a pixel is greater than the second threshold, the corresponding pixel is marked as a strong edge; Find a strong edge within the preset range of the weak edge. If there is a strong edge within the preset range, keep the corresponding weak edge, otherwise delete the corresponding weak edge. Based on preprocessed image The strong edges and weak edges in the output are the edge detection results of the target object.

5. The high-speed image cutting method according to claim 1, characterized in that: The step of performing morphological enhancement processing on the edge of the target object in the edge detection result of the target object to obtain a morphologically enhanced image includes: The edge of the target object in the edge detection result is corroded and expanded to enhance the continuity and integrity of the edge, and the gaps and breakpoints in the edge are filled to enhance the clarity and continuity of the edge contour to obtain a morphologically enhanced image.

6. The high-speed image cutting method according to claim 1, characterized in that: The edge contour traversal of the morphologically enhanced image is performed to determine the minimum bounding rectangle of the target object in the image, and non-maximum suppression processing is performed on the minimum bounding rectangle to obtain a detection frame of the target object, including: Traverse the edge contours of the target object in the morphological enhancement image to determine multiple minimum circumscribed rectangles; The areas of multiple minimum bounding rectangles are calculated, and the minimum bounding rectangle with the largest area is retained from the multiple minimum bounding rectangles as the detection frame of the target object.

7. A high-speed image cutting device for implementing the high-speed image cutting method according to any one of claims 1 to 6, characterized in that: include: An image preprocessing module is used to perform image preprocessing on the original image to obtain a preprocessed image; The edge detection module is used to calculate the pixel gradient in the preprocessed image and perform non-maximum suppression processing on the pixel gradient, perform double threshold detection on the pixel gradient after non-maximum suppression processing, determine the edge position of the target object in the image, and obtain the edge detection result of the target object; A morphological processing module is used to perform morphological enhancement processing on the edge of the target object in the edge detection result of the target object to obtain a morphologically enhanced image; The detection frame calculation module is used to traverse the edge contour of the morphological enhancement image, determine the minimum bounding rectangle of the target object in the image, and perform non-maximum suppression processing on the minimum bounding rectangle to obtain the detection frame of the target object; The image cropping module is used to map the pixel coordinate position corresponding to the detection frame of the target object to the original image, and to crop the image according to the mapping position of the detection frame in the original image to obtain the target image.

Citation Information

Patent Citations

  • High-resolution image accelerated processing method based on parallel pipeline mechanism

    CN106447597A

  • An intelligent identification and analysis method for an examination answer sheet system

    CN109711284A

  • Medicine box segmentation method

    CN114092499A