Slide detection method based on slide morphology and applications thereof
Patent Information
- Application Number
- CN202410704297.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-06-03
- Publication Date
- 2026-08-21
- Estimated Expiration
- 2044-06-03
AI Technical Summary
[0007]本申请实施例提供了一种基于玻片形态学的玻片检测方法及其应用,针对目前技术存在的拥有较多的复杂冗余的操作步骤、检测耗时长以及存储空间要求高等问题
[0019] The main contributions and innovations of this invention are as follows: 1. Compared with the prior art, this invention proposes a novel slide detection method. By combining grayscale image preprocessing, morphological edge detection and multi-level flag bit logic judgment, it realizes automatic and efficient identification of slide type and existence state without relying on a large number of template matching, which greatly improves the robustness and adaptability of the identification system.
Smart Images

Figure CN118628450B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the fields of computer vision and pattern recognition technology, and in particular to a slide detection method based on slide morphology and its application. Background Technology
[0002] In today's medical and scientific research fields, slide scanning and image digitization technologies are gradually becoming industry standards. This shift has greatly facilitated the long-term preservation and efficient sharing of pathological and biomedical research and teaching materials. Traditional slide storage not only occupies a large amount of physical space but also faces the risk of sample degradation due to environmental factors. The widespread application of digital slides effectively solves these problems, ensuring the long-term stability and accessibility of sample information.
[0003] However, in the process of automating the processing and recognition of slide images, existing technologies mainly rely on template matching methods. Although this method has some practicality, its limitations are becoming increasingly apparent. First, template matching technology lacks robustness; even images of the same slide taken at different times or using different devices may yield vastly different matching results. This instability often stems from factors such as lighting conditions, slight changes in camera position and angle, making it difficult to guarantee recognition accuracy.
[0004] Secondly, with the increasing diversity of slide types and samples, template matching strategies require the pre-fabrication and storage of templates for each new type of slide. This not only significantly increases the maintenance cost of the database but also places higher demands on storage resources. Over time, the massive template library not only occupies a large amount of storage space but also significantly increases processing time during matching calculations, affecting the overall system's response speed and efficiency.
[0005] Furthermore, the cumbersome workflow of frequently updating and maintaining the template library limits the system's flexibility and adaptability. This is especially true when facing sudden illnesses or novel biological samples, where the need for rapid response and integration of new templates becomes particularly urgent, and traditional template matching mechanisms fall short in this regard.
[0006] In conclusion, while slide digitization has brought innovation to scientific research and clinical practice, the accompanying image recognition technology, especially template matching-based methods, has significant limitations in practical applications, which have restricted work efficiency and system scalability. There is an urgent need for a more advanced, intelligent, and efficient slide recognition solution to meet the growing and diversified needs. Summary of the Invention
[0007] This application provides a slide detection method based on slide morphology and its application, addressing the problems of current technologies, such as numerous complex and redundant operation steps, long detection time, and high storage space requirements.
[0008] The core technology of this invention mainly utilizes grayscale image preprocessing, morphological edge detection, and multi-level flag bit logic judgment to achieve efficient and automatic identification of slide type and existence state, overcoming the limitations of traditional template matching technology.
[0009] In a first aspect, this application provides a slide detection method based on slide morphology, the method comprising the following steps: S00. Obtain the positioning image and slide image, and perform preprocessing using grayscale image reading and image reduction. Meanwhile, define flag bits 1, 2, 3, and 4, with the default value being false. Flag 1 indicates whether there is an edge to the slide; flag 2 indicates whether the area of the white region in the upper half of the slide is greater than a set threshold; flag 3 indicates whether the area of the white region in the lower half of the slide is greater than a set threshold; and flag 4 indicates whether the area of the white regions in both the upper and lower parts of the slide is greater than a set threshold. S10. Extract the slide edge from the slide image and set the flag bit 1 to true; Meanwhile, the positioning image is cropped and evenly divided into upper and lower parts, then binarized. White areas exceeding the grayscale threshold are saved, and the remaining areas are set to black. The area of the saved white areas is calculated. If the white area in the upper half is greater than the set threshold, then flag 2 is set to true; if the white area in the lower half is greater than the set threshold, then flag 3 is set to true; if the white area in both the upper and lower halves is greater than the set threshold, then flag 4 is set to true. S20. Determine the status of flag 1; If true, check the status of flags 2 and 3; if false, check the status of flag 4. S30. If flag 2 is true and flag 3 is false, return the result that there is only one small slide at the top of the tray; if flag 2 is false and flag 3 is true, return the result that there is only one small slide at the bottom of the tray; if both flags 2 and 3 are true, return the result that there is one small slide at the top and one at the bottom of the tray. If flag 4 is true, the result is returned that there is a large glass slide on the tray; if flag 4 is false, further image processing is performed to determine whether there is no tray on the turntable or there is a tray but no glass slide on the tray.
[0010] Furthermore, in step S10, the specific steps for extracting the slide edge from the slide image and setting the flag bit 1 to true are as follows: The slide image was subjected to morphological transformation black hat processing to extract the slide edges, and then Gaussian blur was used for smoothing. Define a filter and combine it with the Scharr and Laplacian operators to highlight edges, then normalize the obtained image to get the gradient image result; The edge image of the slide is obtained by subtracting the calculation result from the gradient image through the opening operation, and the mean and standard deviation of the edge image of the slide are calculated. Binarize the image of the slide edge based on the mean and standard deviation results; Detect straight lines in the binarized image. If the number of straight lines is greater than 0, it is considered that the edge of the glass slide has been detected, and the flag bit 1 is set to true.
[0011] Furthermore, in step S10, straight lines in the binarized image are detected by Hough line transform.
[0012] Furthermore, in step S10, the region of interest is extracted from the location map and then split into upper and lower parts from the middle.
[0013] Furthermore, in step S10, the grayscale threshold is 240, and the set threshold is 260000.
[0014] Furthermore, in step S30, the specific steps for further image processing are as follows: Top-capping is applied to the slide image to extract dark objects, and Gaussian blur is used to smooth the slide image. The Laplacian operator is used to calculate the Laplacian gradient of the slide image to highlight the edges, thus obtaining a gradient image. The gradient image is added to the edge image to obtain the enhanced edge image; Calculate the mean and standard deviation of the enhanced edge image, and perform binarization on the enhanced edge image based on the calculation results; The binarized image is further refined by closing operations to identify non-zero points in the binarized image as edge points, and to extract the coordinates of the edge points. Transform the ordinates of all edge points so that they are initialized with the image center as the origin to obtain a result matrix; Iterate through every possible path change and calculate the distance between each edge point and the image center; The distance data is statistically analyzed and placed into the corresponding columns of the result matrix. Then, functional dependencies are applied to the result matrix to find the maximum pixel value and its location in the image.
[0015] Furthermore, in step S30, the function is the minMaxLoc function. When the maximum pixel value is greater than or equal to 150, it returns that there is no tray on the turntable. If the maximum pixel value is less than 150, it returns that there is a tray but no slide on the tray.
[0016] Secondly, this application provides a slide detection device based on slide morphology, comprising: The preprocessing module acquires the positioning image and slide image, and performs preprocessing using grayscale image reading and image reduction. It also defines flag bits 1, 2, 3, and 4, which are false by default. Flag 1 indicates whether there is an edge to the slide; flag 2 indicates whether the area of the white region in the upper half of the slide is greater than a set threshold; flag 3 indicates whether the area of the white region in the lower half of the slide is greater than a set threshold; and flag 4 indicates whether the area of the white regions in both the upper and lower parts of the slide is greater than a set threshold. The processing module extracts the slide edge from the slide image and sets the flag bit 1 to true; at the same time, the positioning image is cropped and evenly divided into upper and lower parts, then binarized, and the white areas exceeding the grayscale threshold are saved, while the remaining areas are set to black, and the area of the saved white areas is calculated. If the white area in the upper half is greater than the set threshold, then flag 2 is set to true; if the white area in the lower half is greater than the set threshold, then flag 3 is set to true; if the white area in both the upper and lower halves is greater than the set threshold, then flag 4 is set to true. The flag bit judgment module judges the state of flag bit 1; if it is true, it judges the state of flag bits 2 and 3; if it is false, it judges the state of flag bit 4. If flag 2 is true and flag 3 is false, return the result that there is only one small slide at the top of the tray; if flag 2 is false and flag 3 is true, return the result that there is only one small slide at the bottom of the tray; if both flags 2 and 3 are true, return the result that there is one small slide at the top and one at the bottom of the tray. If flag 4 is true, the result is returned that there is a large glass slide on the tray; if flag 4 is false, further image processing is performed to determine whether there is no tray on the turntable or there is a tray but no glass slide on the tray.
[0017] Thirdly, this application provides an electronic device including a memory and a processor, wherein the memory stores a computer program and the processor is configured to run the computer program to perform the above-described slide detection method based on slide morphology.
[0018] Fourthly, this application provides a readable storage medium storing a computer program, the computer program including program code for controlling a process to execute the process, the process including the slide detection method based on slide morphology described above.
[0019] The main contributions and innovations of this invention are as follows: 1. Compared with the prior art, this invention proposes a novel slide detection method. By combining grayscale image preprocessing, morphological edge detection and multi-level flag bit logic judgment, it realizes automatic and efficient identification of slide type and existence state without relying on a large number of template matching, which greatly improves the robustness and adaptability of the identification system.
[0020] 2. Compared with the existing technology, the present invention addresses the problems of complex operation steps and long detection time in traditional methods. By optimizing the processing flow, such as grayscale image reading and image reduction preprocessing, the present invention significantly reduces processing time and computational burden, and improves system operating efficiency.
[0021] 3. Compared with existing technologies, this invention eliminates the need for large-scale template storage in template matching technology. Through algorithmic innovation, it effectively reduces the dependence on storage space and lowers database maintenance costs, making it particularly suitable for addressing the challenges of increasing diversity in slide types and samples.
[0022] 4. Compared with the prior art, the present invention, through a dynamic flag bit logic judgment strategy, can flexibly handle different sizes and types of slides, including small slides, large slides, and cases without slides, and accurately identify them. This enhances the system's flexibility and rapid response capability, and shows superiority, especially in handling sudden diseases or novel biological samples.
[0023] 5. Compared with existing technologies, this invention innovatively employs techniques such as black hat operation, Gaussian blur, Scharr and Laplacian operators to extract slide edges, and Hough line transform to detect straight lines, thus improving the accuracy of edge detection. Furthermore, through advanced image processing techniques such as top-hat processing, Laplacian gradient calculation, and binarization thinning, it achieves precise judgment of the presence or absence of a tray, demonstrating a deep analytical capability for subtle image features.
[0024] Details of one or more embodiments of this application are set forth in the following drawings and description to make other features, objects and advantages of this application more readily apparent. Attached Figure Description
[0025] The accompanying drawings, which are included to provide a further understanding of this application and form part of this application, illustrate exemplary embodiments of this application and are used to explain this application, but do not constitute an undue limitation of this application. In the drawings: Figure 1 This is a flowchart of a slide inspection method based on slide morphology according to an embodiment of this application. Figure 1 ; Figure 2This is a flowchart of a slide inspection method based on slide morphology according to an embodiment of this application. Figure 2 ; Figure 3 This is a schematic diagram showing a tray with small glass slides on it, according to an embodiment of this application. Figure 4 This is a schematic diagram of a tray according to an embodiment of the present application, where only a small glass slide is located at the bottom. Figure 5 This is a schematic diagram of a tray according to an embodiment of the present application, where only a small glass slide is located at the top. Figure 6 This is a schematic diagram of a large glass slide on a tray according to an embodiment of this application; Figure 7 This is a schematic diagram of a turntable with a tray but no glass slide according to an embodiment of this application; Figure 8 This is a schematic diagram of a turntable without a tray according to an embodiment of this application; Figure 9 This is a schematic diagram of the hardware structure of an electronic device according to an embodiment of this application. Detailed Implementation
[0026] Exemplary embodiments will now be described in detail, examples of which are illustrated in the accompanying drawings. When the following description relates to the drawings, unless otherwise indicated, the same numerals in different drawings denote the same or similar elements. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with one or more embodiments of this specification. Rather, they are merely examples of apparatuses and methods consistent with some aspects of one or more embodiments of this specification as detailed in the appended claims.
[0027] It should be noted that the steps of the corresponding methods are not necessarily performed in the order shown and described in this specification in other embodiments. In some other embodiments, the methods may include more or fewer steps than described in this specification. Furthermore, a single step described in this specification may be broken down into multiple steps in other embodiments; and multiple steps described in this specification may be combined into a single step in other embodiments.
[0028] Example 1 This application aims to propose a slide detection method based on slide morphology. Since glass slides are highly reflective, a light source is added to make the slide reflective, thus avoiding the influence of sample factors on slide identification. The resulting method is detailed below; for details, please refer to [reference needed]. Figure 1 and Figure 2 The method includes: Step 1: First, take two pictures with the camera: a localization image and a slide image. Input the paths of these two images into the algorithm, read the two images as grayscale images, and reduce the image size by a factor of 16 (reducing the image size can reduce the time for subsequent image processing by the algorithm).
[0029] First, define the default flags: 1 (whether there is a slide edge), 2 (whether the area of the upper white region is greater than the threshold), 3 (whether the area of the lower white region is greater than the threshold), and 4 (whether the total area of the upper and lower white regions of the slide is greater than the threshold).
[0030] Step 2: Then, perform a morphological transformation black hat operation on the slide image (because the edges of the slide appear darker compared to the bright background, and the black hat operation can highlight the edges of the slide). Extract the edges of the slide from the bright background, and use Gaussian blur to smooth the image (because the subsequent Scharr and Laplacian operators are very sensitive to noise, so smoothing is needed to eliminate noise). Then, define a 3*3 filter, combining the characteristics of the Scharr and Laplacian operators to highlight the edges, normalize the obtained image to the range of 0-255, obtain the gradient image result, and perform an opening operation. To eliminate non-target edges, the result is subtracted from the gradient image to obtain the slide edge. The slide edge is further refined using an opening operation (the opening operation can effectively remove isolated small points and eliminate small objects). The mean and standard deviation of the edge image are calculated, and then the image is binarized based on these statistics. The Hough line transform is used to detect straight lines in the binarized image (because the Hough line transform is not sensitive to incomplete parts of straight lines, it can effectively solve the problem of discontinuous edges of small slides due to illumination). If the number of straight lines is greater than 0, the slide edge is considered to have been detected, and the flag bit 1 is set to true.
[0031] Step 3: Simultaneously, crop the region of interest from the localization image (to reduce image size and optimize the algorithm's image processing time), and then split it into upper and lower parts (to identify the case of small glass slides). Perform binarization on the upper and lower parts respectively. Save the white areas that exceed the grayscale threshold of 240 (the grayscale threshold of 240 can distinguish between bright and dark areas well, and still leaves some room for error). Set the other areas to black. Then, use the findContours function (used to find contours in binary functions) to find the contours of the white areas, and calculate the area of the white areas in the upper and lower parts respectively.
[0032] Specifically, if the white area in the upper half is greater than the threshold of 260,000 (the threshold of 260,000 is sufficient to distinguish the white area reflected by the diffuser from the white area reflected by the small glass slide), then flag 2 is set to true; if the white area in the lower half is greater than the threshold, then flag 3 is set to true, and if it is less than the threshold, then flag 3 remains unchanged; if the white area in both the upper and lower halves is greater than the set threshold, then flag 4 is set to true.
[0033] Step 4: Determine the flag bit 1 (the flag bit 1 is used as the standard for judgment because the straight line detection feature of the small glass slide can be well distinguished from other cases): If flag 1 is true, then flags 2 and 3 are checked. If flag 2 is true and flag 3 is false, the result is returned: there is only one small slide on the top of the tray. Figure 5 As shown; If flag 2 is false and flag 3 is true, the result returned is that there is only one small glass slide at the bottom of the tray. Figure 4 As shown; if both flags 2 and 3 are true, then it returns that there is a small glass slide on the top and bottom of the tray, as shown. Figure 3 As shown.
[0034] Specifically, if flag 1 is false, then check if flag 4 is true; if flag 4 is true, return the result that there is a large glass slide on the tray. Figure 6 As shown.
[0035] If flag 4 is false, a top-hat operation is performed on the slide image (the top-hat operation can highlight details in the image), dark objects are extracted from the image, and the image is smoothed using Gaussian blur (because the subsequent Laplacian is very sensitive to noise, so smoothing is necessary first). The Laplacian operator is used to calculate the Laplacian gradient of the image (Laplacian detects edges by calculating the second derivative of the image; the second derivative has a large response at edges, which can accurately locate the edge position), the edges are highlighted, the gradient image is added to the edge image obtained in the previous step to obtain an enhanced edge image, the mean and standard deviation of the edge image are calculated, the edge image is binarized using the calculated threshold, and the binary image is further refined through a closing operation. (Closing operations can eliminate small holes in the image). Find the non-zero points (i.e., edge points) in the binarized image, extract the x-coordinates and y-coordinates of these points, transform the y-coordinates so that they are centered at the image center, initialize a result matrix with the same size as the expected maximum radius (1000), iterate through each possible radius, calculate the distance between each point and the center of the circle (image center), and record these distances in the corresponding columns of the res matrix (result matrix). Apply the minMaxLoc function to the res matrix to find the maximum value maxval and its position maxloc. If maxval is greater than or equal to the threshold (150, this threshold is obtained by statistically analyzing multiple images with and without a tray), return the result that there is no tray on the turntable. Figure 8 As shown; if maxval is less than the threshold, the result is returned: the turntable has a tray but no slides. Figure 7 As shown.
[0036] The turntable and the tray on the turntable are part of the instrument and belong to the structure of the prior art. The technical point to be protected in this application does not lie in this, so its structure and principle will not be described in detail.
[0037] The `minMaxLoc` function, mentioned above, is a commonly used function in computer vision and image processing. It's used to find the minimum and maximum pixel values in an image and their corresponding locations. This function is widely used in various image analysis tasks, such as image thresholding, feature point detection, and image contrast adjustment. A simple example of calling the `minMaxLoc` function using OpenCV in Python is shown below: import cv2 # Load grayscale image image = cv2.imread('image.jpg', cv2.IMREAD_GRAYSCALE) # Using the minMaxLoc function min_val, max_val, min_loc, max_loc = cv2.minMaxLoc(image) print(f"Minimum value: {min_val}, Position: {min_loc}") print(f"Maximum value: {max_val}, Position: {max_loc}") The black hat operation mentioned above is a morphological image processing technique. It is the result of subtracting the original image from the image after a closing operation (dilation followed by erosion). This operation can be used to highlight darker patches or features in an image than their surroundings, which is helpful for background subtraction or the extraction of specific dark features.
[0038] The Gaussian blur mentioned above, also known as Gaussian smoothing, is a widely used filter effect in image processing, found in software such as Adobe Photoshop, GIMP, and Paint.NET. This technique works by convolving an image with a two-dimensional Gaussian function (i.e., the probability density function of a normal distribution), thus producing a blurring effect. The Gaussian function is known for its unique bell-shaped curve, which ensures that the degree of blurring for each pixel in an image is related to the values of its neighboring pixels; the farther away the pixel, the smaller its influence on the central pixel.
[0039] The Scharr operator, mentioned above, is an edge detection technique used in image processing. It's an improved version of the Sobel operator, primarily used for calculating image gradients, especially in edge detection tasks. While the Sobel operator is commonly used, it can introduce significant errors in certain situations, particularly when using small kernels (e.g., 3x3). The Scharr operator reduces these errors by using more precise coefficients, providing more accurate edge detection results than the Sobel operator, especially in gradient calculations in the X and Y directions.
[0040] The Laplacian operator mentioned above is a differential operator widely used in image processing and computer vision. It is used to calculate the second derivative of an image, thereby enabling edge detection and image feature enhancement.
[0041] The `findContours` function mentioned above is a key function in the OpenCV library, widely used in computer vision and image processing projects to detect and extract contours in binary images. Contours refer to the boundaries of connected components and are commonly used to identify object shapes in images, perform object tracking, image segmentation, and other advanced visual analysis tasks.
[0042] The advantages of this invention are that it effectively solves the problem of needing to add new image templates to the template file every time a new slide appears, and the issue of inconsistent camera heights caused by machine vibration during transportation leading to mismatches between images in the template library and those in the library, requiring the addition of new templates. This invention optimizes and eliminates the memory usage for storing templates, thus reducing the matching time added when adding new image templates. Compared to morphologically based methods like template matching, it offers better robustness. Furthermore, it is more convenient to operate; the slide recognition threshold can be directly changed by modifying parameters, eliminating the need to repeatedly add image templates to the template library.
[0043] In practical applications, data was collected over two months (with identical computer performance). Template matching, without adding new slide styles (only one template is stored for each case), achieved an accuracy of 87% and an average detection time of 1028ms. The morphology-based slide recognition method achieved 100% accuracy. The average detection time for two small slides was 85ms, for one small slide it was 82ms, for a large slide it was 84ms, and for slides with or without a tray it was 87ms.
[0044] Example 2 Based on the same concept, this application also proposes a slide detection device based on slide morphology, comprising: The preprocessing module acquires the positioning image and slide image, and performs preprocessing using grayscale image reading and image reduction. It also defines flag bits 1, 2, 3, and 4, which are false by default. Flag 1 indicates whether there is an edge to the slide; flag 2 indicates whether the area of the white region in the upper half of the slide is greater than a set threshold; flag 3 indicates whether the area of the white region in the lower half of the slide is greater than a set threshold; and flag 4 indicates whether the area of the white regions in both the upper and lower parts of the slide is greater than a set threshold. The processing module extracts the slide edge from the slide image and sets the flag bit 1 to true; at the same time, the positioning image is cropped and evenly divided into upper and lower parts, then binarized, and the white areas exceeding the grayscale threshold are saved, while the remaining areas are set to black, and the area of the saved white areas is calculated. If the white area in the upper half is greater than the set threshold, then flag 2 is set to true; if the white area in the lower half is greater than the set threshold, then flag 3 is set to true; if the white area in both the upper and lower halves is greater than the set threshold, then flag 4 is set to true. The flag bit judgment module judges the state of flag bit 1; if it is true, it judges the state of flag bits 2 and 3; if it is false, it judges the state of flag bit 4. If flag 2 is true and flag 3 is false, then the result is returned as there is only one small slide at the top of the tray. Figure 5 As shown; if flag 2 is false and flag 3 is true, then the result is returned where there is only one small slide at the bottom of the tray, as shown. Figure 4 As shown; if both flags 2 and 3 are true, the result is returned as follows: there is one small glass slide on the top and one on the bottom of the tray. Figure 3 As shown; If flag 4 is true, the result will be returned that there is a large glass slide on the tray, such as... Figure 6 As shown; if flag 4 is false, further image processing is performed to determine the output turntable result (either no tray on the turntable or a tray with no slide on it), such as... Figure 7 and Figure 8 As shown.
[0045] Example 3 This embodiment also provides an electronic device, see reference. Figure 9 It includes a memory 404 and a processor 402, the memory 404 storing a computer program and the processor 402 being configured to run the computer program to perform the steps in any of the above method embodiments.
[0046] Specifically, the processor 402 may include a central processing unit (CPU), or an application-specific integrated circuit (ASIC), or one or more integrated circuits that can be configured to implement the embodiments of this application.
[0047] Memory 404 may include a mass storage device for data or instructions. For example, and not limitingly, memory 404 may include a hard disk drive (HDD), a floppy disk drive, a solid-state drive (SSD), flash memory, an optical disk drive, a magneto-optical disk drive, magnetic tape, or a Universal Serial Bus (USB) drive, or a combination of two or more of these. Where appropriate, memory 404 may include removable or non-removable (or fixed) media. Where appropriate, memory 404 may be internal or external to a data processing device. In a particular embodiment, memory 404 is non-volatile memory. In a particular embodiment, memory 404 includes read-only memory (ROM) and random access memory (RAM). Where appropriate, the ROM may be a mask-programmed ROM, a programmable read-only memory (PROM), an erasable read-only memory (EPROM), an electrically erasable read-only memory (EEPROM), an electrically alterable read-only memory (EAROM), or flash memory, or a combination of two or more of these. Where appropriate, the RAM can be Static Random-Access Memory (SRAM) or Dynamic Random-Access Memory (DRAM). DRAM can be Fast Page Mode Dynamic Random-Access Memory (FPMDRAM), Extended Data Out Dynamic Random-Access Memory (EDODRAM), Synchronous Dynamic Random-Access Memory (SDRAM), etc.
[0048] The memory 404 can be used to store or cache various data files that need to be processed and / or communicated, as well as possible computer program instructions executed by the processor 402.
[0049] The processor 402 reads and executes computer program instructions stored in the memory 404 to implement any of the slide detection methods based on slide morphology in the above embodiments.
[0050] Optionally, the electronic device may further include a transmission device 406 and an input / output device 408, wherein the transmission device 406 is connected to the processor 402, and the input / output device 408 is connected to the processor 402.
[0051] The transmission device 406 can be used to receive or send data via a network. Specific examples of the network described above may include wired or wireless networks provided by the communication provider of the electronic device. In one example, the transmission device includes a Network Interface Controller (NIC), which can connect to other network devices via a base station to communicate with the Internet. In another example, the transmission device 406 may be a Radio Frequency (RF) module used for wireless communication with the Internet.
[0052] Input / output device 408 is used to input or output information.
[0053] Example 4 This embodiment also provides a readable storage medium storing a computer program, the computer program including program code for controlling a process to execute the process, the process including the slide detection method based on slide morphology according to Embodiment 1.
[0054] It should be noted that the specific examples in this embodiment can refer to the examples described in the above embodiments and optional implementations, and will not be repeated here.
[0055] Generally, various embodiments can be implemented in hardware or dedicated circuitry, software, logic, or any combination thereof. Some aspects of the invention can be implemented in hardware, while others can be implemented by firmware or software executed by a controller, microprocessor, or other computing device, but the invention is not limited thereto. Although various aspects of the invention may be shown and described as block diagrams, flowcharts, or using some other graphical representation, it should be understood that, by way of non-limiting example, these blocks, apparatuses, systems, techniques, or methods described herein can be implemented in hardware, software, firmware, dedicated circuitry or logic, general-purpose hardware or controllers or other computing devices, or some combination thereof.
[0056] Embodiments of the present invention can be implemented by computer software, which may be executable by a data processor of a mobile device, such as a processor entity, or by hardware, or by a combination of software and hardware. Computer software or programs (also referred to as program products), including software routines, applets, and / or macros, can be stored in any device-readable data storage medium, and they include program instructions for performing specific tasks. A computer program product may include one or more computer-executable components configured to perform embodiments when the program is run. One or more computer-executable components may be at least one piece of software code or a portion thereof. Additionally, it should be noted that any block in the logical flow of the figures may represent a program step, or interconnected logic circuits, blocks, and functions, or a combination of program steps and logic circuits, blocks, and functions. The software may be stored on physical media such as memory chips or blocks of storage implemented within a processor, magnetic media such as hard disks or floppy disks, and optical media such as, for example, DVDs and their data variants, CDs, etc. The physical medium is a non-transient medium.
[0057] Those skilled in the art should understand that the technical features of the above embodiments can be combined in any way. For the sake of brevity, not all possible combinations of the technical features in the above embodiments have been described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.
[0058] The above embodiments are merely illustrative of several implementation methods of this application, and their descriptions are relatively specific and detailed, but they should not be construed as limiting the scope of this application. It should be noted that those skilled in the art can make various modifications and improvements without departing from the concept of this application, and these all fall within the protection scope of this application. Therefore, the protection scope of this application should be determined by the appended claims.
Claims
1. A slide detection method based on slide morphology, characterized in that, Includes the following steps: S00. Obtain the positioning image and slide image, and perform preprocessing using grayscale image reading and image reduction. Meanwhile, define flag bits 1, 2, 3, and 4, with the default value being false. Flag 1 indicates whether there is an edge to the slide; flag 2 indicates whether the area of the white region in the upper half of the slide is greater than a set threshold; flag 3 indicates whether the area of the white region in the lower half of the slide is greater than a set threshold; and flag 4 indicates whether the area of the white regions in both the upper and lower parts of the slide is greater than a set threshold. S10. Extract the slide edge from the slide image and set the flag bit 1 to true; Meanwhile, the positioning image is cropped and evenly divided into upper and lower parts, then binarized. White areas exceeding the grayscale threshold are saved, and the remaining areas are set to black. The area of the saved white areas is calculated. If the white area in the upper half is greater than the set threshold, then flag 2 is set to true; if the white area in the lower half is greater than the set threshold, then flag 3 is set to true; if the white area in both the upper and lower halves is greater than the set threshold, then flag 4 is set to true. S20. Determine the status of flag 1; If true, check the status of flags 2 and 3; if false, check the status of flag 4. S30. If flag 2 is true and flag 3 is false, return the result that there is only one small slide at the top of the tray; if flag 2 is false and flag 3 is true, return the result that there is only one small slide at the bottom of the tray; if both flags 2 and 3 are true, return the result that there is one small slide at the top and one at the bottom of the tray. If flag 4 is true, the result is returned that there is a large glass slide on the tray; if flag 4 is false, further image processing is performed to determine whether there is no tray on the turntable or there is a tray but no glass slide on the tray. The specific steps for further image processing are as follows: Top-capping is applied to the slide image to extract dark objects, and Gaussian blur is used to smooth the slide image. The Laplacian operator is used to calculate the Laplacian gradient of the slide image to highlight the edges, thus obtaining a gradient image; The gradient image is added to the edge image to obtain the enhanced edge image; Calculate the mean and standard deviation of the enhanced edge image, and perform binarization on the enhanced edge image based on the calculation results; The binarized image is further refined by closing operations to identify non-zero points in the binarized image as edge points, and to extract the coordinates of the edge points. Transform the ordinates of all edge points so that they are initialized with the image center as the origin to obtain a result matrix; Iterate through each path change and calculate the distance between each edge point and the image center; The distance data is statistically analyzed and placed into the corresponding columns of the result matrix. Then, functional dependencies are applied to the result matrix to find the maximum pixel value and its location in the image.
2. The slide detection method based on slide morphology as described in claim 1, characterized in that, In step S10, the specific steps for extracting the slide edge from the slide image and setting the flag bit 1 to true are as follows: The slide image was subjected to morphological transformation black hat processing to extract the slide edges, and then Gaussian blur was used for smoothing. Define a filter and combine it with the Scharr and Laplacian operators to highlight edges, then normalize the obtained image to get the gradient image result; The edge image of the slide is obtained by subtracting the calculation result from the gradient image through the opening operation, and the mean and standard deviation of the edge image of the slide are calculated. Binarize the image of the slide edge based on the mean and standard deviation results; Detect straight lines in the binarized image. If the number of straight lines is greater than 0, it is considered that the edge of the glass slide has been detected, and the flag bit 1 is set to true.
3. The slide detection method based on slide morphology as described in claim 2, characterized in that, In step S10, straight lines in the binarized image are detected by Hough line transform.
4. The slide detection method based on slide morphology as described in claim 1, characterized in that, In step S10, the region of interest is extracted from the location map and then split into upper and lower parts from the middle.
5. The slide detection method based on slide morphology as described in claim 1, characterized in that, In step S10, the grayscale threshold is 240, and the set threshold is 260000.
6. The slide detection method based on slide morphology as described in claim 1, characterized in that, In step S30, the function is minMaxLoc. When the maximum pixel value is greater than or equal to 150, it returns that there is no tray on the turntable. If the maximum pixel value is less than 150, it returns that there is a tray but no slide on the tray.
7. An apparatus for implementing the slide detection method based on slide morphology according to any one of claims 1 to 6, characterized in that, include: The preprocessing module acquires the positioning image and slide image, and performs preprocessing using grayscale image reading and image reduction. It also defines flag bits 1, 2, 3, and 4, which are false by default. Flag 1 indicates whether there is an edge to the slide; flag 2 indicates whether the area of the white region in the upper half of the slide is greater than a set threshold; flag 3 indicates whether the area of the white region in the lower half of the slide is greater than a set threshold; and flag 4 indicates whether the area of the white regions in both the upper and lower parts of the slide is greater than a set threshold. The processing module extracts the slide edge from the slide image and sets the flag bit 1 to true; at the same time, the positioning image is cropped and evenly divided into upper and lower parts, then binarized, and the white areas exceeding the grayscale threshold are saved, while the remaining areas are set to black, and the area of the saved white areas is calculated. If the white area in the upper half is greater than the set threshold, then flag 2 is set to true; if the white area in the lower half is greater than the set threshold, then flag 3 is set to true; if the white area in both the upper and lower halves is greater than the set threshold, then flag 4 is set to true. The flag bit judgment module judges the state of flag bit 1; if it is true, it judges the state of flag bits 2 and 3; if it is false, it judges the state of flag bit 4. If flag 2 is true and flag 3 is false, return the result that there is only one small slide at the top of the tray; if flag 2 is false and flag 3 is true, return the result that there is only one small slide at the bottom of the tray; if both flags 2 and 3 are true, return the result that there is one small slide at the top and one at the bottom of the tray. If flag 4 is true, the result is returned that there is a large glass slide on the tray; if flag 4 is false, further image processing is performed to determine whether there is no tray on the turntable or there is a tray but no glass slide on the tray.
8. An electronic device comprising a memory and a processor, characterized in that, The memory stores a computer program, and the processor is configured to run the computer program to perform the slide detection method based on slide morphology as described in any one of claims 1 to 6.
9. A readable storage medium, characterized in that, The readable storage medium stores a computer program, the computer program including program code for controlling a process to execute the process, the process including the slide detection method based on slide morphology according to any one of claims 1 to 6.
Citation Information
Patent Citations
Laminated glass
CN108290786A
Refrigerator
CN108931100A