A contour fast marking and searching method for multiple microorganism images

By determining the starting pixel point in the microbial image and searching along a predetermined direction to update the pixel coordinate matrix, the problem of low efficiency in the labeling and searching of connected components in microbial images in the prior art is solved. This achieves fast and accurate labeling and storage of connected component locations, thereby improving image processing efficiency.

CN119810068BActive Publication Date: 2026-04-17BEIHANG UNIV
View PDF 2 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
BEIHANG UNIV
Filing Date
2024-12-20
Publication Date
2026-04-17

AI Technical Summary

Technical Problem

Existing technologies suffer from low efficiency in connected component labeling and lookup when processing high-resolution microbial images, especially for large images and large numbers of bacteria, where existing methods are computationally intensive and inefficient.

Method used

A fast contour labeling and search method for various microbial images is proposed. By acquiring the target binary image and pixel coordinate matrix, the starting pixel is determined using the configured search rules, and the connected components are searched along a predetermined direction. The values ​​in the pixel coordinate matrix are updated until all pixels are traversed, thereby achieving accurate positioning and labeling of the connected components.

Benefits of technology

It enables rapid and accurate labeling and storage of connected components in microbial images, improving the efficiency and accuracy of image processing. It can complete the storage and retrieval of 25000*25000 pixel images within 12 seconds and is suitable for contour searching of various microbial images.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119810068B_ABST
    Figure CN119810068B_ABST
Patent Text Reader

Abstract

This application provides a method for rapid contour marking and finding of various microbial images, relating to the field of image processing technology. The method includes: acquiring a target binary image and a target pixel coordinate matrix of the target binary image; for any connected component, determining the starting pixel of the connected component among the pixels within the connected component according to a configured search rule; searching the connected component along a first target neighborhood direction based on the starting pixel to obtain a first connected pixel in the first target neighborhood direction; updating the values ​​of the elements in the target pixel coordinate matrix corresponding to the pixel coordinates of the starting pixel and the first connected pixel to a connected component threshold; and determining the location of the connected component from the updated target pixel coordinate matrix based on the connected component threshold. This application can efficiently determine the location of connected components in an image.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of image processing technology, and more specifically, to a method for rapid contour marking and search of images of various microorganisms. Background Technology

[0002] Microscopic imaging technology enables precise measurement of bacteria at the single-cell level, which is crucial for understanding microbial communities and accurately controlling bacteria-based treatments and diagnostics. Live bacteria can be localized and imaged using methods such as genes, organic dyes, or nanoprobes. Based on the imaging results, segmentation algorithms generate bacterial instance masks. By labeling these masks, information such as the location, morphology, and contour of individual bacteria can be obtained for subsequent in-depth analysis. Labeling each bacterium can be achieved by marking connected components in the binary image of the mask, and then extracting more detailed bacterial location, morphology, and contour information based on the labeled connected components. However, a high-resolution microbial image is extremely large, typically hundreds of millions of pixels, containing a vast number of bacteria, usually hundreds of thousands. Therefore, it is necessary to effectively label and store the connected components of these bacteria before achieving rapid search and extraction of bacterial contours.

[0003] Existing methods for determining the location of connected components include the quadratic scanning method and the region growing method. The quadratic scanning method requires two image traversals, which takes more time. It also requires mapping the labels of the connected regions to each other and selecting the smallest label, resulting in excessive computation. In addition, the actual image size is huge, while the area of ​​the connected component only occupies a small part of the actual image, so the processing efficiency is relatively low. The region growing method requires judging each target element one by one. When the area of ​​the connected component is large, the algorithm efficiency drops significantly. Summary of the Invention

[0004] The purpose of this application is to provide a method for rapid contour marking and searching of various microbial images, in order to solve the above-mentioned problems existing in the prior art, and to quickly and accurately obtain the location of connected regions in the image.

[0005] Firstly, a method for rapid contour marking and searching of various microbial images is provided, which may include:

[0006] Obtain a target binary image and a target pixel coordinate matrix of the target binary image; wherein, the position of each element in the target pixel coordinate matrix corresponds one-to-one with the pixel coordinate of each pixel in the target binary image; the target binary image contains at least one connected component; each connected component corresponds to a unique connected component threshold;

[0007] For any connected component, the starting pixel of the connected component is determined among the pixels within the connected component according to the configured search rules; wherein, the search rules include a search direction and a first target neighborhood direction; the first target neighborhood direction is determined based on the search direction;

[0008] Based on the starting pixel, the connected region is searched along the first target neighborhood direction to obtain the first connected pixel of the starting pixel in the first target neighborhood direction;

[0009] The pixel coordinates of the starting pixel and the first connected pixel are respectively updated to the value of the element position in the target pixel coordinate matrix corresponding to the pixel coordinates of the starting pixel and the first connected pixel, respectively, and the connected component threshold is updated to the connected component threshold.

[0010] Based on the starting pixel in the connected component, the first connected pixel, and the search rule, obtain the second connected pixel;

[0011] Using the second connected pixel as the new starting pixel, return to the execution step: search the connected region along the first target neighborhood direction based on the starting pixel until all pixels in the connected region have been traversed;

[0012] Based on the connected component threshold, the position of the connected component is determined from the updated target pixel coordinate matrix.

[0013] In an optional implementation, each matrix element corresponds to an initial element value;

[0014] The search rules also include: the search starting point.

[0015] In an optional implementation, the starting pixel of the connected component is determined among the pixels within the connected component according to the configured search rules, including:

[0016] Based on the search starting point and search direction, the target binary image is searched, and the first pixel found that is located in the connected region is taken as the initial pixel.

[0017] If the pixel coordinates of the initial pixel point correspond to the same element position value in the target pixel coordinate matrix as the initial element value, then the initial pixel point is taken as the starting pixel point of the connected component.

[0018] In an optional implementation, searching the connected components along the first target neighborhood direction based on the starting pixel to obtain the first connected pixel in the first target neighborhood direction includes:

[0019] If the adjacent pixels of the starting pixel in the first target neighborhood direction are located within the connected region, then the adjacent pixels are taken as the first connected pixels.

[0020] If the adjacent pixels of the first connected pixel point in the first target neighborhood direction are located within the connected region, then the adjacent pixels of the first connected pixel point in the first target neighborhood direction are taken as the first connected pixel point.

[0021] Based on each first connected pixel, the first connected pixel of the starting pixel in the direction of the first target neighborhood is obtained.

[0022] In an optional implementation, the search rule further includes: a second target neighborhood direction; the second target neighborhood direction is determined based on the search direction;

[0023] Based on the starting pixel in the connected component, the first connected pixel, and the search rule, the second connected pixel is obtained, including:

[0024] If the adjacent pixels of the starting pixel in the second target neighborhood direction are located in the connected region, then the adjacent pixels are taken as the second connected pixels.

[0025] If the adjacent pixels of the first connected pixel in the second target neighborhood direction are located in the connected region, then the adjacent pixels of the first connected pixel in the second target neighborhood direction are taken as the second connected pixel.

[0026] In an optional implementation, the method further includes: generating a connected component search array based on the pixel coordinates of each second connected pixel;

[0027] Using the second connected pixel as the new starting pixel includes:

[0028] For any pixel coordinate in the connected component search array, the pixel point corresponding to the pixel coordinate is taken as the new starting pixel point.

[0029] In an optional implementation, determining the location of the connected component from the updated target pixel coordinate matrix based on the connected component threshold includes:

[0030] The matrix elements in the updated target pixel coordinate matrix whose element values ​​are the same as the connected component threshold are used as the target matrix elements of the connected component.

[0031] Based on the element positions of each obtained target matrix element, the position of the connected component is determined.

[0032] Secondly, a device for rapid contour marking and searching of various microbial images is provided, the device may include:

[0033] An acquisition unit is used to acquire a target binary image and a target pixel coordinate matrix of the target binary image; wherein, the position of each element in the target pixel coordinate matrix corresponds one-to-one with the pixel coordinates of each pixel in the target binary image; the target binary image contains at least one connected component; each connected component corresponds to a unique connected component threshold.

[0034] A search unit is configured to, for any connected component, determine the starting pixel of the connected component among the pixels within the connected component according to a configured search rule; wherein the search rule includes a search direction and a first target neighborhood direction; the first target neighborhood direction is determined based on the search direction; and the connected component is searched along the first target neighborhood direction based on the starting pixel to obtain the first connected pixel of the starting pixel in the first target neighborhood direction.

[0035] The update unit is used to update the values ​​of the element positions in the target pixel coordinate matrix corresponding to the pixel coordinates of the starting pixel point and the first connected pixel point to the connected component threshold of the connected component;

[0036] The return unit is used to obtain a second connected pixel based on the starting pixel in the connected region, the first connected pixel, and the search rule; and to return to the execution step of using the second connected pixel as a new starting pixel: searching the connected region along the first target neighborhood direction based on the starting pixel until all pixels in the connected region have been traversed.

[0037] The determining unit is used to determine the position of the connected component from the updated target pixel coordinate matrix based on the connected component threshold.

[0038] Thirdly, an electronic device is provided, which includes a processor, a communication interface, a memory, and a communication bus, wherein the processor, the communication interface, and the memory communicate with each other through the communication bus;

[0039] Memory, used to store computer programs;

[0040] When a processor executes a program stored in memory, it implements any of the steps described in the first aspect above.

[0041] Fourthly, a computer-readable storage medium is provided, wherein a computer program is stored therein, and when executed by a processor, the computer program implements the steps of any of the methods described in the first aspect above.

[0042] In the bacterial analysis of actual microbial images, this application can complete the storage and retrieval of an image with a size of 25000*25000 pixels and containing 10000 connected components in just 12 seconds.

[0043] This application can efficiently, quickly, and accurately find connected components (i.e., microbial image outlines) in an image. At the same time, it constructs a matrix that is exactly the same as the pixel value distribution of the binary image based on the found connected components, and marks and stores the positions of each connected component in the image for later image processing tasks, thereby improving the efficiency and accuracy of image processing and providing accurate connected component information for different application scenarios.

[0044] This application uses a complete outline in a variety of microbial images as a connected component in that image. By constructing a matrix that is exactly the same as the pixel value distribution of the image, the positions of each connected component, i.e. each microbial outline, are obtained and marked, which facilitates the subsequent search for the positions of different microbial outlines and the determination of the state of different microbial outlines. Attached Figure Description

[0045] To more clearly illustrate the technical solutions of the embodiments of this application, the accompanying drawings used in the embodiments of this application will be briefly introduced below. It should be understood that the following drawings only show some embodiments of this application and should not be regarded as a limitation of the scope. For those skilled in the art, other related drawings can be obtained based on these drawings without creative effort.

[0046] Figure 1 A flowchart illustrating a method for rapid contour marking and search of various microbial images provided in this application embodiment;

[0047] Figure 2 An architecture diagram of a method for rapid contour labeling and search of bacteria for multiple microbial images provided in this application embodiment;

[0048] Figure 3 A flowchart illustrating a method for contour marking of microbial images provided in this application embodiment;

[0049] Figure 4 A schematic diagram of a storage structure provided in an embodiment of this application;

[0050] Figure 5 A schematic diagram illustrating a method for rapid contour marking and search of various microbial images provided in this application embodiment;

[0051] Figure 6 A schematic diagram of a device for rapid contour marking and searching of various microbial images provided in this application embodiment;

[0052] Figure 7 This is a schematic diagram of the structure of an electronic device provided in an embodiment of this application. Detailed Implementation

[0053] The technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only a part of the embodiments of this application, and not all of the embodiments. Based on the embodiments of this application, all other embodiments obtained by those of ordinary skill in the art without creative effort are within the scope of protection of this application.

[0054] The preferred embodiments of this application are described below with reference to the accompanying drawings. It should be understood that the preferred embodiments described herein are for illustration and explanation only and are not intended to limit this application. Furthermore, the embodiments and features in the embodiments of this application can be combined with each other without conflict.

[0055] Figure 1 This is a flowchart illustrating a method for rapid contour marking and search of various microbial images, provided as an embodiment of this application. Figure 1 As shown, the method may include:

[0056] Step S110: Obtain the target binary image and the target pixel coordinate matrix of the target binary image; for any connected component, determine the starting pixel of the connected component among the pixels in the connected component according to the configured search rules.

[0057] In the embodiments of this application, the target binary image is a binary image containing multiple or various microbial outlines.

[0058] In this embodiment, the position of each element in the target pixel coordinate matrix corresponds one-to-one with the pixel coordinates of each pixel in the target binary image; the target binary image contains at least one connected component; each connected component corresponds to a unique connected component threshold.

[0059] In this embodiment of the application, each matrix element in the target pixel coordinate matrix corresponds to an initial element value, and each initial element value can be set to 0; when the element value of a certain matrix element is not 0, it means that the matrix element has been searched before (that is, its corresponding pixel has been searched).

[0060] In this embodiment of the application, the search rules include a search starting point, a search direction, a first target neighborhood direction, and a second target neighborhood direction. Specifically, the search starting point, the first target neighborhood direction, and the second target neighborhood direction are all determined based on the search direction. The search starting point is the starting point of the search direction, and the first target neighborhood direction and the second target neighborhood direction are the two endpoints of the search direction.

[0061] For example, if the search direction is from left to right and from top to bottom, the starting point of the search is the top left pixel of the image, the first target neighborhood direction is down, and the second target neighborhood direction is right; alternatively, the first target neighborhood direction can be right and the second target neighborhood direction can be down. If the search direction is from right to left and from bottom to top, the starting point of the search is the bottom right pixel of the image, the first target neighborhood direction is left, and the second target neighborhood direction can be up; alternatively, the first target neighborhood direction can be up and the second target neighborhood direction can be left.

[0062] In the embodiments of this application, assuming that the values ​​of the binary image are 0 and 1, then a pixel with a value of 1 indicates that it is located inside the connected component, while a pixel with a value of 0 indicates that it is located outside the connected component.

[0063] In this embodiment of the application, determining the starting pixel of the connected component among the pixels within the connected component according to the configured search rules includes:

[0064] Based on the search starting point and search direction, the target binary image is searched, and the first pixel found that is located in the connected region is taken as the initial pixel.

[0065] If the pixel coordinates of the initial pixel point have the same element position value in the target pixel coordinate matrix as the initial element value, then the initial pixel point is taken as the starting pixel point of the connected component.

[0066] If the pixel coordinates of the initial pixel point are different from the value of the element position in the target pixel coordinate matrix, then the initial pixel point is taken as the new search starting point, and the execution steps are returned: based on the search starting point and search direction, search the target binary image until an initial pixel point is obtained that is located in the connected region and whose value of the element position in the corresponding target pixel coordinate matrix is ​​the same as the initial element value.

[0067] In this embodiment, if the value of the element position in the target pixel coordinate matrix corresponding to the pixel coordinate of the initial pixel is different from the initial element value, then the value of its element position should be the same as the threshold of the connected component it is in, proving that the pixel has been found before and is not the first time it has been searched, and therefore cannot be used as the starting pixel.

[0068] In this embodiment, the initial pixel is the first pixel with a value of 1 in the connected component. If the value of the element position corresponding to the pixel coordinate of the initial pixel in the target pixel coordinate matrix is ​​0 (i.e., the initial element value), then the initial pixel is the starting pixel of the connected component. If the corresponding value is not 0, the search continues in the search direction with the initial pixel as the starting point until the corresponding starting pixel is found or the edge of the image (i.e., the end point) is reached.

[0069] For example, starting from the top left corner, the search direction is from left to right and from top to bottom. Suppose the pixel with coordinates (2,2) in the image has a value of 1, then (2,2) is the initial pixel. Continue to check if the value of the matrix element at (2,2) in the target pixel matrix is ​​the initial value, i.e., 0. If it is 0, then (2,2) is the starting pixel; otherwise, starting from (2,2), continue to search for the next pixel with a value of 1 in the direction from left to right and from top to bottom.

[0070] Step S120: Based on the starting pixel, search the connected region along the first target neighborhood direction to obtain the first connected pixel of the starting pixel in the first target neighborhood direction.

[0071] In this embodiment of the application, searching the connected components along the direction of the first target neighborhood based on the starting pixel to obtain the first connected pixel in the direction of the first target neighborhood includes:

[0072] If the neighboring pixels of the starting pixel in the first target neighborhood direction are located within the connected component, then the neighboring pixels are taken as the first connected pixels, and the search continues to check whether the neighboring pixels of the first connected pixel in the first target neighborhood direction are located within the connected component. If they are located outside the connected component, then the starting pixel has 1 first connected pixel in the first target neighborhood direction, that is, the neighboring pixels of the starting pixel in the first target neighborhood direction. If the neighboring pixels of the first connected pixel in the first target neighborhood direction are located within the connected component, then the neighboring pixels of the first connected pixel in the first target neighborhood direction are also taken as the first connected pixels of the starting pixel. This search continues until the neighboring pixels of a certain first connected pixel in the first target neighborhood direction are located outside the connected component.

[0073] If the neighboring pixels of the starting pixel in the first target neighborhood direction are outside the connected region, it means that the starting pixel has no connected pixels in the first target neighborhood direction.

[0074] For example, if the starting pixel's coordinates are (2,2) and the first target neighborhood direction is directly below, then the adjacent pixel in the first target neighborhood direction of the starting pixel is (3,2). If the value of the pixel at (3,2) in the binary image is 1 (meaning it is within a connected component), then the pixel at (3,2) is taken as the first connected pixel. Continue to check if the value of the pixel directly below the first connected pixel (3,2), i.e., (4,2), in the binary image is 1. If it is 1, then (4,2) is also a first connected pixel, and the search can continue. If the value of (4,2) is 0, it means it is outside the connected component, and there is no need to continue the search. The starting pixel (2,2) has only one first connected pixel in the first target neighborhood direction, namely (3,2).

[0075] Step S130: Update the values ​​of the elements in the target pixel coordinate matrix corresponding to the pixel coordinates of the starting pixel and the first connected pixel to the connected region threshold of the connected region; obtain the second connected pixel based on the starting pixel, the first connected pixel and the search rule in the connected region.

[0076] In this embodiment, the value of the element in the matrix corresponding to the starting pixel is the initial element value. Since the search direction is fixed, once the starting pixel of a certain connected region is determined, the pixel coordinates of the pixel in the first target neighborhood direction of the starting pixel can be determined. The value of the element in the corresponding matrix should be consistent with the initial element value. Therefore, at this time, it is necessary to update the value of the element position in the matrix corresponding to the pixel coordinates of the starting pixel and the first connected pixel to the threshold of the connected region, so that the element distribution of the matrix is ​​consistent with the pixel distribution in the image, so as to determine each connected region in the image.

[0077] In this embodiment of the application, the second connected pixel is obtained based on the starting pixel, the first connected pixel, and the search rule in the connected component, including:

[0078] If the adjacent pixels of the starting pixel in the second target neighborhood direction are located in the connected region, then the adjacent pixels are taken as the second connected pixels.

[0079] If the neighboring pixels of the first connected pixel in the second target neighborhood direction are located in the connected region, then the neighboring pixels of the first connected pixel in the second target neighborhood direction are taken as the second connected pixel.

[0080] In this embodiment of the application, the method further includes: generating a connected component search array based on the pixel coordinates of each second connected pixel.

[0081] In this embodiment of the application, for the starting pixel and the first connected pixel, it is only determined whether the pixel closely adjacent to it in the second target neighborhood direction is located in the connected region, and the search is not continued along the second target neighborhood direction, that is, it is not determined whether the adjacent pixels of the second connected pixel in the second target neighborhood direction are located in the connected region.

[0082] In the embodiments of this application, the determination of the first connected pixel and the second connected pixel does not actually have a specific order. After the starting pixel is determined, it can be determined at the same time whether the adjacent pixels in the two target neighborhood directions of the pixel are located in the connected domain. Alternatively, it can be determined first whether the adjacent pixels in one target neighborhood direction are located in the connected domain, and then whether the adjacent pixels in the other target neighborhood direction are located in the connected domain.

[0083] In one embodiment of this application, taking the sequential relationship between the two as an example, after determining the starting pixel, it is determined whether its adjacent pixels in the second target neighborhood direction are located within a connected component. If the adjacent pixels in the second target neighborhood direction are located within a connected component, then the adjacent pixel is taken as the second connected pixel, and its pixel coordinates are stored in the connected component search array. Then, it is determined whether its adjacent pixels in the first target neighborhood direction are located within a connected component. If they are located within a connected component, then the pixel is taken as the first connected pixel. Next, it is determined whether the adjacent pixels in the second target neighborhood direction of the first connected pixel are located within a connected component. If they are located within a connected component, then the adjacent pixel is taken as the second connected pixel, and its pixel coordinates are stored in the connected component search array. If they are not located within a connected component, then it is determined whether the adjacent pixels in the first target neighborhood direction are located within a connected component.

[0084] In the embodiments of this application, the purpose of the operation performed after determining the starting pixel is to search only one direction during the search process, and only store the coordinates for the other direction. When the searched direction reaches the boundary, the stored coordinates are used as the new starting pixel to complete the next round of search; thereby improving search efficiency while avoiding repeated searches.

[0085] For example, if the second target neighborhood direction is right, the starting pixel's coordinates are (2,2), and the first connected pixels include (3,2), then we determine whether the starting pixel and the first connected pixels' adjacent pixels (2,3) and (3,3) in the second target neighborhood direction are within the connected component. If both (2,3) and (3,3) are within the connected component (i.e., their pixel values ​​are both 1), then both (2,3) and (3,3) are considered second connected pixels, and their coordinates are stored in the connected component search array. There is no need to determine whether the pixels to the right of (2,3) and (3,3) are within the connected component.

[0086] Step S140: Take the second connected pixel as the new starting pixel and return to the execution steps: Search the connected region along the direction of the first target neighborhood based on the starting pixel until all pixels in the connected region have been traversed; Determine the position of the connected region from the updated target pixel coordinate matrix according to the connected region threshold.

[0087] In this embodiment, after searching all the first connected pixels of the starting pixel of the connected region along the first target neighborhood direction, the pixel corresponding to each pixel coordinate stored in the connected region search array is taken as the new starting pixel, and then the first connected pixels in the corresponding first target neighborhood direction and the second connected pixels in the second target neighborhood direction are searched again, so as to search all the pixels of the connected region.

[0088] For example, the search direction is from top to bottom and from left to right. The direction of the first target neighborhood is directly below, and the direction of the second target neighborhood is directly to the right. The connected component search array contains (2,3) and (3,3). First, for (2,3), it is determined whether the pixel (2,4) directly to its right is located within the connected component. If it is not located, no operation is performed, and it is proven that (2,3) should be the right boundary of the connected component. If it is located, the process continues to check (2,5) until a pixel located outside the connected component is found. It is then determined whether the pixel (3,3) directly below (2,3) is located within the connected component. If it is located, the value of the element at matrix (3,3) is modified to the threshold of the connected component. Then, (3,3) is used as the new starting pixel, and the above steps are repeated.

[0089] In this embodiment of the application, determining the position of a connected component from the updated target pixel coordinate matrix based on the connected component threshold includes: taking the matrix elements in the updated target pixel coordinate matrix whose element values ​​are the same as the connected component threshold as the target matrix elements of the connected component; and determining the position of the connected component based on the element positions of each target matrix element.

[0090] In this embodiment of the application, after traversing all pixels within a connected component, the corresponding connected component search array can be deleted.

[0091] In this embodiment of the application, during the search process, if the element value of the corresponding element in the target matrix is ​​not the initial value, it means that the element has been marked or searched, and the element will be skipped directly to continue the search.

[0092] In this embodiment, after traversing all connected components in the image, a target matrix with the same pixel value distribution as the binary image can be obtained. Each region in the target matrix with non-zero element values ​​is a connected component of the binary image. Since the values ​​of the elements in the matrix corresponding to each pixel in each connected component are modified to the threshold of the connected component, the values ​​of each region in the target matrix are the thresholds of the connected components. Based on the target matrix, one can intuitively see how many connected components exist in the binary image and the distribution of each connected component.

[0093] In another embodiment of this application, such as Figure 2 As shown, methods for rapid contour labeling and lookup of various microbial images include:

[0094] Step 1: Obtain the bacterial segmentation mask binary image I1 of the microbial image. In I1, 0 represents the background and 1 represents the connected region.

[0095] Step 2: Create a labeling matrix M1 of the same size as the binary image to record the labeled connected components. The initial value is 0. An array of starting points A1 is used to record the coordinates of the starting point of each labeled connected component. That is, the number of rows in A1 corresponds to the number of connected components. A1 has two columns, which correspond to the starting point position of each connected component.

[0096] Step 3: Traverse the pixels from left to right and from top to bottom.

[0097] Step 4: If a pixel with a value of 0 is encountered, proceed to the next pixel as in Step 3. If a pixel with a value of 1 is encountered, first query the value at the corresponding position in M1. If the value is 0, then this point is a new connected component, denoted as the nth. Record the value at that position in M1 as n, and set the current position P... i,j Record this as the starting point position and add it to A1. Then proceed to step five. If the value is non-zero, proceed to step three and move on to the next pixel.

[0098] Step 5: Using P i,j Starting from I1, establish a connected component search array A2. Search to the right in I1 until a value of 0 is encountered. For non-zero regions, the corresponding position value in M1 is denoted as n. Specifically, when searching to the right in I1, if a non-zero value is encountered, it is not added to the A2 array. Instead, the value at the corresponding position in M1 is modified to n. The search stops when a 0 value is encountered. When searching downwards, if a non-zero value is encountered, the position of the search downwards is added to the A2 array. 0 values ​​are not processed in any way.

[0099] If we use 4-neighborhood to determine the connected components, then we can determine P in I1. i,j Point P below i+1,j Point P on the right i,j+1 The value of P. i+1,j If the value is 1, then P in M1 will be... i+1,j Let the value be n, and set P i+1,j Add to A2; if it is 0, do nothing. If P i,j+1 If the value is 1, then P in M1 will be... i,j+1 Let the value be n, and continue moving one step to the right to P. i,j+1 Repeat step five; if the result is 0, proceed to step six.

[0100] If we use 8-neighborhood to determine the connected components, then we can determine P in I1. i,j Point P below i+1,j Point P to its lower left i+1,j-1 P in the lower right corner i+1,j+1 Point P on the right i,j+1 The value of P. i+1,j If the value is 1, then P in M1 will be... i+1,j Let the value be n, and set P i+1,j Add to A2; if it is 0, do nothing. If P i+1,j-1 If the value is 1, then P in M1 will be...i+1,j-1 Let the value be n, and set P i+1,j-1 Add to A2; if it is 0, do nothing. If P i+1,j+1 If the value is 1, then P in M1 will be... i+1,j+1 Let the value be n, and set p i+1,j+1 Add to A2; if it is 0, do nothing. If P i,j+1 If the value is 1, then P in M1 will be... i,j+1 Let the value be n, and continue moving one step to the right to P. i,j+1 Repeat step five; if the result is 0, proceed to step six.

[0101] Step 6: Traverse A2, and record the point corresponding to the current traversal of A2 as . In query I1 If the value is 0, no action is taken; if it is 1, then query M1. The value of M1. If in M1 If the value is 0, then... Execute step five as the starting point; if M1 If the value is non-zero, no action is taken. Continue this process until A2 has been completely traversed, then delete the A2 array.

[0102] Step 7: After traversing all elements in I1 in step 4, we obtain a matrix M1 with connected component labels and an array A1 of starting points for each connected component. M1 and A1 complete the labeling and storage of bacterial outline information.

[0103] Step 8: Traverse array A1, and record the point corresponding to the current traversal of A1 as . The contour of the connected component can be extracted using a boundary tracing algorithm.

[0104] Step 9: Provide any point S in I1 i,j Find the corresponding bacterial profile. Search for S in M1. i,j The value of is determined by the number of elements in A1. If it is 0, the point is not a bacterial region and no bacterial outline exists. If it is n, the point is a bacterial region. The nth element in A1 is the starting point of this region, and the outline of the connected region can be obtained directly using the boundary tracing algorithm. This completes the search for the bacterial outline.

[0105] In another embodiment of this application, the fast contour labeling and search method for various microbial images can be applied to connected component labeling. It only requires traversing all pixels in the image once to achieve connected component labeling and location; this includes: establishing a label matrix and a starting point array. The original image is traversed, and the connected components of each pixel are determined. Corresponding labels are added to the label matrix, and only the starting points of the connected components are recorded in the starting point array. A connected component search array is used to perform the connected component search. The label matrix is ​​used to determine the pixels to which the connected components belong and the already labeled pixels. The labeled pixels are skipped during the search.

[0106] In another embodiment of this application, such as Figure 3 As shown, the fast contour labeling and search method for various microbial images can be applied to the storage and search of connected components in images. By creating a label matrix and a starting point array, the connected component search for any point in the image can be completed quickly. The specific steps are as follows:

[0107] Create a label matrix M1 of the same size as the binary image to record the labeled connected components. The initial value is 0. An array of starting points A1 is used to record the coordinates of the starting point of each labeled connected component. That is, the number of rows in A1 corresponds to the number of connected components. A1 has two columns, which correspond to the starting point position of each connected component.

[0108] Provide any point S in I1 i,j Find the corresponding bacterial profile. Search for S in M1. i,j The value of is determined by the number of elements in A1. If it is 0, the point is not a bacterial region and no bacterial outline exists. If it is n, the point is a bacterial region. The nth element in A1 is the starting point of this region, and the outline of the connected region can be obtained directly using the boundary tracing algorithm. This completes the search for the bacterial outline.

[0109] In another embodiment of this application, the rapid contour labeling and search method for various microbial images can be applied to a strategy of adding starting points to achieve connected component search. The specific steps are as follows:

[0110] With P i,j Starting from point I1, construct a connected component search array A2. Search to the right in I1 until a value of 0 is encountered. For non-zero regions, denote the corresponding position value in M1 as n. Traverse A2, and denote the point corresponding to the current traversal of A2 as . In query I1 If the value is 0, no action is taken; if it is 1, then query M1. The value of M1. If in M1 If the value is 0, then... Execute step five as the starting point; if M1 If the value is non-zero, no action is taken. Continue this process until A2 has been completely traversed, then delete the A2 array.

[0111] In one embodiment of this application, taking four-neighbor search as an example, the method for rapid contour labeling and searching of various microbial images includes:

[0112] like Figure 4 As shown, construct a label matrix M1 of the same size as the binary image I1, with each element of the label matrix M1 having an initial value of 0; create a starting point array A1; traverse I1 in the order of top to bottom and left to right, i.e., (1,1), (2,1), (3,1)...(6,1), (2,1), (2,2); since the search direction is from top to bottom and from left to right, and the 4-neighborhood contains four directions (up, down, left, right), subtract the top and left directions from the 4-neighborhood, keeping only the right and bottom directions, to obtain the neighborhood to be searched.

[0113] like Figure 5 As shown, when traversing to (2,2), the value of I1 is 1, the first connected component is encountered, and a connected component search array A2 is created; the value of M1 at this point is 0, and it is not marked, so the value of M1 at this point is updated to 1. (2,2) is added to A1, and at this time A1 contains (2,2).

[0114] The search is performed on the neighborhood of (2,2) based on the search direction. The neighborhood of (2,2) includes (2,3) and (3,2). (2,3) is 1, (2,2) is not the lower boundary of the connected component, the value of (2,3) in M1 is updated to 1, and (2,3) is added to A2. At this time, A2 contains (2,3). (3,2) is 1, the value of (3,2) in M1 is updated to 1, (2,2) is not the right boundary; at this time, A2 contains (2,3).

[0115] Continue searching downwards and to the right from (3,2). (3,3) is 1, (3,2) is not the lower boundary of the connected component, the value of (3,3) in M1 is updated to 1, (3,3) is added to A2, and A2 now contains (2,3) and (3,3). (4,2) is 0, (3,2) is the right boundary.

[0116] Traverse A2, perform a neighborhood search on the first point (2,3) in A2 until a 0 boundary is reached; (2,4) is 0, and (2,3) is the lower boundary of the connected domain. (3,3) is 1, the value of (3,3) in M1 is 1, it has been marked, and (2,3) is not the right boundary.

[0117] A neighborhood search is performed based on (3,3). (3,4) is 1, and (3,3) is not the lower boundary of the connected domain. The value of (3,4) in M1 is updated to 1, and (3,4) is added to A2. At this time, A2 contains (2,3), (3,3), and (3,4). (4,3) is 1, and (4,3) is not the right boundary of the connected domain. The value of (4,3) in M1 is updated to 1.

[0118] A neighborhood search is performed based on (4,3), where (4,4) is 0, (4,3) is the lower boundary of the connected domain, and (5,3) is 0, where (4,3) is the right boundary of the connected domain.

[0119] Continue traversing A2. The corresponding traversal point is (3,3). Perform a neighborhood search. M1's (3,4) has been marked as 1 and does not need to be modified. There is no need to add (3,4) to A2. At this time, A2 contains (2,3), (3,3), and (3,4); (4,3) is 1. M1's (4,3) value has been marked as 1, indicating that the right-side search has been completed and there is no need to continue searching to the right.

[0120] Continuing to traverse A2, the corresponding traversal point is now (3,4). Performing a neighborhood search, (3,5) is 0, and (3,4) is the lower boundary of the connected component. (4,4) is 0, and (3,4) is the right boundary of the connected component.

[0121] At this point, A2 has been traversed, connected component 1 has been marked, and the connected component search array A2 has been deleted.

[0122] Continue traversing I1 from top to bottom and left to right. Since (2,3), (3,2), (3,3), (4,3), and (3,5) have already been marked in M1, skip them until (6,4) where the second connected component is encountered. Create a connected component search array A2. Repeat the above steps.

[0123] Complete the update of the marker matrix M1 and the starting point array A1. The starting point array contains (2,2), (6,4), and (1,6).

[0124] Randomly select a point (2,6) and find its connected components.

[0125] Find the value 3 corresponding to (2,6) in M1, which corresponds to (1,6) in A1. Extract the contour of the connected component using the boundary tracking algorithm to complete the search.

[0126] Corresponding to the above method, embodiments of this application also provide a device for rapid contour marking and searching of various microbial images, such as... Figure 6 As shown, this device for rapid contour marking and finding of various microbial images includes:

[0127] The acquisition unit 610 acquires the target binary image and the target pixel coordinate matrix of the target binary image; wherein, the position of each element in the target pixel coordinate matrix corresponds one-to-one with the pixel coordinate of each pixel in the target binary image; the target binary image contains at least one connected component; each connected component corresponds to a unique connected component threshold.

[0128] The search unit 620 is used to determine the starting pixel of any connected component according to the configured search rules among the pixels in the connected component; wherein the search rules include a search direction and a first target neighborhood direction; the first target neighborhood direction is determined based on the search direction; the connected component is searched along the first target neighborhood direction based on the starting pixel to obtain the first connected pixel in the first target neighborhood direction;

[0129] The update unit 630 is used to update the values ​​of the element positions in the target pixel coordinate matrix corresponding to the pixel coordinates of the starting pixel and the first connected pixel to the connected component threshold.

[0130] Return unit 640 is used to obtain the second connected pixel based on the starting pixel, the first connected pixel, and the search rules in the connected component; take the second connected pixel as the new starting pixel and return to the execution steps: search the connected component along the direction of the first target neighborhood based on the starting pixel until all pixels in the connected component have been traversed;

[0131] The determining unit 650 is used to determine the position of the connected component from the updated target pixel coordinate matrix based on the connected component threshold.

[0132] The functions of each unit in the contour rapid marking and finding device for multiple microbial images provided in the above embodiments of this application can be implemented through the above method steps. Therefore, the specific working process and beneficial effects of each unit in the contour rapid marking and finding device for multiple microbial images provided in the embodiments of this application will not be repeated here.

[0133] This application also provides an electronic device, such as... Figure 7 As shown, it includes a processor 710, a communication interface 720, a memory 730, and a communication bus 740, wherein the processor 710, the communication interface 720, and the memory 730 communicate with each other through the communication bus 740.

[0134] Memory 730 is used to store computer programs;

[0135] When the processor 710 executes the program stored in the memory 730, it performs the following steps:

[0136] Obtain the target binary image and the target pixel coordinate matrix of the target binary image; wherein, the position of each element in the target pixel coordinate matrix corresponds one-to-one with the pixel coordinate of each pixel in the target binary image; the target binary image contains at least one connected component; each connected component corresponds to a unique connected component threshold;

[0137] For any connected component, the starting pixel of the connected component is determined among the pixels in the connected component according to the configured search rules. The search rules include the search direction and the first target neighborhood direction. The first target neighborhood direction is determined based on the search direction. The connected component is searched along the first target neighborhood direction based on the starting pixel to obtain the first connected pixel in the first target neighborhood direction.

[0138] The pixel coordinates of the starting pixel and the first connected pixel are respectively updated to the value of the element position in the target pixel coordinate matrix, which is the connected component threshold.

[0139] Based on the starting pixel, the first connected pixel, and the search rules in the connected component, obtain the second connected pixel; use the second connected pixel as the new starting pixel and return to the execution steps: search the connected component along the direction of the first target neighborhood based on the starting pixel until all pixels in the connected component have been traversed;

[0140] Based on the connected component threshold, the location of the connected component is determined from the updated target pixel coordinate matrix.

[0141] The communication bus mentioned above can be a Peripheral Component Interconnect (PCI) bus or an Extended Industry Standard Architecture (EISA) bus, etc. This communication bus can be divided into address bus, data bus, control bus, etc. For ease of illustration, only one thick line is used to represent it in the diagram, but this does not mean that there is only one bus or one type of bus.

[0142] The communication interface is used for communication between the aforementioned electronic devices and other devices.

[0143] The memory may include random access memory (RAM) or non-volatile memory (NVM), such as at least one disk storage device. Optionally, the memory may also be at least one storage device located remotely from the aforementioned processor.

[0144] The processors mentioned above can be general-purpose processors, including central processing units (CPUs), network processors (NPs), etc.; they can also be digital signal processors (DSPs), application-specific integrated circuits (ASICs), field-programmable gate arrays (FPGAs), or other programmable logic devices, discrete gate or transistor logic devices, or discrete hardware components.

[0145] The implementation methods and beneficial effects of the various components of the electronic device in the above embodiments for solving the problem can be found in [reference needed]. Figure 1 The steps in the illustrated embodiments are used to implement the electronic device. Therefore, the specific working process and beneficial effects of the electronic device provided in this application will not be repeated here.

[0146] In another embodiment provided in this application, a computer-readable storage medium is also provided, which stores instructions that, when executed on a computer, cause the computer to perform any of the contour rapid marking and search methods for multiple microbial images described in the above embodiments.

[0147] In another embodiment provided in this application, a computer program product containing instructions is also provided, which, when run on a computer, causes the computer to execute any of the contour rapid marking and search methods for various microbial images in the above embodiments.

[0148] Those skilled in the art will understand that the embodiments in this application can be provided as methods, systems, or computer program products. Therefore, the embodiments in this application can take the form of entirely hardware embodiments, entirely software embodiments, or embodiments combining software and hardware aspects. Furthermore, the embodiments in this application can take the form of computer program products implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.

[0149] This application describes embodiments of methods, apparatus (systems), and computer program products according to embodiments of this application with reference to flowchart illustrations and / or block diagrams. It will be understood that each block of the flowchart illustrations and / or block diagrams, and combinations of blocks in the flowchart illustrations and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, special-purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, generate instructions for implementing the flowchart illustrations. Figure 1 One or more processes and / or boxes Figure 1 A device that provides the functions specified in one or more boxes.

[0150] These computer program instructions may also be stored in a computer-readable storage medium that can direct a computer or other programmable data processing device to function in a particular manner, such that the instructions stored in the computer-readable storage medium produce an article of manufacture including instruction means, which are implemented in a process Figure 1 One or more processes and / or boxes Figure 1 The function specified in one or more boxes.

[0151] These computer program instructions may also be loaded onto a computer or other programmable data processing equipment to cause a series of operational steps to be performed on the computer or other programmable equipment to produce a computer-implemented process, thereby providing instructions that execute on the computer or other programmable equipment for implementing the process. Figure 1 One or more processes and / or boxes Figure 1 The steps of the function specified in one or more boxes.

[0152] Although preferred embodiments have been described in this application, those skilled in the art, upon learning the basic inventive concept, can make other changes and modifications to these embodiments. Therefore, the appended claims are intended to be interpreted as including the preferred embodiments as well as all changes and modifications falling within the scope of the embodiments of this application.

[0153] Obviously, those skilled in the art can make various modifications and variations to the embodiments of this application without departing from the spirit and scope of the embodiments of this application. Therefore, if these modifications and variations to the embodiments of this application fall within the scope of the claims in this application and their equivalents, then this application also intends to include these modifications and variations.

Claims

1. A method for fast contour labeling and searching for a plurality of microorganism images, characterized in that, The method includes: Obtain a target binary image and a target pixel coordinate matrix of the target binary image; wherein, the position of each element in the target pixel coordinate matrix corresponds one-to-one with the pixel coordinate of each pixel in the target binary image; the target binary image contains at least one connected component; each connected component corresponds to a unique connected component threshold; For any connected component, the starting pixel of the connected component is determined among the pixels within the connected component according to the configured search rules; wherein, the search rules include a search direction, a first target neighborhood direction, and a second target neighborhood direction; the first target neighborhood direction is determined based on the search direction; the second target neighborhood direction is determined based on the search direction. Based on the starting pixel, the connected region is searched along the first target neighborhood direction to obtain the first connected pixel of the starting pixel in the first target neighborhood direction; The pixel coordinates of the starting pixel and the first connected pixel are respectively updated to the value of the element position in the target pixel coordinate matrix corresponding to the pixel coordinates of the starting pixel and the first connected pixel, respectively, and the connected component threshold is updated to the connected component threshold. If the adjacent pixels of the starting pixel in the second target neighborhood direction are located in the connected region, then the adjacent pixels are taken as the second connected pixels. If the adjacent pixels of the first connected pixel in the second target neighborhood direction are located in the connected region, then the adjacent pixels of the first connected pixel in the second target neighborhood direction are taken as the second connected pixel. Using the second connected pixel as the new starting pixel, return to the execution step: search the connected region along the first target neighborhood direction based on the starting pixel until all pixels in the connected region have been traversed; Based on the connected component threshold, the position of the connected component is determined from the updated target pixel coordinate matrix.

2. The method of claim 1, wherein, Each matrix element corresponds to an initial element value; The search rules also include: the search starting point.

3. The method of claim 2, wherein, Based on the configured search rules, the starting pixel of the connected component is determined among the pixels within the connected component, including: Based on the search starting point and search direction, the target binary image is searched, and the first pixel found that is located in the connected component is taken as the initial pixel. If the pixel coordinates of the initial pixel point correspond to the same element position value in the target pixel coordinate matrix as the initial element value, then the initial pixel point is taken as the starting pixel point of the connected component.

4. The method as described in claim 1, characterized in that, Searching the connected components along the first target neighborhood direction based on the starting pixel to obtain the first connected pixel in the first target neighborhood direction includes: If the adjacent pixels of the starting pixel in the first target neighborhood direction are located within the connected region, then the adjacent pixels are taken as the first connected pixels. If the adjacent pixels of the first connected pixel point in the first target neighborhood direction are located within the connected region, then the adjacent pixels of the first connected pixel point in the first target neighborhood direction are taken as the first connected pixel point. Based on each first connected pixel, the first connected pixel of the starting pixel in the direction of the first target neighborhood is obtained.

5. The method as described in claim 1, characterized in that, The method further includes: Based on the pixel coordinates of each second connected pixel, generate a connected component search array; Using the second connected pixel as the new starting pixel includes: For any pixel coordinate in the connected component search array, the pixel point corresponding to the pixel coordinate is taken as the new starting pixel point.

6. The method as described in claim 1, characterized in that, Based on the connected component threshold, the location of the connected component is determined from the updated target pixel coordinate matrix, including: The matrix elements in the updated target pixel coordinate matrix whose element values ​​are the same as the connected component threshold are used as the target matrix elements of the connected component. Based on the element positions of each obtained target matrix element, the position of the connected component is determined.

Citation Information

Patent Citations

  • Contour projection method of tumour 3D anatomy structure in radiotherapy plan system

    CN101000689A

  • Method for determining external periphery outline of mammary gland

    CN101419712A