A layered visual recognition method and device, electronic equipment and storage medium

By performing grayscale processing and sliding window statistics on blood sample images, combined with peak finding and coordinate transformation, the accuracy problem of PBMC layer recognition was solved, and stable layer recognition under different lighting conditions was achieved.

CN120953196BActive Publication Date: 2026-11-24GUANGZHOU NAT LAB
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202511042691.6
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2025-07-28
Publication Date
2026-11-24
Estimated Expiration
2045-07-28

AI Technical Summary

Technical Problem

Existing technologies cannot accurately identify the color difference between the PBMC layer and the adjacent separation fluid/cell layer when separating peripheral blood mononuclear cells from blood samples, resulting in low identification accuracy. They are also susceptible to interference from light and container reflections, making it difficult to distinguish the PBMC layer from non-target cell residues.

Method used

By acquiring the target image, performing grayscale processing and sliding window traversal to count the average grayscale value, and utilizing peak finding and coordinate transformation, combined with bounding box matrix cropping and image rotation, accurate positioning and layer recognition of the PBMC layer can be achieved.

Benefits of technology

It achieves accurate identification of PBMC layers, reduces computational complexity, improves identification robustness and accuracy, and can stably output layer coordinate information under different lighting conditions.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120953196B_ABST
    Figure CN120953196B_ABST
Patent Text Reader

Abstract

This invention discloses a layered visual recognition method, apparatus, electronic device, and storage medium. The method includes: acquiring a target image; performing grayscale processing on the target image to obtain a grayscale image; using a sliding window to traverse and statistically analyze the average grayscale value of each image row in the grayscale image; performing peak lookup on the average grayscale value of all image rows to obtain the peak position; converting the peak position into the coordinate position of the target image; and determining layering information based on the coordinate position. This invention, targeting a target image, uses grayscale processing to traverse and statistically analyze the average grayscale value to construct a histogram, and finally uses peak lookup image processing to accurately obtain layer boundaries for visual recognition, such as blood sample layering. It can be widely applied in the field of image processing technology.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of image processing technology, and in particular to a layered visual recognition method, apparatus, electronic device, and storage medium. Background Technology

[0002] In experiments involving the extraction of peripheral blood mononuclear cells (PBMCs) from blood samples, the volume, morphology, and specific gravity of PBMCs differ from other peripheral blood cells. The difference in specific gravity between various blood cells and PBMCs can be used to separate them. Generally, Ficoll density gradient centrifugation is used. Red blood cells and granulocytes, with their higher specific gravity, sink to the bottom of the centrifuge tube after centrifugation, while lymphocytes and monocytes, with a specific gravity less than or equal to that of the separation medium, float on the surface after centrifugation. Traditionally, after stratified gradient centrifugation, PBMCs suspended in the separation medium are manually aspirated using a pipette. This method relies on human vision and experience, resulting in significant uncertainty and low accuracy in identification.

[0003] In the existing technologies, related technology 1 quantifies the sample liquid volume through grayscale processing and thickness recognition models, but does not involve cell layer-specific recognition; related technology 2 achieves gas / liquid or liquid / liquid phase boundary recognition through binarization and contour curve confidence screening, but cannot distinguish cell layers in solid-liquid mixtures; related technology 3 is based on RGB channel separation to locate serum liquid level height, but it is only applicable to transparent liquid phases and is not sensitive to the color characteristics of PBMC and the separation liquid mixture layer; related technology 4 identifies the boundary line between adjacent liquids through windows or spectra, but does not solve the problem of small color differences and morphological complexity of cell layers.

[0004] In summary, the color difference between the PBMC layer and the adjacent separation liquid / cell layer is small and the boundary is blurred. Existing grayscale, binarization, or contour recognition schemes (such as related technologies 1, 2, and 4) lose key color information and are difficult to locate accurately. Furthermore, the cell layer is in a semi-transparent suspended state, and traditional edge detection (such as related technology 3) is easily affected by light and container reflection, leading to misjudgment of the liquid surface position. Existing technologies lack quantitative analysis of the color characteristics of the cell layer and cannot distinguish between the PBMC layer and non-target cell residues (such as granulocytes). Summary of the Invention

[0005] This invention proposes a layered visual recognition method, device, electronic device, and storage medium, aiming to at least partially solve one of the technical problems in related technologies. This invention can accurately achieve layered visual recognition.

[0006] On one hand, embodiments of the present invention provide a layered visual recognition method, including: Acquire the target image; The target image is processed to obtain a grayscale image; Use a sliding window to iterate through and calculate the average grayscale value of each row in a grayscale image; Find the peak position by performing peak analysis on the average gray value of all image rows; The peak position is converted into the coordinate position of the target image, and the layering information is determined based on the coordinate position.

[0007] Optionally, before the step of performing grayscale processing on the target image, the method further includes the following steps: Get the selection matrix parameters; the selection matrix parameters include the coordinates of the top left corner of the selection matrix, the height of the selection matrix, and the width of the selection matrix; The region of interest is determined in the target image based on the bounding box matrix parameters, and the target image is then cropped based on the region of interest.

[0008] Optionally, before the step of performing grayscale processing on the target image, the method further includes the following steps: Obtain the orientation angle of the target image; Based on the angle difference between the orientation angle and the target angle, a coordinate rotation transformation is performed on the target image.

[0009] Optionally, the average grayscale value of each row in the grayscale image is statistically analyzed by traversing a sliding window, including the following steps: Initialize the image processing rows; Boundary determination is performed based on the boundary conditions of the image processing rows and the sliding window to obtain the window boundary of the sliding window in the image processing rows; the window boundary includes a first boundary and a second boundary. Based on the window boundaries and the image width of the grayscale image, the average grayscale value of the processed image row is obtained by summing and averaging the grayscale values ​​of all pixels in the grayscale image. The expression for the average grayscale value is:

[0010] In the formula, This represents the image width of a grayscale image; Indicates the first boundary; Indicates the second boundary; Indicates the first line, number The grayscale value of the pixels in the column; The image processing rows are incremented based on a preset row step size, and the process returns to the step of boundary determination based on the boundary conditions of the image processing rows and the sliding window, until the image processing rows have been traversed to the grayscale image.

[0011] Optionally, the sliding window is determined by the region between the first boundary and the second boundary; boundary determination is performed based on the boundary conditions of the processed image row and the sliding window to obtain the window boundary of the sliding window in the processed image row, including the following steps: The first determination value is obtained based on the difference between the processed image row and half the preset height of the sliding window; When the first judgment value is less than 0, the first boundary is set to 0; when the first judgment value is greater than or equal to 0, the first boundary is set to the first judgment value. The expression for the first boundary is:

[0012] In the formula, Indicates the first boundary; Indicates the processing of image rows; Indicates the preset height of the sliding window; The second determination value is obtained by summing the processed image row with half the preset height of the sliding window; When the second determination value is greater than the image height of the grayscale image, the second boundary is set to the image height; when the second determination value is less than or equal to the image height of the grayscale image, the second boundary is set to the second determination value. The expression for the second boundary is:

[0013] In the formula, Indicates the second boundary; This represents the image height of a grayscale image; Indicates the processing of image rows; Indicates the preset height of the sliding window; Specifically, when the first boundary is greater than or equal to the second boundary, the second boundary is set to the first boundary plus 1.

[0014] Optionally, peak location can be obtained by finding the peak position of the average gray value of all image rows, including the following steps: When the average gray value of the target image row is greater than or equal to the preset minimum peak height, and the average gray value of the adjacent image rows of the target image row is less than or equal to the average gray value of the target image row, the target image row is determined to be the initial peak. Based on preset constraints, all initial peak values ​​are filtered to obtain the target peak value; The peak position is determined based on the image row where each target peak is located.

[0015] Optionally, the target peak value is obtained by filtering all initial peak values ​​based on preset constraints, including at least one of the following steps: Based on the preset minimum spacing between adjacent peaks, spacing constraints are applied to all adjacent initial peaks; The expression for the spacing constraint is:

[0016] In the formula, and This represents two adjacent initial peak values; Indicates the minimum distance between adjacent peaks; Based on the preset minimum peak prominence, prominence constraints are applied to all initial peak values; The expression for the prominence constraint is as follows:

[0017] In the formula, Indicates the image row where the candidate peak is located The average gray value; Indicates the preset salience window length; Represents image rows The average gray value; This indicates the minimum prominence of the peak value.

[0018] Optionally, converting the peak location into coordinates of the target image includes the following steps: Use the horizontal center point of the image row where the peak position is located as the initial x-coordinate, and the peak position as the initial y-coordinate; Based on the initial x-coordinate and initial y-coordinate, the coordinate position is obtained through inverse coordinate rotation transformation.

[0019] Optionally, converting the peak location into coordinates of the target image includes the following steps: Use the horizontal center point of the image row where the peak position is located as the initial x-coordinate, and the peak position as the initial y-coordinate; The x-coordinate of the position is determined by the sum of the initial x-coordinate and the x-coordinate of the top left corner of the selection matrix. The ordinate of the coordinate position is determined by the sum of the initial ordinate and the ordinate of the top left corner of the selected matrix.

[0020] Optionally, the target image is acquired by a target camera; determining the layering information based on the coordinate position includes the following steps: Based on the intrinsic and extrinsic parameter matrices of the target camera, the coordinate position is converted into three-dimensional coordinates in the world coordinate system; The height information of each layer interface of the sample corresponding to the target image is determined based on three-dimensional coordinates.

[0021] On the other hand, embodiments of the present invention provide a layered visual recognition device, comprising: The image acquisition module is used to acquire the target image; The grayscale processing module is used to perform grayscale processing on the target image to obtain a grayscale image; The grayscale averaging module is used to iterate through and calculate the average grayscale value of each row in a grayscale image using a sliding window. The peak lookup module is used to find the peak position by analyzing the average gray value of all image rows. The layered analysis module is used to convert peak positions into coordinate positions in the target image and determine layered information based on the coordinate positions.

[0022] Optionally, the device also includes a selection and cropping module for performing the following operations: Get the selection matrix parameters; the selection matrix parameters include the coordinates of the top left corner of the selection matrix, the height of the selection matrix, and the width of the selection matrix; The region of interest is determined in the target image based on the bounding box matrix parameters, and the target image is then cropped based on the region of interest.

[0023] Optionally, the device also includes an image rotation module for performing the following operations: Obtain the orientation angle of the target image; Based on the angle difference between the orientation angle and the target angle, a coordinate rotation transformation is performed on the target image.

[0024] On the other hand, embodiments of the present invention provide an electronic device, including: a processor and a memory; the memory is used to store a program; the processor executes the program to implement the above-described hierarchical visual recognition method.

[0025] On the other hand, embodiments of the present invention provide a computer storage medium storing a processor-executable program, which, when executed by a processor, is used to implement the above-described layered visual recognition method.

[0026] This invention involves acquiring a target image; performing grayscale processing on the target image to obtain a grayscale image; using a sliding window to traverse and statistically analyze the average grayscale value of each row in the grayscale image; performing peak lookup on the average grayscale value of all rows to obtain the peak position; converting the peak position into the coordinate position of the target image; and determining the layering information based on the coordinate position. This invention, for a target image, through grayscale processing, then traversing and statistically analyzing the average grayscale value to construct a histogram, and finally using a peak lookup image processing method, can accurately obtain layer boundaries to achieve visual recognition, such as blood sample layering. Attached Figure Description

[0027] The accompanying drawings are provided to further understand the technical solutions of the present invention and constitute a part of the specification. They are used together with the embodiments of the present invention to explain the technical solutions of the present invention, and do not constitute a limitation on the technical solutions of the present invention.

[0028] Figure 1 This is a schematic diagram of an implementation environment for performing layered visual recognition according to an embodiment of the present invention; Figure 2 This is a flowchart illustrating a layered visual recognition method provided in an embodiment of the present invention. Figure 3 A schematic diagram illustrating an application implementation of the layered visual recognition method provided in this invention; Figure 4 This is a schematic diagram illustrating the unfolded process of step S300 provided in an embodiment of the present invention; Figure 5 A schematic diagram illustrating the unfolded process of step S400 provided in an embodiment of the present invention; Figure 6 This is a schematic diagram of the unfolding process for determining layered information based on coordinate position, provided in an embodiment of the present invention. Figure 7 A schematic diagram illustrating examples of blood samples before and after centrifugation provided in an embodiment of the present invention; Figure 8 A schematic diagram illustrating an example of a blood sample layered image provided in an embodiment of the present invention; Figure 9 This is a schematic diagram of the structure of a layered visual recognition device provided in an embodiment of the present invention; Figure 10 This is a schematic diagram of the structure of an electronic device provided in an embodiment of the present invention. Detailed Implementation

[0029] To make the objectives, technical solutions, and advantages of this invention clearer, the invention will be further described in detail below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative and not intended to limit the invention.

[0030] It should be noted that although functional modules are divided in the system diagram and the logical order is shown in the flowchart, in some cases, the steps shown or described may be performed in a different order than the module division in the system or the order in the flowchart. The terms "first / S100," "second / S200," etc., in the specification, claims, and the aforementioned figures are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence.

[0031] In this invention, the reference to "embodiment" means that a specific feature, structure, or characteristic described in connection with an embodiment may be included in at least one embodiment of the invention. The appearance of this phrase in various places in the specification does not necessarily refer to the same embodiment, nor is it a separate or alternative embodiment mutually exclusive with other embodiments. It will be explicitly and implicitly understood by those skilled in the art that the embodiments described in this invention can be combined with other embodiments.

[0032] like Figure 1 The diagram shown is a schematic representation of an implementation environment provided by an embodiment of the present invention. (Refer to...) Figure 1 The implementation environment includes at least one terminal 102 and a server 101. The terminal 102 and the server 101 can be connected via a network, either wirelessly or via a wired connection, to complete data transmission and exchange.

[0033] Server 101 can be a standalone physical server, a server cluster or distributed system consisting of multiple physical servers, or a cloud server that provides basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communication, middleware services, domain name services, security services, CDN (Content Delivery Network), and big data and artificial intelligence platforms.

[0034] Additionally, server 101 can also be a node server in a blockchain network. Blockchain is a novel application model of computer technologies such as distributed data storage, peer-to-peer transmission, consensus mechanisms, and encryption algorithms.

[0035] Terminal 102 can be a smartphone, tablet computer, laptop computer, desktop computer, smart speaker, smartwatch, etc., but is not limited to these. Terminal 102 and server 101 can be directly or indirectly connected via wired or wireless communication, and this embodiment of the invention does not impose any limitations.

[0036] Exemplary based on Figure 1 The implementation environment shown in this embodiment of the invention provides a layered visual recognition method. The following description uses the application of this layered visual recognition method in terminal 102 as an example. It can be understood that this layered visual recognition method can also be applied to server 101.

[0037] Reference Figure 2 , Figure 2 The flowchart illustrates a layered visual recognition method applied to a terminal according to an embodiment of the present invention. The executing entity of this layered visual recognition method can be any of the aforementioned computer devices (including servers or terminals). (Refer to...) Figure 2 The method includes the following steps: S100, Acquire the target image; The target image includes a layered image of a blood sample after gradient centrifugation; alternatively, the target image can be any other image with multiple layers requiring boundary identification between these layers. Subsequent embodiments will use a layered blood sample image as an example for illustration.

[0038] Exemplary examples, such as in some specific implementations, Figure 3 As shown, a camera 310 can be used to capture layered images of the blood sample 320 after gradient centrifugation. In some optional embodiments, a camera backlight 330 can be set to highlight the blood sample layer boundaries when the camera captures layered images, facilitating subsequent image processing. In addition, the camera light source can also be changed to a front light source or a combination of front and back light sources, etc.

[0039] In some embodiments, before the step of performing grayscale processing on the target image, the method may further include the following steps: obtaining bounding box matrix parameters; the bounding box matrix parameters include the coordinates of the upper left corner of the bounding box matrix, the height of the bounding box matrix, and the width of the bounding box matrix; determining the region of interest in the target image based on the bounding box matrix parameters, and cropping the target image according to the region of interest.

[0040] For example, in some specific implementations, in order to accurately locate the region to be identified for layering and avoid interference from other image regions, the region of interest (ROI) can be obtained based on the bounding rectangle parameter; that is, the region where layering height information needs to be identified. Specifically, the expression for the ROI region is:

[0041] in, Represents the original color image. This indicates the selected ROI image. Indicates the selection of the top left corner of the rectangle Coordinates (i.e., the vertical coordinate). Indicates the selection of the top left corner of the rectangle Coordinates (i.e., the x-coordinate) Indicates the height of the selected rectangle. This indicates the width of the rectangle to be selected.

[0042] It should be noted that the beneficial effects of this embodiment are mainly as follows: by cropping the target image to the ROI using frame selection matrix parameters (such as the coordinates of the upper left corner, height, and width), the amount of data for subsequent grayscale processing, sliding window traversal, and peak finding is significantly reduced, thus lowering computational complexity. This is especially beneficial when processing high-resolution images, saving processing time. Furthermore, the cropping step eliminates interference from irrelevant background or noise regions in the image, allowing sliding window statistics and peak finding to focus more intently on the key areas of the target object. This embodiment, through pre-cropping of the ROI, enhances the practicality and universality of the technical solution, while simultaneously addressing the redundant computation and noise sensitivity issues that may exist in the original solution.

[0043] It should be understood that if the target image initially includes only the region where layer height information needs to be identified, then there is no need to select and crop the image during image processing.

[0044] In some embodiments, before the step of performing grayscale processing on the target image, the method may further include the following steps: obtaining the orientation angle of the target image; and performing coordinate rotation transformation on the target image based on the angle difference between the orientation angle and the target angle.

[0045] For example, in some specific implementations, the orientation angle can be determined first based on a specific structure in the target image. For instance, taking a blood sample layered image as an example, the orientation angle can be determined by the bottom or opening of the test tube containing the blood sample. Then, the target image is subjected to coordinate rotation transformation based on a preset target angle (e.g., the test tube needs to be in a vertical direction with the opening facing upwards).

[0046] It should be noted that the beneficial effects of this application's embodiments are mainly as follows: by correcting the image to the target angle (such as a horizontal / vertical reference) through rotation transformation, it ensures that the image rows are strictly aligned with the actual layering direction of the target object, eliminating grayscale statistical errors caused by tilt, making the peak position more accurate, avoiding layering coordinate transformation errors, and improving recognition robustness. Furthermore, the corrected image makes the grayscale peaks more concentrated, reducing invalid statistical intervals in the sliding window traversal (e.g., a single row contains multiple levels of grayscale noise when tilted). This embodiment, through pre-geometric correction, solves the inherent defect of the original scheme being sensitive to image orientation, forming a collaborative mechanism of "angle correction → grayscale statistics → peak positioning," which can solve the problem of inaccurate layering recognition in tilted scenes. In addition, it should be noted that the advantage of this application's embodiments is that it does not limit the installation angle of the image acquisition device (e.g., a camera), allowing the image to be rotated as needed, regardless of whether the shooting direction is horizontal or vertical, to ensure that the image rows are strictly aligned with the actual layering direction of the target object.

[0047] It should be understood that because the angle at which the blood sample layering image acquisition device (such as a camera) captures the blood sample layering image may be at an angle to the vertical direction, the image needs to be rotated during image processing. If the installation structure is changed so that the angle of the captured blood sample layering image is the same as the vertical direction, then there is no need to rotate the image during image processing.

[0048] Specifically, taking the example of a camera mounting structure capturing a layered image of a blood sample at an angle of 90° to the vertical direction (i.e., an angle difference), the rotation coordinate transformation can achieve the following:

[0049] in, , Represents the coordinates of the rotated image. , Represents the coordinates of the image before rotation. This represents the height of the image before rotation. After rotation, the height and width of the image are swapped.

[0050] It should be understood that if the angle difference is other angles, the image can be rotated based on the principle of coordinate transformation, or directly based on the angle difference. The specific transformation method can be set according to actual needs, and the embodiments of the present invention do not impose any restrictions.

[0051] S200. Perform grayscale processing on the target image to obtain a grayscale image; For example, in some specific implementations, converting an RGB image to a grayscale image can be achieved as follows:

[0052] in The pixel grayscale value (rounded down). , , These are the red, green, and blue channel values ​​of the RGB image, respectively.

[0053] S300: Use a sliding window to iterate and count the average gray value of each row in the grayscale image; It should be noted that in some embodiments, such as Figure 4As shown, step S300 may include the following steps: S301, initializing the processed image row; S302, performing boundary determination based on the boundary conditions of the processed image row and the sliding window to obtain the window boundary of the sliding window in the processed image row; the window boundary includes a first boundary and a second boundary; S303, summing and averaging the gray values ​​of all pixels in the grayscale image in the processed image row according to the window boundary and the image width of the grayscale image to obtain the average gray value of the processed image row; S304, incrementing the processed image row based on a preset row step size, and returning to the step of performing boundary determination based on the boundary conditions of the processed image row and the sliding window until the processed image row has traversed the grayscale image.

[0054] For example, in some specific implementations, calculating the average grayscale value of each row or interval row in the image based on the sliding window can be specifically implemented as follows: ;in, and The first boundary and the second boundary are, in order. Indicates the image width. grayscale image matrix ( Indicates the first line, number The column's pixel grayscale value (range 0-255) can also be set. The step size for the rows where the average gray value needs to be calculated. A value of 1 indicates that the average gray value is calculated for each row.

[0055] It should be noted that the beneficial effects of the embodiments of this application are mainly as follows: by clearly defining the specific process of sliding window traversal and statistical average gray value, especially by introducing a boundary judgment mechanism and row step length control, the industrial applicability and algorithm reliability of the original technical solution are significantly improved; specifically, by dynamically constraining the window boundary to avoid out-of-bounds access, the accuracy of gray value statistics in the image edge region is ensured, and peak positioning shift is prevented due to noise introduced by invalid pixels; furthermore, by flexibly adjusting the traversal density by preset row step length, redundant calculations are greatly reduced while ensuring the recognition accuracy of key areas; the boundary conditions are adaptive to different image sizes, and the parameterized design of the row step length supports multi-scenario expansion (such as small step length for high-precision detection and large step length for real-time systems), enabling the algorithm to stably output layered coordinate information in complex industrial environments.

[0056] In some embodiments, the sliding window is determined by the area between a first boundary and a second boundary. Boundary determination based on the boundary conditions of the processed image row and the sliding window to obtain the window boundary of the sliding window in the processed image row may include the following steps: obtaining a first determination value based on the difference between the processed image row and half the preset height of the sliding window; setting the first boundary to 0 when the first determination value is less than 0, and setting the first boundary to the first determination value when the first determination value is greater than or equal to 0; obtaining a second determination value based on the sum of the processed image row and half the preset height of the sliding window; setting the second boundary to the image height when the second determination value is greater than the image height of the grayscale image, and setting the second boundary to the second determination value when the second determination value is less than or equal to the image height of the grayscale image; wherein, when the first boundary is greater than or equal to the second boundary, the second boundary is set to the first boundary plus 1.

[0057] For example, in some specific implementations, the window boundary and Defined as: , ; in, Indicates the current image row being processed. , Indicates the image height. Indicates the height of the sliding window; if ≥ Then forced .

[0058] In some optional implementations, to enhance the numerical effect of constructing a histogram from the statistically averaged gray values, the average gray values ​​collected in the previous steps can be inverted, and the inverted values ​​can then be used as the average gray value. The specific formula is as follows:

[0059] In the formula, This indicates the result of inverting the grayscale value.

[0060] It should be noted that the beneficial effects of the embodiments of this application are mainly as follows: by precisely defining the mathematical logic and fault-tolerance mechanism for sliding window boundary determination, the statistical failure problem caused by window overshooting in image edge regions is solved; specifically, based on the preset window height and image size, the window is always within the effective area of ​​the image through quantitative calculation of the first boundary and the second boundary (such as the difference / sum of half the height), avoiding grayscale statistical distortion caused by partial overshooting; when the first boundary is unexpectedly greater than or equal to the second boundary (such as in ultra-small images), the second boundary is forcibly set to the first boundary + 1, eliminating the risk of empty windows or negative windows and ensuring the stability of the algorithm in extreme scenarios; the boundary determination is compatible with any image size and window parameters, and can be adapted to different resolution devices without manual adjustment, making the layer recognition more reliable in complex environments.

[0061] S400: Find the peak position by performing peak search on the average gray value of all image rows; It should be noted that in some embodiments, such as Figure 5 As shown, step S400 may include the following steps: S401, when the average gray value of the target image row is greater than or equal to the preset minimum peak height, and the average gray value of the adjacent image rows of the target image row is less than or equal to the average gray value of the target image row, the target image row is determined to be an initial peak; S402, all initial peaks are filtered based on preset constraints to obtain target peaks; S403, the peak position is determined according to the image row where each target peak is located.

[0062] For example, in some specific implementations, the peak value and its corresponding width are found based on the average gray value of the image rows, wherein the following conditions are met: The average gray value at that location was identified as the peak value.

[0063] in, For image rows Average gray value, and Image rows in order and image lines Average gray value, This is the set minimum height for the peak value.

[0064] It should be noted that the beneficial effects of the embodiments of this application are mainly as follows: the accuracy and anti-interference ability of peak finding are significantly optimized by the dual screening mechanism (initial peak location + constraint condition filtering); specifically, low-amplitude noise is excluded by the minimum peak height threshold, and the gray level comparison of the neighborhood is combined with the gray level comparison of the target row (the gray level of the target row must be greater than or equal to the adjacent rows before and after) to ensure that only the real layer edges are captured, and to avoid misjudging random fluctuations as peaks; the initial peak is screened a second time by preset constraint conditions (such as peak spacing, intensity continuity, etc.) to eliminate false peaks caused by texture interference or local defects, thereby improving the robustness of scene recognition.

[0065] In some embodiments, the process of filtering all initial peaks based on preset constraints to obtain the target peak may include at least one of the following steps: setting a spacing constraint on all adjacent initial peaks based on a preset minimum spacing between adjacent peaks; and setting a prominence constraint on all initial peaks based on a preset minimum prominence.

[0066] For example, in some specific implementations, the identified peak values ​​need to satisfy spacing constraints:

[0067] in, , To identify two adjacent peaks, This is the minimum spacing between adjacent peak values.

[0068] The identified peaks need to meet the salience constraint:

[0069] in, To identify the average gray value of the row that is the peak, For the identified peak value, To calculate the window length for salience, Minimum saliency of peak value; The average gray value of a row that simultaneously meets the peak definition, spacing constraint, and prominence constraint is identified as a peak. At this point, the peak width... Defined as:

[0070] This can be determined through linear interpolation. (i.e., the right boundary of the sample to be identified in the target image) and (i.e., the left boundary of the sample to be identified in the target image), making , To calculate the relative height ratio of the peak width, The window length is used to calculate the salience. The peak point, To identify the average gray value of the row that is the peak, .

[0071] It should be noted that the beneficial effects of the embodiments of this application are mainly as follows: by introducing a dual screening mechanism of spacing constraints and salience constraints, the practicality of peak positioning is significantly improved; specifically, by presetting the minimum spacing between adjacent peaks to force separation of initial peaks that are too close, the peak clustering problem caused by texture repetition or local noise is solved, ensuring that the layer spacing conforms to physical reality; weak response pseudo-peaks are filtered by using the minimum salience threshold of the peak (i.e., the lowest relative height of the peak relative to the gray level of its neighboring area), avoiding misidentification of low contrast areas and improving the anti-interference ability of blurred boundaries; the two types of constraints can be enabled independently or in combination, flexibly adapting to different recognition needs, and reducing the false detection rate while ensuring the core layer positioning accuracy.

[0072] S500: Convert the peak position into the coordinate position of the target image, and determine the layering information based on the coordinate position; It should be noted that in some embodiments, when the target image has undergone coordinate rotation transformation in advance, converting the peak position into the coordinate position of the target image may include the following steps: taking the horizontal center point of the image row where the peak position is located as the initial horizontal coordinate and the peak position as the initial vertical coordinate; and obtaining the coordinate position by inverse coordinate rotation transformation based on the initial horizontal coordinate and the initial vertical coordinate.

[0073] It should be understood that if the target image acquired at the beginning is an image that only contains layered regions and the image orientation also meets the preset requirements, then coordinate synchronization is performed directly when converting the peak position to the coordinate position of the target image.

[0074] For example, in some specific implementations, when the target image has undergone coordinate rotation transformation in advance, the peak position identified can be transformed to the initial (before coordinate rotation transformation) target image. This can be achieved by the inverse transformation of coordinate rotation transformation based on the principle of coordinate transformation. Specifically, the coordinate transformation between the before and after images can be achieved by marking the coordinates of two key points in the target image, thereby converting the peak position into the coordinate position of the target image.

[0075] It should be noted that the beneficial effects of the embodiments of this application are mainly as follows: the closed-loop design of inverse coordinate rotation transformation significantly improves the accuracy of layer position mapping; specifically, the peak position (calculated based on the corrected image) is mapped back to the original image coordinate system through inverse rotation transformation, eliminating the coordinate offset introduced by the previous angle correction (such as the positioning deviation caused by the tilt shooting of the industrial camera), and ensuring that the final layer coordinates strictly correspond to the actual physical position; the horizontal center point of the peak row is used as the default horizontal coordinate, avoiding complex horizontal feature analysis, and reducing the computational complexity while ensuring accuracy.

[0076] It should be noted that in some embodiments, when the target image is pre-cropped based on the bounding box matrix parameters, converting the peak position into the coordinate position of the target image may include the following steps: taking the horizontal center point of the image row where the peak position is located as the initial horizontal coordinate, and taking the peak position as the initial vertical coordinate; determining the horizontal coordinate of the coordinate position by the sum of the initial horizontal coordinate and the horizontal coordinate of the upper left corner of the bounding box matrix; determining the vertical coordinate of the coordinate position by the sum of the initial vertical coordinate and the vertical coordinate of the upper left corner of the bounding box matrix.

[0077] For example, in some specific implementations, converting peak point coordinates to PBMC layered image (i.e., target image) coordinates can be achieved as follows:

[0078] in, , Indicates the selection of the top left corner of the rectangle , coordinate, , Represents the coordinates of the peak point in the PBMC layered image. , This indicates the coordinates of the peak point (i.e., the peak location).

[0079] It should be noted that the beneficial effects of the embodiments of this application are mainly as follows: by using the coordinate translation transformation mechanism of the bounding box matrix, the global mapping problem of layer coordinates after ROI (region of interest) cropping is efficiently solved; specifically, the peak position (calculated based on the cropped grayscale image) is superimposed with the coordinates of the upper left corner of the bounding box matrix to automatically compensate for the cropping offset, ensuring that the layer coordinates correspond to the actual physical position of the original image; the mapping is completed directly through coordinate addition (rather than reprocessing the original image), avoiding repeated grayscale statistics or peak search, and improving processing efficiency.

[0080] It should also be noted that the target image is acquired by the target camera; in some embodiments, such as Figure 6 As shown, determining layer information based on coordinate position may include the following steps: S511, converting the coordinate position into three-dimensional coordinates in the world coordinate system based on the intrinsic and extrinsic parameter matrices of the target camera; S512, determining the height information of each layer interface of the sample corresponding to the target image based on the three-dimensional coordinates.

[0081] For example, in some specific implementations, the coordinates (i.e., coordinate positions) of peak points in the PBMC layered image (i.e., the target image) are converted into three-dimensional coordinates in the world coordinate system:

[0082] in, , This represents the coordinates of the peak point in the PBMC layered image, where Z represents the distance along the Z-axis (depth). This represents the intrinsic parameter matrix of the camera. This represents the extrinsic parameter matrix of the camera. This indicates the world coordinate system position corresponding to the peak point. Ultimately, the height information of each liquid level can be obtained based on the calculated peak point coordinates.

[0083] It should be noted that the beneficial effects of the embodiments of this application are mainly as follows: by using camera calibration and three-dimensional coordinate transformation mechanism, image tomography is upgraded to physical space measurement; specifically, based on camera intrinsic parameters (focal length / distortion) and extrinsic parameters (pose), the image coordinates are converted into three-dimensional points in the world coordinate system, and the absolute height information of each layer interface of the sample is directly output, solving the problem that traditional solutions can only provide relative positions.

[0084] To explain in detail the principle of the technical solution of the present invention, the overall process of the present invention will be described below with reference to some specific embodiments. It is easy to understand that the following is an explanation of the technical principle of the present invention and should not be regarded as a limitation of the present invention.

[0085] First, it should be noted that, as Figure 7 As shown, experiments involving the extraction of peripheral blood mononuclear cells (PBMCs) from blood samples typically employ Ficoll density gradient centrifugation. Red blood cells and granulocytes, being denser, sink to the bottom of the centrifuge tube after centrifugation, while lymphocytes and monocytes, with a density less than or equal to that of the separation medium, float on the surface. However, the traditional method involves manually aspirating the PBMCs suspended in the separation medium using a pipette after stratified gradient centrifugation. This relies on human vision and experience, leading to significant uncertainty.

[0086] In view of the shortcomings of existing technologies, the present invention provides a layered visual recognition technical solution, such as... Figure 3 As shown, embodiments of the present invention can use a camera to capture layered images of blood samples after gradient centrifugation; specifically, a backlight can be set for the camera to highlight the boundaries between blood sample layers when capturing layered images, facilitating subsequent image processing. Furthermore, the camera light source can also be changed to a front light source or a combination of front and back light sources, etc., based on various light source configurations. Figure 3 The application scenarios shown can be implemented through the following process: 1. Use a camera to acquire layered images of the PBMC after gradient eccentrication, such as... Figure 8 As shown.

[0087] 2. Obtain the ROI (Region of Interest) of the image based on the bounding rectangle parameters; that is, the region where layered height information needs to be identified.

[0088] in, Represents the original color image. This indicates the selected ROI image. Indicates the selection of the top left corner of the rectangle coordinate, Indicates the selection of the top left corner of the rectangle coordinate, Indicates the height of the selected rectangle. This indicates the width of the rectangle to be selected.

[0089] 3. Rotate the ROI image 90° clockwise, and the coordinate transformation is as follows:

[0090] in, , Represents the coordinates of the rotated image. , Represents the coordinates of the image before rotation. This represents the height of the image before rotation. After rotation, the height and width of the image are swapped.

[0091] It should be noted that because the camera mounting structure captures blood sample layered images at a 90° angle to the vertical direction, image rotation is required during image processing. If the camera mounting structure is changed so that the captured blood sample layered images are at the same angle to the vertical direction, image rotation is not required during image processing.

[0092] 4. Convert an RGB image to a grayscale image:

[0093] in The pixel grayscale value (rounded down). , , These are the red, green, and blue channel values ​​of the RGB image, respectively.

[0094] 5. Calculate the average gray value of each row or every other row in the image based on the sliding window, and then invert the gray values:

[0095] Among them, window boundaries and Defined as ,

[0096] like ≥ Then forced .

[0097] grayscale image matrix ( Indicates the first line, number The column's pixel grayscale value ranges from 0 to 255. The step size is the row where the average gray value needs to be calculated. A value of 1 indicates that the average gray value is calculated for each row. The height of the sliding window; , These represent the height and width of the image, respectively.

[0098] 6. Find the peak value and its corresponding width based on the average gray value of the image rows, where the following conditions are met: The average gray value at that location was identified as the peak value.

[0099] in, For image rows Average gray value, and Image rows in order and image lines Average gray value, The minimum height of the set peak value; The identified peaks need to satisfy the spacing constraint:

[0100] in , For the identified peak value, This is the minimum spacing between adjacent peak values.

[0101] The identified peaks need to meet the salience constraint:

[0102] in To identify the average gray value of the row that is the peak, For the identified peak value, The window length is used to calculate the salience. Minimum saliency of peak value; The average gray value of a row that simultaneously meets the peak definition, spacing constraint, and prominence constraint is identified as a peak. At this point, the peak width... Defined as:

[0103] This is determined through linear interpolation. and , making , To calculate the relative height ratio of the peak width, The window length is used to calculate the salience. The peak point, To identify the average gray value of the row that is the peak, .

[0104] 7. Rotate and transform the obtained peak points to their coordinates in the original ROI image:

[0105] in, The peak point, This represents the width of the image before rotation. , This indicates the coordinates of the peak point in the original ROI image.

[0106] 8. Convert the peak point coordinates in the ROI image to PBMC layered image coordinates:

[0107] in, , Indicates the selection of the top left corner of the rectangle , coordinate, , This indicates the coordinates of the peak point in the PBMC layered image.

[0108] 9. Convert the peak point coordinates in the PBMC layered image to three-dimensional coordinates in the world coordinate system:

[0109] in, , This represents the coordinates of the peak point in the PBMC layered image, where Z represents the distance along the Z-axis (depth). This represents the intrinsic parameter matrix of the camera. This represents the extrinsic parameter matrix of the camera. This indicates the world coordinate system position corresponding to the peak point.

[0110] 10. The height information of each liquid level can be obtained based on the calculated peak point coordinates.

[0111] In summary, the embodiments of the present invention can be applied to blood sample stratification identification. Specifically, by acquiring the stratified images of PBMCs after gradient centrifugation, the liquid stratification boundaries are obtained through image processing methods such as grayscale processing, histogram calculation, and peak finding. Combined with the intrinsic and extrinsic parameter matrices obtained from camera calibration, the position information of the liquid stratification boundaries in the world coordinate system can be determined, thereby realizing the automated extraction of the required liquid samples.

[0112] On the other hand, such as Figure 9 As shown, an embodiment of the present invention provides a layered visual recognition device 900, comprising: Image acquisition module 901 is used to acquire target images; The grayscale processing module 902 is used to perform grayscale processing on the target image to obtain a grayscale image; The grayscale averaging module 903 is used to traverse and count the average grayscale value of each row in a grayscale image using a sliding window. Peak lookup module 904 is used to find the peak position by searching the average gray value of all image rows. The layering analysis module 905 is used to convert the peak position into the coordinate position of the target image and determine the layering information based on the coordinate position.

[0113] In some embodiments, the apparatus may further include a selection and cropping module for performing the following operations: Get the selection matrix parameters; the selection matrix parameters include the coordinates of the top left corner of the selection matrix, the height of the selection matrix, and the width of the selection matrix; The region of interest is determined in the target image based on the bounding box matrix parameters, and the target image is then cropped based on the region of interest.

[0114] In some embodiments, the apparatus further includes an image rotation module for performing the following operations: Obtain the orientation angle of the target image; Based on the angle difference between the orientation angle and the target angle, a coordinate rotation transformation is performed on the target image.

[0115] The content of the method embodiments of the present invention is applicable to the device embodiments. The specific functions implemented by the device embodiments are the same as those of the above method embodiments, and the beneficial effects achieved are also the same as those achieved by the above methods.

[0116] On the other hand, embodiments of the present invention also provide an electronic device, which includes a memory and a processor. The memory stores a computer program, and the processor executes the computer program to implement the above-described method. This electronic device can be any smart terminal, including tablet computers, in-vehicle computers, etc.

[0117] It is understood that the content of the above method embodiments is applicable to this device embodiment. The specific functions implemented by this device embodiment are the same as those of the above method embodiments, and the beneficial effects achieved are also the same as those achieved by the above method embodiments.

[0118] like Figure 10 As shown, Figure 10 This illustration shows a specific example of the hardware structure of an electronic device 1000 according to one embodiment. The electronic device 1000 includes: The processor 1001 can be implemented using a general-purpose CPU (Central Processing Unit), microprocessor, application-specific integrated circuit (ASIC), or one or more integrated circuits, and is used to execute relevant programs to implement the technical solutions provided in the embodiments of the present invention. The memory 1002 can be implemented as a read-only memory (ROM), a static storage device, a dynamic storage device, or a random access memory (RAM). The memory 1002 can store the operating system and other application programs. When the technical solutions provided in the embodiments of this specification are implemented through software or firmware, the relevant program code is stored in the memory 1002 and is called and executed by the processor 1001. Input / output interface 1003 is used to implement information input and output; The communication interface 1004 is used to enable communication and interaction between this device and other devices. Communication can be achieved through wired means (such as USB, network cable, etc.) or wireless means (such as mobile network, WIFI, Bluetooth, etc.). Bus 1005 transmits information between various components of the device (e.g., processor 1001, memory 1002, input / output interface 1003, and communication interface 1004); The processor 1001, memory 1002, input / output interface 1003 and communication interface 1004 are connected to each other within the device via bus 1005.

[0119] The electronic device embodiments described above are merely illustrative. The units described as separate components may or may not be physically separate; that is, they may be located in one place or distributed across multiple network units. Some or all of the modules can be selected to achieve the purpose of this embodiment according to actual needs.

[0120] The content of the method embodiments of the present invention is applicable to the embodiments of the present electronic device. The specific functions implemented by the embodiments of the present electronic device are the same as those of the above method embodiments, and the beneficial effects achieved are also the same as those achieved by the above methods.

[0121] Another aspect of this invention provides a computer-readable storage medium storing a program that is executed by a processor to implement the aforementioned method.

[0122] It should be noted that the computer-readable medium shown in the embodiments of the present invention can be a computer-readable signal medium or a computer-readable storage medium, or any combination thereof. A computer-readable storage medium can be, for example,—but not limited to—an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination thereof. More specific examples of a computer-readable storage medium may include, but are not limited to: an electrical connection having one or more wires, a portable computer disk, a hard disk, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM), flash memory, optical fiber, portable compact disc read-only memory (CD to ROM), optical storage devices, magnetic storage devices, or any suitable combination thereof. In the present invention, a computer-readable storage medium can be any tangible medium containing or storing a program that can be used by or in conjunction with an instruction execution system, apparatus, or device. In the present invention, a computer-readable signal medium can include a data signal propagated in baseband or as part of a carrier wave, wherein computer-readable program code is carried. Such transmitted data signals can take various forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination thereof. The computer-readable signal medium can also be any computer-readable medium other than a computer-readable storage medium, which can send, propagate, or transmit a program for use by or in connection with an instruction execution system, apparatus, or device. The program code contained on the computer-readable medium can be transmitted using any suitable medium, including but not limited to wireless, wired, etc., or any suitable combination thereof.

[0123] The content of the method embodiments of the present invention is applicable to the computer-readable storage medium embodiments. The specific functions implemented by the computer-readable storage medium embodiments are the same as those of the above method embodiments, and the beneficial effects achieved are also the same as those achieved by the above methods.

[0124] This invention also discloses a computer program product or computer program, which includes computer instructions stored in a computer-readable storage medium. A processor of a computer device can read the computer instructions from the computer-readable storage medium and execute the computer instructions, causing the computer device to perform the aforementioned method.

[0125] The flowcharts and block diagrams in the accompanying drawings illustrate the architecture, functionality, and operation of possible implementations of systems, methods, and computer program products according to various embodiments of the present invention. In this regard, each block in a flowchart or block diagram may represent a module, segment, or portion of code containing one or more executable instructions for implementing a specified logical function. It should also be noted that in some alternative implementations, the functions indicated in the blocks may occur in a different order than those indicated in the drawings. For example, two consecutively indicated blocks may actually be executed substantially in parallel, and they may sometimes be executed in reverse order, depending on the functions involved. It should also be noted that each block in a block diagram or flowchart, and combinations of blocks in a block diagram or flowchart, may be implemented using a dedicated hardware-based system that performs the specified function or operation, or using a combination of dedicated hardware and computer instructions.

[0126] It should be noted that although several modules for the device used to perform actions have been mentioned in the detailed description above, this division is not mandatory. In fact, according to embodiments of the present invention, the features and functions of two or more modules or units described above can be embodied in one module or unit. Conversely, the features and functions of one module or unit described above can be further divided and embodied by multiple modules or units.

[0127] Through the above description of the embodiments, those skilled in the art will readily understand that the exemplary embodiments described herein can be implemented by software or by combining software with necessary hardware. Therefore, the technical solutions according to the embodiments of the present invention can be embodied in the form of a software product, which can be stored in a non-volatile storage medium (such as a CD-ROM, USB flash drive, portable hard drive, etc.) or on a network, including several instructions to cause a computing device (such as a personal computer, server, touch terminal, or network device, etc.) to execute the method according to the embodiments of the present invention.

[0128] In some alternative embodiments, the functions / operations mentioned in the block diagrams may not occur in the order shown in the operation diagrams. For example, depending on the functions / operations involved, two consecutively shown blocks may actually be executed substantially simultaneously, or the blocks may sometimes be executed in reverse order. Furthermore, the embodiments presented and described in the flowcharts of this invention are provided by way of example to provide a more comprehensive understanding of the technology. The disclosed methods are not limited to the operations and logic flows presented in this invention. Alternative embodiments are contemplated, in which the order of various operations is changed and sub-operations described as part of a larger operation are executed independently.

[0129] Furthermore, although the invention has been described in the context of functional modules, it should be understood that, unless otherwise stated, one or more of the functions and / or features may be integrated into a single physical device and / or software module, or one or more functions and / or features may be implemented in a separate physical device or software module. It is also understood that a detailed discussion of the actual implementation of each module is unnecessary for understanding the invention. Rather, given the properties, functions, and internal relationships of the various functional modules in the apparatus disclosed herein, the actual implementation of the module will be understood within the scope of conventional skill of an engineer. Therefore, those skilled in the art can implement the invention as set forth in the claims using ordinary techniques without excessive experimentation. It is also understood that the specific concepts disclosed are merely illustrative and not intended to limit the scope of the invention, which is determined by the full scope of the appended claims and their equivalents.

[0130] If a function is implemented as a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of this invention, or the part that contributes to the prior art, or a part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods of the various embodiments of this invention. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.

[0131] The logic and / or steps represented in the flowchart or otherwise described herein, for example, can be considered as a sequenced list of executable instructions for implementing logical functions, and can be embodied in any computer-readable medium for use by, or in conjunction with, an instruction execution means, apparatus, or device (such as a computer-based device, a processor-including device, or other means that can fetch and execute instructions from, or in conjunction with, an instruction execution means, apparatus, or device). For the purposes of this specification, "computer-readable medium" can be any means that can contain, store, communicate, propagate, or transmit programs for use by, or in conjunction with, an instruction execution means, apparatus, or device.

[0132] More specific examples (a non-exhaustive list) of computer-readable media include: electrical connections (electronic devices) having one or more wires, portable computer disk drives (magnetic devices), random access memory (RAM), read-only memory (ROM), erasable and editable read-only memory (EPROM or flash memory), fiber optic devices, and portable optical disc read-only memory (CDROM). Furthermore, computer-readable media can even be paper or other suitable media on which programs can be printed, because programs can be obtained electronically, for example, by optically scanning the paper or other medium, followed by editing, interpreting, or otherwise processing as necessary, and then stored in computer memory.

[0133] It should be understood that various parts of the present invention can be implemented in hardware, software, firmware, or a combination thereof. In the above embodiments, multiple steps or methods can be implemented in software or firmware stored in memory and executed by a suitable instruction execution device. For example, if implemented in hardware, as in another embodiment, it can be implemented using any one or a combination of the following techniques known in the art: discrete logic circuits having logic gates for implementing logical functions on data signals, application-specific integrated circuits (ASICs) having suitable combinational logic gates, programmable gate arrays (PGAs), field-programmable gate arrays (FPGAs), etc.

[0134] In the description of this specification, references to terms such as "one embodiment," "some embodiments," "example," "specific example," or "some examples," etc., indicate that a specific feature, structure, material, or characteristic described in connection with that embodiment or example is included in at least one embodiment or example of the invention. In this specification, the illustrative expressions of the above terms do not necessarily refer to the same embodiment or example. Furthermore, the specific features, structures, materials, or characteristics described may be combined in any suitable manner in one or more embodiments or examples.

[0135] Although embodiments of the invention have been shown and described, those skilled in the art will understand that various changes, modifications, substitutions and alterations can be made to these embodiments without departing from the principles and spirit of the invention, the scope of which is defined by the claims and their equivalents.

[0136] The above is a detailed description of the preferred embodiments of the present invention. However, the present invention is not limited to the embodiments. Those skilled in the art can make various equivalent modifications or substitutions without departing from the spirit of the present invention. All such equivalent modifications or substitutions are included within the scope defined by the claims of the present invention.

Claims

1. A layered visual recognition method, characterized in that, Includes the following steps: Acquire the target image; The target image is processed to obtain a grayscale image; The average grayscale value of each row in the grayscale image is statistically analyzed by using a sliding window to traverse and count the total grayscale value. Peak location is obtained by performing peak lookup on the average gray value of all the image rows; The peak position is converted into the coordinate position of the target image, and the layering information is determined based on the coordinate position; The step of using a sliding window to traverse and calculate the average grayscale value of each row in the grayscale image includes the following steps: Initialize the image processing rows; Boundary determination is performed based on the boundary conditions of the processed image row and the sliding window to obtain the window boundary of the sliding window in the processed image row; the window boundary includes a first boundary and a second boundary. Based on the window boundary and the image width of the grayscale image, the grayscale values ​​of all pixels in the grayscale image of the processed image row are summed and averaged to obtain the average grayscale value of the processed image row; The image processing row is incremented based on a preset row step size, and the process returns to the step of boundary determination based on the boundary conditions of the image processing row and the sliding window, until the image processing row has traversed the grayscale image. The sliding window is defined by the region between the first boundary and the second boundary; the boundary determination based on the boundary conditions of the processed image row and the sliding window to obtain the window boundary of the sliding window in the processed image row includes the following steps: A first determination value is obtained based on the difference between the processed image row and half the preset height of the sliding window; When the first determination value is less than 0, the first boundary is set to 0; when the first determination value is greater than or equal to 0, the first boundary is set to the first determination value. A second determination value is obtained based on the sum of the processed image row and half the preset height of the sliding window; When the second determination value is greater than the image height of the grayscale image, the second boundary is set to the image height; when the second determination value is less than or equal to the image height of the grayscale image, the second boundary is set to the second determination value. Wherein, when the first boundary is greater than or equal to the second boundary, the second boundary is set to the first boundary plus 1; The step of finding the peak position by searching the average gray value of all the image rows includes the following steps: When the average gray value of the target image row is greater than or equal to the preset minimum peak height, and the average gray value of the adjacent image rows of the target image row is less than or equal to the average gray value of the target image row, the target image row is determined to be the initial peak. Based on preset constraints, all the initial peak values ​​are filtered to obtain the target peak value; The peak position is determined based on the image row where each of the target peaks is located; The step of filtering all the initial peak values ​​based on preset constraints to obtain the target peak value includes at least one of the following steps: Based on a preset minimum spacing between adjacent peaks, spacing constraints are applied to all adjacent initial peaks. The expression for the spacing constraint is as follows: In the formula, and This represents two adjacent initial peak values; Indicates the minimum distance between adjacent peaks; Based on the preset minimum peak prominence, prominence constraints are applied to all the initial peak values; The expression for the prominence constraint is as follows: In the formula, Indicates the image row where the candidate peak is located The average gray value; Indicates the preset salience window length; Represents image rows The average gray value; This indicates the minimum prominence of the peak value.

2. The layered visual recognition method according to claim 1, characterized in that, Before the step of performing grayscale processing on the target image, the method further includes the following steps: Obtain the selection matrix parameters; the selection matrix parameters include the coordinates of the top left corner of the selection matrix, the height of the selection matrix, and the width of the selection matrix; Based on the bounding box matrix parameters, a region of interest is determined in the target image, and the target image is cropped according to the region of interest.

3. The layered visual recognition method according to claim 1, characterized in that, Before the step of performing grayscale processing on the target image, the method further includes the following steps: Obtain the orientation angle of the target image; Based on the angle difference between the orientation angle and the target angle, the target image is subjected to coordinate rotation transformation.

4. The layered visual recognition method according to claim 1, characterized in that, The expression for the average gray value is: In the formula, This represents the image width of a grayscale image; Indicates the first boundary; Indicates the second boundary; Indicates the first line, number The grayscale value of the pixels in the column.

5. The layered visual recognition method according to claim 1, characterized in that, The expression for the first boundary is: In the formula, Indicates the first boundary; Indicates the processing of image rows; Indicates the preset height of the sliding window; The expression for the second boundary is: In the formula, Indicates the second boundary; This represents the image height of a grayscale image; Indicates the processing of image rows; This indicates the preset height of the sliding window.

6. The layered visual recognition method according to claim 3, characterized in that, Converting the peak position into the coordinate position of the target image includes the following steps: Use the horizontal center point of the image row where the peak position is located as the initial horizontal coordinate, and the peak position as the initial vertical coordinate; Based on the initial x-coordinate and the initial y-coordinate, the coordinate position is obtained through the inverse coordinate rotation transformation.

7. The layered visual recognition method according to claim 2, characterized in that, Converting the peak position into the coordinate position of the target image includes the following steps: Use the horizontal center point of the image row where the peak position is located as the initial horizontal coordinate, and the peak position as the initial vertical coordinate; The x-coordinate of the coordinate position is determined by the sum of the initial x-coordinate and the x-coordinate of the upper left corner of the selection matrix; The ordinate of the coordinate position is determined by the sum of the initial ordinate and the ordinate of the top left corner of the selection matrix.

8. The layered visual recognition method according to claim 1, characterized in that, The target image is acquired by a target camera; determining the layering information based on the coordinate position includes the following steps: Based on the intrinsic and extrinsic parameter matrices of the target camera, the coordinate position is converted into three-dimensional coordinates in the world coordinate system; The height information of each layer interface of the sample corresponding to the target image is determined based on the three-dimensional coordinates.

9. A layered visual recognition device, characterized in that, include: The image acquisition module is used to acquire the target image; A grayscale processing module is used to perform grayscale processing on the target image to obtain a grayscale image; The grayscale averaging module is used to traverse and calculate the average grayscale value of each row in the grayscale image using a sliding window. The peak lookup module is used to perform peak lookup on the average gray value of all the image rows to obtain the peak position; The layering analysis module is used to convert the peak position into the coordinate position of the target image, and determine the layering information based on the coordinate position; The step of using a sliding window to traverse and calculate the average grayscale value of each row in the grayscale image includes the following steps: Initialize the image processing rows; Boundary determination is performed based on the boundary conditions of the processed image row and the sliding window to obtain the window boundary of the sliding window in the processed image row; the window boundary includes a first boundary and a second boundary. Based on the window boundary and the image width of the grayscale image, the grayscale values ​​of all pixels in the grayscale image of the processed image row are summed and averaged to obtain the average grayscale value of the processed image row; The image processing row is incremented based on a preset row step size, and the process returns to the step of boundary determination based on the boundary conditions of the image processing row and the sliding window, until the image processing row has traversed the grayscale image. The sliding window is defined by the region between the first boundary and the second boundary; the boundary determination based on the boundary conditions of the processed image row and the sliding window to obtain the window boundary of the sliding window in the processed image row includes the following steps: A first determination value is obtained based on the difference between the processed image row and half the preset height of the sliding window; When the first determination value is less than 0, the first boundary is set to 0; when the first determination value is greater than or equal to 0, the first boundary is set to the first determination value. A second determination value is obtained based on the sum of the processed image row and half the preset height of the sliding window; When the second determination value is greater than the image height of the grayscale image, the second boundary is set to the image height; when the second determination value is less than or equal to the image height of the grayscale image, the second boundary is set to the second determination value. Wherein, when the first boundary is greater than or equal to the second boundary, the second boundary is set to the first boundary plus 1; The step of finding the peak position by searching the average gray value of all the image rows includes the following steps: When the average gray value of the target image row is greater than or equal to the preset minimum peak height, and the average gray value of the adjacent image rows of the target image row is less than or equal to the average gray value of the target image row, the target image row is determined to be the initial peak. Based on preset constraints, all the initial peak values ​​are filtered to obtain the target peak value; The peak position is determined based on the image row where each of the target peaks is located; The step of filtering all the initial peak values ​​based on preset constraints to obtain the target peak value includes at least one of the following steps: Based on a preset minimum spacing between adjacent peaks, spacing constraints are applied to all adjacent initial peaks. The expression for the spacing constraint is as follows: In the formula, and This represents two adjacent initial peak values; Indicates the minimum distance between adjacent peaks; Based on the preset minimum peak prominence, prominence constraints are applied to all the initial peak values; The expression for the prominence constraint is as follows: In the formula, Indicates the image row where the candidate peak is located The average gray value; Indicates the preset salience window length; Represents image rows The average gray value; This indicates the minimum prominence of the peak value.

10. An electronic device, characterized in that, Including the processor and memory; The memory is used to store programs; The processor executes the program to implement the method as described in any one of claims 1 to 8.

11. A computer storage medium storing a processor-executable program, which, when executed by a processor, is used to implement the method as described in any one of claims 1 to 8.

Citation Information

Patent Citations

  • Insoluble liquid interface determining method and device

    CN107784644A