A multi-threaded digital slice scanning method and apparatus
By employing a multi-threaded processing method in the digital slice scanner and dynamically adjusting the waiting time of each thread, the problem of slow scanning speed in the prior art is solved, and a highly efficient digital slice scanning process is achieved.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-11-09
- Publication Date
- 2026-03-06
AI Technical Summary
The scanning process of existing digital slide scanners is too slow, especially in intraoperative frozen section diagnosis, which cannot be completed within 30 minutes, and multi-threaded processing leads to resource waste and time extension.
A multi-threaded digital slicing scanning method is adopted. By setting dynamic waiting time for each thread, including processes such as device movement, image acquisition, processing, registration, fusion, segmentation and saving, the waiting time of each thread is dynamically adjusted to optimize resource utilization.
It improves the efficiency of digital slide scanning, reduces the waste of computing resources, and meets the need for rapid scanning, especially in intraoperative frozen section diagnosis, where scanning can be completed in a short time.
Smart Images

Figure CN113961316B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to a multi-threaded digital slice scanning method and apparatus, specifically a highly efficient scanning process that coordinates various stages in the digital slice formation process using a digital slice scanner based on an area scan camera, belonging to the field of digital slice image processing technology. Background Technology
[0002] A digital tiling scanner is a device that digitizes physical slices. Its main principle is to use moving structures and industrial cameras to create panoramic digital slices. Depending on the type of camera used, it is divided into area scan camera scanners and line scan camera scanners. Line scan cameras acquire images column-by-column or row-by-row images, which are then stitched together; while area scan cameras acquire images from a fixed field of view, which are then registered and stitched together to form panoramic digital slices.
[0003] In digital slicing scanning, images are acquired and processed sequentially, with each step's output serving as the input for the next. The entire image processing must proceed sequentially, especially during registration, image fusion, and the creation of other layers, all of which require the use of previous images. The entire processing flow, from sending commands to saving the image, is time-consuming. If one process is completed before moving to the next, the entire digital slice formation process becomes very slow. This is particularly problematic when digital slicing is applied to intraoperative frozen section diagnosis, which requires completion within 30 minutes of specimen reception. Slow digital slicing scanning is unacceptable, resulting in very poor usability.
[0004] However, if each process is made into a thread, too many threads will be created, resulting in a waste of resources. At the same time, due to the different processing times of each thread and resource contention, the overall processing time will be increased. Summary of the Invention
[0005] To address the aforementioned issues, this invention proposes a multi-threaded digital slice scanning method and apparatus, which can better handle the digital slice scanning process, reduce resource contention between threads, and ensure the processing speed of each process.
[0006] The technical solution adopted by this invention to solve its technical problem is as follows:
[0007] In a first aspect, the present invention provides a multi-threaded digital slicing scanning method, including a device movement command sending thread, an image acquisition thread, an image processing thread, an image registration thread, an image fusion thread, an image segmentation thread, a pyramid layer thread, and an image saving thread, and each thread is set with a waiting time and the waiting time is dynamically adjusted.
[0008] As one possible implementation of this embodiment, the delay time for sending the instruction is set to S1 milliseconds, and the device movement instruction sending thread includes:
[0009] Obtain a data point from the scan list and increment the number of fields of view to be captured by 1.
[0010] Determine whether the entire field of view has been acquired. If not, double the delay time S1 and continue to determine whether the acquisition is complete. If it is complete, halve the delay time S1 and return to the previous step to obtain the next data from the scan list. Exit the process after traversing all data in all scan lists.
[0011] As one possible implementation of this embodiment, the image acquisition waiting delay time is set to S2 milliseconds, and the image acquisition thread includes:
[0012] Determine whether the "Device Movement Command Sending Thread" has ended and whether the required field-of-view image is 0; if it has not ended and the required image is not 0, proceed to the next step; if it has ended and the required image is 0, end the thread.
[0013] If the number of images to be processed exceeds the preset threshold, the delay time S2 will be doubled and the status of the images to be processed will continue to be determined.
[0014] If the number of images to be processed is less than the threshold, the delay time S2 is halved and images are acquired according to the sent acquisition command. The number of fields of view is decremented by 1 for each field of view image acquired. The number of images to be processed is then incremented by 1 before proceeding to the next step.
[0015] Determine if the number of fields of view is greater than 0. If it is greater than 0, proceed to step 2; if it is equal to 0, proceed to step 1.
[0016] As one possible implementation of this embodiment, the image processing waiting time is set to S3 milliseconds, and the image processing thread includes:
[0017] Determine if the "image acquisition thread" has ended and if the number of images to be processed is 0; if it has not ended and the number of images to be acquired is not 0, proceed to the next step; if it has ended and the number of images to be processed is 0, terminate the thread.
[0018] If the number of images to be registered is greater than the threshold, then delay for 3 milliseconds and proceed to the next step; if it is less than the threshold, proceed to the fourth step.
[0019] If S3 is greater than 500 milliseconds, start another image processing thread, double the delay time S3, and then proceed to the second step to continue judging the image that needs to be registered.
[0020] After halving the delay time S3, the images are processed separately, and the number of images to be processed in each thread is reduced by 1; the number of slices to be registered is increased by 1.
[0021] Determine if the number of images to be processed is greater than 0. If it is greater than 0, proceed to step 2; if it is equal to 0, proceed to step 1.
[0022] As one possible implementation of this embodiment, the image registration waiting time is set to S4 milliseconds, and the image registration thread includes:
[0023] Determine if all "image processing threads" have ended and if the number of images to be registered is 0; if they have not ended and the number of images to be registered is not 0, proceed to the next step; if they have ended and the number of images to be registered is 0, terminate the thread.
[0024] If the number of images to be fused is greater than the threshold, and if it is greater than the preset threshold, the delay time S4 will be doubled before continuing to determine the situation of the images to be fused.
[0025] If the value is less than the threshold, the delay time S4 is halved, and image registration is performed on the images to be registered. The number of slices to be registered is reduced by 1 for each completed field-of-view image. The number of images to be fused is increased by 1, and the process proceeds to the next step.
[0026] Check if the number of slices is greater than 0. If it is, proceed to step 2; if it is equal to 0, proceed to step 1.
[0027] As one possible implementation of this embodiment, the image fusion waiting time is set to S5 milliseconds, and the image fusion thread includes:
[0028] Determine if the "image registration thread" has ended and if the number of images to be merged is 0; if it has not ended and the number of images to be merged is not 0, proceed to the next step; if it has ended and the number of images to be merged is 0, end the thread.
[0029] If the number of images to be segmented is greater than the threshold, and if it is greater than the preset threshold, the delay time S5 will be doubled before continuing to judge the situation of the images to be segmented.
[0030] If the value is less than the threshold, the delay time S5 is halved, and the images to be fused are fused as needed. The number of images to be fused is reduced by 1 after each field of view is completed, and the number of images to be segmented is increased by 1 before proceeding to the next step.
[0031] Determine if the number of images to be fused is greater than 0. If it is greater than 0, proceed to step 2; if it is equal to 0, proceed to step 1.
[0032] As one possible implementation of this embodiment, the image segmentation waiting time is set to S6 milliseconds, and the image segmentation thread includes:
[0033] Determine if the "Image Fusion Thread" has ended and if the number of images to be segmented is 0; if it has not ended and the number of images to be segmented is not 0, proceed to the next step; if it has ended and the number of images to be segmented is 0, end the thread.
[0034] If the number of images that need to create a pyramid layer is greater than the threshold, the delay time S6 will be doubled and the situation of images that need to create a pyramid layer will continue to be determined.
[0035] If the value is less than the threshold, the delay time S6 is halved, and the images to be segmented are segmented according to the required images. The number of images to be segmented is reduced by 1 after each field of view image is completed. The number of images to be created into a pyramid layer is increased by 1, and then the process proceeds to the next step.
[0036] Determine if the number of images to be segmented is greater than 0. If it is greater than 0, proceed to step 2; if it is equal to 0, proceed to step 1.
[0037] As one possible implementation of this embodiment, the waiting time for creating the pyramid layer image is set to S7 milliseconds, and the pyramid layer thread includes:
[0038] Determine if the "Image Segmentation Thread" has ended and if the number of images requiring pyramid layers is 0; if it has not ended and the number of images requiring pyramid layers is not 0, proceed to the next step; if it has ended and the number of images requiring pyramid layers is 0, end the thread.
[0039] If the number of tile images to be saved is greater than a threshold, then the delay time S7 is doubled and the image status of the tiles to be saved is checked again.
[0040] If the value is less than the threshold, the delay time S7 is halved, and the images for creating pyramid layers are created as needed. For each completed pyramid layer, the number of images to be created is reduced by 1, and the number of tile images to be saved is increased by 1 before proceeding to the next step.
[0041] Determine if the number of images to be created for the pyramid layer is greater than 0. If it is greater than 0, proceed to step 2; if it is equal to 0, proceed to step 1.
[0042] As one possible implementation of this embodiment, the waiting time for the thread saving the tile image is set to S8 milliseconds, and the image saving thread includes:
[0043] Determine if the "creating pyramid layer thread" has ended and if the number of tile images to be saved is 0; if it has not ended and the number of tile images to be saved is not 0, proceed to the next step; if it has ended and the number of tile images to be saved is 0, end the tile image saving thread.
[0044] If the number of tile images to be saved is greater than 0, save the tile image, decrement the number of tile images to be saved by 1, and continue to this step; if it is equal to 0, go to the first step.
[0045] Secondly, an embodiment of the present invention provides a multi-threaded digital slice scanning device, comprising:
[0046] The instruction sending module is used to execute the device movement instruction sending thread;
[0047] The image acquisition module is used to execute the image acquisition thread;
[0048] The image processing module is used to execute image processing threads;
[0049] The image registration module is used to execute the image registration thread;
[0050] The image fusion module is used to execute the image fusion thread;
[0051] The image segmentation module is used to execute the image segmentation thread;
[0052] The pyramid layer module is used to execute pyramid layer threads;
[0053] The image saving module is used to execute the image saving thread.
[0054] The technical solutions of the embodiments of the present invention can have the following beneficial effects:
[0055] To address the need for efficient scanning processes involving coordinated operations across various stages in digital slice formation using a digital slice scanner based on an area scan camera, this invention proposes a dynamic thread processing method for area scan cameras and a scanning process handling method for dynamic thread waiting time. This reduces the allocation of corresponding computing resources, thereby reducing the overall scanning time of digital slices and effectively meeting the requirements of rapid scanning in digital slice scanners.
[0056] To better handle the digital slicing scanning process, reduce resource contention between threads, and ensure the processing speed of each process, this invention employs a dynamic thread waiting time digital slicing scanning method based on multi-threading. This ensures the overall scanning time, reduces computational resource contention, and is applied to digital slicing scanners based on area scan cameras to guarantee high efficiency in the scanning process. Attached image description:
[0057] Figure 1 This is a flowchart illustrating a multi-threaded digital slice scanning method according to an exemplary embodiment;
[0058] Figure 2 This is a structural diagram of a multi-threaded digital slice scanning device according to an exemplary embodiment;
[0059] Figure 3 This is a flowchart illustrating a thread startup and a movement command sending thread according to an exemplary embodiment;
[0060] Figure 4 This is a flowchart illustrating an image acquisition thread according to an exemplary embodiment;
[0061] Figure 5 This is a flowchart illustrating an image processing thread according to an exemplary embodiment;
[0062] Figure 6 This is a flowchart illustrating an image registration thread according to an exemplary embodiment;
[0063] Figure 7 This is a flowchart illustrating an image fusion thread according to an exemplary embodiment;
[0064] Figure 8 This is a flowchart illustrating an image segmentation thread according to an exemplary embodiment;
[0065] Figure 9 This is a flowchart illustrating a pyramid-format image creation thread according to an exemplary embodiment;
[0066] Figure 10 This is a flowchart illustrating a tile map image saving thread according to an exemplary embodiment. Detailed Implementation
[0067] The present invention will be further described below with reference to the accompanying drawings and embodiments:
[0068] To clearly illustrate the technical features of this solution, the invention will be described in detail below through specific embodiments and in conjunction with the accompanying drawings. The following disclosure provides many different embodiments or examples for implementing different structures of the invention. To simplify the disclosure of the invention, components and arrangements of specific examples are described below. Furthermore, reference numerals and / or letters may be repeated in different examples. This repetition is for simplification and clarity and does not in itself indicate a relationship between the various embodiments and / or arrangements discussed. It should be noted that the components illustrated in the drawings are not necessarily drawn to scale. Descriptions of well-known components, processing techniques, and processes are omitted in this invention to avoid unnecessarily limiting the invention.
[0069] Figure 1 This is a flowchart illustrating a multi-threaded digital slice scanning method according to an exemplary embodiment. Figure 1 As shown in the figure, the digital slicing scanning method based on multithreading provided by the present invention includes a device movement command sending thread, an image acquisition thread, an image processing thread, an image registration thread, an image fusion thread, an image segmentation thread, a pyramid layer thread, and an image saving thread, and each thread is set with a waiting time and the waiting time is dynamically adjusted.
[0070] As one possible implementation of this embodiment, the delay time for sending the instruction is set to S1 milliseconds, and the device movement instruction sending thread includes:
[0071] Obtain a data point from the scan list and increment the number of fields of view to be captured by 1.
[0072] Determine whether the entire field of view has been acquired. If not, double the delay time S1 and continue to determine whether the acquisition is complete. If it is complete, halve the delay time S1 and return to the previous step to obtain the next data from the scan list. Exit the process after traversing all data in all scan lists.
[0073] As one possible implementation of this embodiment, the image acquisition waiting delay time is set to S2 milliseconds, and the image acquisition thread includes:
[0074] Determine whether the "Device Movement Command Sending Thread" has ended and whether the required field-of-view image is 0; if it has not ended and the required image is not 0, proceed to the next step; if it has ended and the required image is 0, end the thread.
[0075] If the number of images to be processed exceeds the preset threshold, the delay time S2 will be doubled and the status of the images to be processed will continue to be determined.
[0076] If the number of images to be processed is less than the threshold, the delay time S2 is halved and images are acquired according to the sent acquisition command. The number of fields of view is decremented by 1 for each field of view image acquired. The number of images to be processed is then incremented by 1 before proceeding to the next step.
[0077] Determine if the number of fields of view is greater than 0. If it is greater than 0, proceed to step 2; if it is equal to 0, proceed to step 1.
[0078] As one possible implementation of this embodiment, the image processing waiting time is set to S3 milliseconds, and the image processing thread includes:
[0079] Determine if the "image acquisition thread" has ended and if the number of images to be processed is 0; if it has not ended and the number of images to be acquired is not 0, proceed to the next step; if it has ended and the number of images to be processed is 0, terminate the thread.
[0080] If the number of images to be registered is greater than the threshold, then delay for 3 milliseconds and proceed to the next step; if it is less than the threshold, proceed to the fourth step.
[0081] If S3 is greater than 500 milliseconds, start another image processing thread, double the delay time S3, and then proceed to the second step to continue judging the image that needs to be registered.
[0082] After halving the delay time S3, the images are processed separately, and the number of images to be processed in each thread is reduced by 1; the number of slices to be registered is increased by 1.
[0083] Determine if the number of images to be processed is greater than 0. If it is greater than 0, proceed to step 2; if it is equal to 0, proceed to step 1.
[0084] As one possible implementation of this embodiment, the image registration waiting time is set to S4 milliseconds, and the image registration thread includes:
[0085] Determine if all "image processing threads" have ended and if the number of images to be registered is 0; if they have not ended and the number of images to be registered is not 0, proceed to the next step; if they have ended and the number of images to be registered is 0, terminate the thread.
[0086] If the number of images to be fused is greater than the threshold, and if it is greater than the preset threshold, the delay time S4 will be doubled before continuing to determine the situation of the images to be fused.
[0087] If the value is less than the threshold, the delay time S4 is halved, and image registration is performed on the images to be registered. The number of slices to be registered is reduced by 1 for each completed field-of-view image. The number of images to be fused is increased by 1, and the process proceeds to the next step.
[0088] Check if the number of slices is greater than 0. If it is, proceed to step 2; if it is equal to 0, proceed to step 1.
[0089] As one possible implementation of this embodiment, the image fusion waiting time is set to S5 milliseconds, and the image fusion thread includes:
[0090] Determine if the "image registration thread" has ended and if the number of images to be merged is 0; if it has not ended and the number of images to be merged is not 0, proceed to the next step; if it has ended and the number of images to be merged is 0, end the thread.
[0091] If the number of images to be segmented is greater than the threshold, and if it is greater than the preset threshold, the delay time S5 will be doubled before continuing to judge the situation of the images to be segmented.
[0092] If the value is less than the threshold, the delay time S5 is halved, and the images to be fused are fused as needed. The number of images to be fused is reduced by 1 after each field of view is completed, and the number of images to be segmented is increased by 1 before proceeding to the next step.
[0093] Determine if the number of images to be fused is greater than 0. If it is greater than 0, proceed to step 2; if it is equal to 0, proceed to step 1.
[0094] As one possible implementation of this embodiment, the image segmentation waiting time is set to S6 milliseconds, and the image segmentation thread includes:
[0095] Determine if the "Image Fusion Thread" has ended and if the number of images to be segmented is 0; if it has not ended and the number of images to be segmented is not 0, proceed to the next step; if it has ended and the number of images to be segmented is 0, end the thread.
[0096] If the number of images that need to create a pyramid layer is greater than the threshold, the delay time S6 will be doubled and the situation of images that need to create a pyramid layer will continue to be determined.
[0097] If the value is less than the threshold, the delay time S6 is halved, and the images to be segmented are segmented according to the required images. The number of images to be segmented is reduced by 1 after each field of view image is completed. The number of images to be created into a pyramid layer is increased by 1, and then the process proceeds to the next step.
[0098] Determine if the number of images to be segmented is greater than 0. If it is greater than 0, proceed to step 2; if it is equal to 0, proceed to step 1.
[0099] As one possible implementation of this embodiment, the waiting time for creating the pyramid layer image is set to S7 milliseconds, and the pyramid layer thread includes:
[0100] Determine if the "Image Segmentation Thread" has ended and if the number of images requiring pyramid layers is 0; if it has not ended and the number of images requiring pyramid layers is not 0, proceed to the next step; if it has ended and the number of images requiring pyramid layers is 0, end the thread.
[0101] If the number of tile images to be saved is greater than a threshold, then the delay time S7 is doubled and the image status of the tiles to be saved is checked again.
[0102] If the value is less than the threshold, the delay time S7 is halved, and the images for creating pyramid layers are created as needed. For each completed pyramid layer, the number of images to be created is reduced by 1, and the number of tile images to be saved is increased by 1 before proceeding to the next step.
[0103] Determine if the number of images to be created for the pyramid layer is greater than 0. If it is greater than 0, proceed to step 2; if it is equal to 0, proceed to step 1.
[0104] As one possible implementation of this embodiment, the waiting time for the thread saving the tile image is set to S8 milliseconds, and the image saving thread includes:
[0105] Determine if the "creating pyramid layer thread" has ended and if the number of tile images to be saved is 0; if it has not ended and the number of tile images to be saved is not 0, proceed to the next step; if it has ended and the number of tile images to be saved is 0, end the tile image saving thread.
[0106] If the number of tile images to be saved is greater than 0, save the tile image, decrement the number of tile images to be saved by 1, and continue to this step; if it is equal to 0, go to the first step.
[0107] As one possible implementation of this embodiment, the initial values of the waiting times S1-S8 of each thread are set according to the computer's processing power, for example, 50 milliseconds.
[0108] like Figure 2 As shown, an embodiment of the present invention provides a multi-threaded digital slice scanning device, comprising:
[0109] The instruction sending module is used to execute the device movement instruction sending thread;
[0110] The image acquisition module is used to execute the image acquisition thread;
[0111] The image processing module is used to execute image processing threads;
[0112] The image registration module is used to execute the image registration thread;
[0113] The image fusion module is used to execute the image fusion thread;
[0114] The image segmentation module is used to execute the image segmentation thread;
[0115] The pyramid layer module is used to execute pyramid layer threads;
[0116] The image saving module is used to execute the image saving thread.
[0117] like Figure 3-10As shown, the specific process of digital slice scanning using the multi-threaded digital slice scanning device in this embodiment is as follows.
[0118] 1. Place the glass slide into the digital section scanner to obtain a navigation preview image, identify the sample tissue, and obtain all scanning fields.
[0119] 2. Start scanning and start the following threads: (1) Device movement command sending thread; (2) Image acquisition thread; (3) Image processing thread; (4) Image registration thread; (5) Image fusion thread; (6) Image segmentation thread; (7) Other layers of the pyramid thread; (8) Image saving thread.
[0120] 3. The working process of the device movement command sending thread is as follows: Set the command sending wait delay to S1 milliseconds;
[0121] 3.1 Obtain a data point from the list of all fields to be scanned and send it to the digital slice scanner control system; and record the number of fields of view to be acquired, viewNum, incremented by 1; if there is no data to be scanned, exit this thread.
[0122] 3.2 Determine whether the entire field of view has been acquired, i.e., viewNum = 0; if not acquired (viewNum is not equal to 0), delay for S1 milliseconds, S1 = 2 * S1; and go to 3.2 to continue to determine whether the acquisition is complete; if acquired, set S1 = S1 / 2 and go to 3.1 to get a new column.
[0123] 4. The image acquisition thread works as follows: The image acquisition waiting delay time is set to S2 milliseconds;
[0124] 4.1 Determine whether the "Device Movement Command Sending Thread" has ended and whether the required field-of-view image is 0 (whether viewNum equals 0); if it has not ended and the required image is not 0, proceed to 4.2; if it has ended and the required image is 0, end this thread.
[0125] 4.2 Does the number of images to be processed (backup in the next thread) exceed the threshold? (The threshold is set according to the memory situation. If the threshold is set too low, the computing power cannot keep up and there will be a problem of a sharp increase in memory.) If it exceeds the preset threshold, delay for S2 milliseconds, and S2 = 2 * S2, and go to 4.2 to continue to judge the situation of the images to be processed.
[0126] If it is less than the threshold, then S2 = S2 / 2 and images are acquired according to the sent acquisition command. For each acquired view image, viewNum is decremented by one; and the number of images to be processed, processNum, is incremented by one, and we go to 4.3.
[0127] 4.3 Determine if viewNum is greater than 0. If it is greater than 0, go to 4.2; if it is equal to 0, go to 4.1.
[0128] 5. The image processing thread works as follows: The image processing wait time is set to S3 milliseconds;
[0129] 5.1 Determine if the "Image Acquisition Thread" has ended and if the number of images to be processed is 0; if it has not ended and the number of images to be acquired is not 0, proceed to 5.2; if it has ended and the number of images to be processed is 0, then terminate this thread.
[0130] 5.2 Does the number of images to be registered exceed the threshold? (The threshold should be set according to the memory situation. If the threshold is set too low, the computing power will not be able to keep up, and the memory will increase sharply.) If it exceeds the preset threshold, delay for 3 milliseconds; go to 5.3.
[0131] If it is less than the threshold, proceed to 5.4;
[0132] 5.3 If S3 is greater than 500 milliseconds, start another image processing thread, and set S3 = 2 * S3, and go to 5.2 to continue judging the image that needs to be registered;
[0133] 5.4 In all threads, S3 = S3 / 2 and the images are processed separately. Each thread decrements the number of images to be processed (processNum) by one and increments the number of slices to be registered (locationNum). (Threads perform mutual exclusion operations on the processing of the same variable. After multiple threads are started, there may be a situation where some threads have no images to process. In this case, the threads are not shut down, but the extra threads are made to wait.) Go to 5.5.
[0134] 5.5 Determine if the number of images to be processed, processNum, is greater than 0. If it is greater than 0, proceed to 5.2; if it is equal to 0, proceed to 5.1.
[0135] 6. The image registration thread works as follows: The image registration waiting time is set to S4 milliseconds;
[0136] 6.1 Determine if all "image processing threads" have ended and if the number of images to be registered is 0; if they have not ended and the number of images to be registered is not 0, proceed to 6.2; if they have ended and the number of images to be registered is 0, terminate this thread.
[0137] 6.2 Does the number of images to be fused exceed the threshold? (The threshold is set according to the memory situation. If the threshold is set too low, the computing power will not be able to keep up, and the memory will increase sharply.) If it exceeds the preset threshold, delay for S4 milliseconds, and S4 = 2 * S4, and then go to 6.2 to continue to judge the situation of the images to be fused.
[0138] If it is less than the threshold, then S4 = S4 / 2 and image registration is performed on the images to be registered as needed, and locationNum is decremented by one for each completed field-of-view image; and the number of images to be fused, fuseNum, is incremented by one, going to 6.3;
[0139] 6.3 Determine if locationNum is greater than 0. If it is greater than 0, go to 6.2; if it is equal to 0, go to 6.1.
[0140] 7. The image fusion thread works as follows: The image registration waiting time is set to 5 milliseconds;
[0141] 7.1 Determine if the "Image Registration Thread" has ended and if the number of images to be merged is 0; if it has not ended and the number of images to be merged is not 0, proceed to 7.2; if it has ended and the number of images to be merged is 0, end this thread.
[0142] 7.2 Does the number of images to be segmented exceed the threshold? (The threshold is set according to the memory situation. If the threshold is set too small, the computing power cannot keep up and the memory will increase sharply.) If it exceeds the preset threshold, delay for S5 milliseconds, and S5 = 2 * S5, and then go to 7.2 to continue to judge the situation of the images to be segmented.
[0143] If it is less than the threshold, then S5 = S5 / 2 and perform image fusion as needed, and decrement fuseNum by one for each completed field-of-view image; and increment splitNum by one for the number of images to be segmented, and go to 7.3;
[0144] 7.3 Determine if fuseNum is greater than 0. If it is greater than 0, go to 7.2; if it is equal to 0, go to 7.1.
[0145] 8. The image segmentation thread works as follows: The image segmentation waiting time is set to 6 milliseconds;
[0146] 8.1 Determine if the "Image Fusion Thread" has ended and if the number of images to be segmented is 0; if it has not ended and the number of images to be segmented is not 0, proceed to 8.2; if it has ended and the number of images to be segmented is 0, end this thread.
[0147] 8.2 Does the number of images that need to create a pyramid layer exceed the threshold? (The threshold is set according to the memory situation. If the threshold is set too low, the computing power cannot keep up and there will be a problem of a sharp increase in memory.) If it exceeds the preset threshold, delay for S6 milliseconds, and S6 = 2 * S6, and go to 8.2 to continue to judge the number of images that need to create a pyramid layer.
[0148] If it is less than the threshold, then S6 = S6 / 2 and image segmentation is performed on the images to be segmented as needed, and splitNum is decremented by one for each completed field-of-view image; and the number of images that need to be created (pyramidNum) is incremented by one, going to 8.3;
[0149] 8.3 Determine if splitNum is greater than 0. If it is greater than 0, go to 8.2; if it is equal to 0, go to 8.1.
[0150] 9. The working process of other layers in the pyramid format is as follows: Set the waiting time for creating the pyramid layer image to 7 milliseconds;
[0151] 9.1 Determine if the "Image Segmentation Thread" has ended and if the number of images requiring pyramid layers is 0; if it has not ended and the number of images requiring pyramid layers is not 0, proceed to 9.2; if it has ended and the number of images requiring pyramid layers is 0, end this thread.
[0152] 9.2 Check if the number of tile images to be saved is greater than the threshold (the threshold is set according to the memory situation. If the threshold is set too small, the computing power cannot keep up and the memory will increase sharply). If it is greater than the preset threshold, delay for S7 milliseconds, and S7 = 2 * S7, and go to 9.2 to continue to judge the image situation of the tile to be saved.
[0153] If it is less than the threshold, then S7 = S7 / 2 and create pyramid layer images as needed, and decrement the number of pyramid layer images created (pyramidNum) by one for each completed pyramid layer; and increment the number of tile images to be saved (tileNum) by one, then go to 9.3;
[0154] 9.3 Determine if pyramidNum is greater than 0. If it is greater than 0, go to 9.2; if it is equal to 0, go to 9.1.
[0155] 10. The thread for saving the tile map is set to wait for 8 milliseconds (S);
[0156] 10.1 Determine if the "creating pyramid layer thread" has ended and if the number of tile images to be saved is 0; if it has not ended and the number of tile images to be saved is not 0, proceed to 10.2; if it has ended and the number of tile images to be saved is 0, end the tile image saving thread, proceed to 11 to end this thread and end the entire scanning process.
[0157] 10.2 If the tileNum to be saved is greater than 0, save the tile map, decrement tileNum by one, and go back to 10.2; if it is equal to 0, go back to 10.1.
[0158] 11. All scanning threads have finished, and the entire scanning process is complete.
[0159] Calculation example
[0160] Taking the initial value of the waiting time S1-S8 for each thread as 50 milliseconds as an example, Figures 3-10 As shown, the specific process of digital slice scanning in this invention is as follows.
[0161] 1. Place the glass slide into the digital section scanner to obtain a navigation preview image, identify the sample tissue, obtain all scanned fields, and put them into a listScanView;
[0162] 2. Start the scanning-related threads: (1) device movement command sending thread sendPositionThread; (2) image acquisition thread pictureCaptureThread; (3) image processing thread pictureProcessThread; (4) image registration thread pictureLocatedThread; (5) image fusion thread pictureFuseThread; (6) image segmentation thread pictureSplitThread; (7) other pyramid layer threads picturePyramidThread; (8) image saving thread pictureSaveThread;
[0163] 3. Set the command sending delay S1 = 50 milliseconds (set the delay according to the computer's processing capacity);
[0164] 3.1 Obtain data from listScanView and send it to the digital slice scanner control system; increment viewNum to indicate the number of fields of view to be acquired;
[0165] 3.2viewNum equals 1; delay 50 milliseconds, S1 = S1 * 2 = 100 milliseconds;
[0166] 3.2 viewNum equals 0; delay 100 milliseconds, S1 = S1 / 2 = 50 milliseconds; go to 3.1 to send instructions in a loop;
[0167] 3.1 Once all commands to be sent in listScanView have been sent, exit the thread and set boolSendPositionFinish = true;
[0168] 4. Set the image acquisition delay time to S2 = 50 milliseconds;
[0169] 4.1 If boolSendPositionFinish is false and viewNum = 1, proceed to 4.2;
[0170] 4.2 The number of images to be processed (processNum) is less than the threshold of 10; S2 = S2 / 2 = 25, acquire images, and decrement viewNum, increment the number of images to be processed (processNum); go to 4.3;
[0171] 4.3 viewNum equals 0; go to 4.1;
[0172] 4.1 If boolSendPositionFinish is false and viewNum = 5, proceed to 4.2;
[0173] 4.2 The number of images to be processed, processNum, is greater than the threshold of 10; delay 25 milliseconds, S2 = S2 * 2 = 100 milliseconds; go to 4.2;
[0174] 4.2 The number of images to be processed (processNum) is less than the threshold of 10; S2 = S2 / 2 = 25, acquire images, and decrement viewNum, increment the number of images to be processed (processNum); go to 4.3;
[0175] 4.3 viewNum is not equal to 0; go to 4.2;
[0176] 4.2 The process is repeated in a loop; eventually, it returns to 4.1.
[0177] 4.1 When boolSendPositionFinish is true and viewNum = 0, the thread ends and pictureCaptureFinish = true;
[0178] 5. Set the image processing wait time to S3 = 50 milliseconds;
[0179] 5.1 With pictureCaptureFinish = false and processNum = 10, go to 5.2;
[0180] 5.2 The number of locations (locationNum) to be registered is less than the threshold of 10; proceed to 5.4;
[0181] 5.4S3 = S3 / 2 = 25 milliseconds; decrement the number of images to be processed (processNum); and increment the number of slices to be registered (locationNum); go to 5.5;
[0182] 5.5 If processNum is greater than 0, proceed to 5.2;
[0183] 5.2 If the number of locations (locationNum) to be registered is greater than the threshold of 10, delay for 25 milliseconds; proceed to 5.3;
[0184] 5.3 If S3 is less than 500 milliseconds, proceed to 5.2;
[0185] 5.2 Loop through the process until all images have been processed, then proceed to 5.1;
[0186] 5.1 Set pictureCaptureFinish = true and processNum = 0; when the thread ends, set pictureProcessFinish = true.
[0187] For (4) the image registration thread pictureLocatedThread; (5) the image fusion thread pictureFuseThread; (6) the image segmentation thread pictureSplitThread; (7) the other layers of the pyramid thread picturePyramidThread; and (8) the image saving thread pictureSaveThread, each thread completes its processing according to the same processing idea. Whether to delay or wait depends on whether there is a backlog of downstream threads. If the backlog is greater than the threshold, then delay or wait.
[0188] After all the above threads have finished processing, proceed to step 11.
[0189] 11. All scanning threads have finished, and the entire scanning process is complete.
[0190] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention and not to limit it. Although the present invention has been described in detail with reference to the above embodiments, those skilled in the art should understand that modifications or equivalent substitutions can still be made to the specific implementation of the present invention. Any modifications or equivalent substitutions that do not depart from the spirit and scope of the present invention should be covered within the scope of protection of the claims of the present invention.
Claims
1. A multi-thread based digital slide scanning method, characterized in that, The device movement instruction sending thread, the image acquisition thread, the image processing thread, the image registration thread, the image fusion thread, the image segmentation thread, the pyramid layer thread and the image saving thread are provided with waiting time and the waiting time is dynamically adjusted; The process of dynamically adjusting the waiting time by the device movement instruction sending thread is: judging whether the sent field of view is completely acquired according to the data in the scanning list, doubling the waiting time if not completed, halving the waiting time if completed, and repeating the process until all data in the scanning list are traversed. The process of dynamically adjusting the waiting time by the image acquisition thread is: doubling the waiting time if the number of images to be processed is greater than a preset threshold, halving the waiting time if the number of images to be processed is less than the threshold, and repeating the process. The process of dynamically adjusting the waiting time by the image processing thread is: delaying if the number of images to be registered is greater than a preset threshold, starting another image processing thread if the waiting time is greater than 500 milliseconds, doubling the waiting time and repeating the process if the number of images to be registered is greater than the threshold, and halving the waiting time and processing the images if the number of images to be registered is less than the threshold. The process of dynamically adjusting the waiting time by the image registration thread is: doubling the waiting time if the number of images to be fused is greater than a preset threshold, halving the waiting time if the number of images to be fused is less than the threshold, and repeating the process. The process of dynamically adjusting the waiting time by the image fusion thread is: doubling the waiting time if the number of images to be segmented is greater than a preset threshold, halving the waiting time if the number of images to be segmented is less than the threshold, and repeating the process. The process of dynamically adjusting the waiting time by the image segmentation thread is: doubling the waiting time if the number of images to be created into pyramid layers is greater than a preset threshold, halving the waiting time if the number of images to be created into pyramid layers is less than the threshold, and repeating the process. The process of dynamically adjusting the waiting time by the pyramid layer thread is: doubling the waiting time if the number of images to be saved into tiles is greater than a preset threshold, halving the waiting time if the number of images to be saved into tiles is less than the threshold, and repeating the process.
2. The multi-thread based digital slide scanning method of claim 1, wherein, The device movement instruction sending thread is provided with a waiting delay time S1, and comprises: obtaining a data from the scanning list and recording the number of fields of view to be acquired as 1; judging whether the sent field of view is completely acquired, doubling the delay time S1 if not completed, halving the delay time S1 if completed, and returning to the previous step to obtain the next data from the scanning list until all data in the scanning list are traversed.
3. The multi-thread based digital slide scanning method of claim 2, wherein, Setting the image acquisition waiting delay time as S2 milliseconds, the image acquisition thread comprises: Judging whether the "device movement instruction sending thread" is ended and whether the number of images to be acquired is 0; if not and not 0, entering the next step; if yes and 0, ending the thread; If the number of images to be processed is greater than a preset threshold, doubling the delay time S2 and then judging the number of images to be processed; If the number of images to be processed is less than the threshold, halving the delay time S2 and then acquiring images according to the sent acquisition instructions, and reducing the number of fields of view by 1 each time an image is acquired; and adding 1 to the number of images to be processed and then entering the next step; Judging whether the number of fields of view is greater than 0; if yes, going to the second step; if no, going to the first step.
4. The multi-thread based digital slide scanning method of claim 3, wherein, Setting the image processing waiting time as S3 milliseconds, the image processing thread comprises: Judging whether the "image acquisition thread" is ended and whether the number of images to be processed is 0; if not and not 0, entering the next step; if yes and 0, ending the thread; Judging whether the number of images to be registered is greater than a threshold; if yes, delaying S3 milliseconds and then entering the next step; if no, going to the fourth step; If S3 is greater than 500 milliseconds, starting another image processing thread, doubling the delay time S3 and then going to the second step to judge the number of images to be registered; Halving the delay time S3 and then processing the images respectively, and reducing the number of images to be processed by 1 each time; and adding 1 to the number of slices to be registered; Judging whether the number of images to be processed is greater than 0; if yes, going to the second step; if no, going to the first step.
5. The multi-thread based digital slide scanning method of claim 4, wherein, Setting the image registration waiting time as S4 milliseconds, the image registration thread comprises: Judging whether all the "image processing threads" are ended and whether the number of images to be registered is 0; if not and not 0, entering the next step; if yes and 0, ending the thread; Judging whether the number of images to be fused is greater than a threshold; if yes, doubling the delay time S4 and then judging the number of images to be fused; If no, halving the delay time S4 and then registering the images according to the number of images to be registered, and reducing the number of slices to be registered by 1 each time a field of view image is completed; adding 1 to the number of images to be fused and then entering the next step; Judging whether the number of slices is greater than 0; if yes, going to the second step; if no, going to the first step.
6. The multi-thread based digital slide scanning method of claim 5, wherein, Setting the image fusion waiting time as S5 milliseconds, the image fusion thread comprises: Judging whether the "image registration thread" is ended and whether the number of images to be fused is 0; if not and not 0, entering the next step; if yes and 0, ending the thread; whether the number of images needing segmentation is greater than a threshold value, if greater than the preset threshold value, doubling the delay time S5 and continuing to judge the images needing segmentation; if less than the threshold value, halving the delay time S5 and performing image fusion according to the images needing fusion, and reducing the number of images needing fusion by 1 after completing one field of view image; and increasing the number of images needing segmentation by 1, and entering the next step; judging whether the number of images needing fusion is greater than 0, if greater than 0, turning to the second step; if equal to 0, turning to the first step.
7. The multi-thread based digital slide scanning method of claim 6, wherein, setting the image segmentation waiting time as S6 milliseconds, the image segmentation thread comprising: judging whether the "image fusion thread" is ended and the number of images needing segmentation is 0; if not ended and the number of images needing segmentation is not 0, entering the next step; if ended and the number of images needing segmentation is 0, ending the thread; whether the number of images needing to create pyramid layers is greater than a threshold value, if greater than the preset threshold value, doubling the delay time S6 and continuing to judge the images needing to create pyramid layers; if less than the threshold value, halving the delay time S6 and performing image segmentation according to the images needing segmentation, and reducing the number of images needing segmentation by 1 after completing one field of view image; and increasing the number of images needing to create pyramid layers by 1, and entering the next step; judging whether the number of images needing segmentation is greater than 0, if greater than 0, turning to the second step; if equal to 0, turning to the first step.
8. The multi-thread based digital slide scanning method of claim 7, wherein, setting the waiting time for creating pyramid layer images as S7 milliseconds, the pyramid layer thread comprising: judging whether the "image segmentation thread" is ended and the number of images needing to create pyramid layers is 0; if not ended and the number of images needing to create pyramid is not 0, entering the next step; if ended and the number of images needing to create pyramid layers is 0, ending the thread; whether the number of images needing to save tiles is greater than a threshold value, if greater than the preset threshold value, doubling the delay time S7 and continuing to judge the images needing to save tiles; if less than the threshold value, halving the delay time S7 and performing the images creating pyramid layers according to the images needing to create pyramid layers, and reducing the number of images needing to create pyramid layers by 1 after completing one; and increasing the number of images needing to save tiles by 1, and entering the next step; judging whether the number of images needing to create pyramid layers is greater than 0, if greater than 0, turning to the second step; if equal to 0, turning to the first step.
9. The multi-thread based digital slide scanning method of claim 8, wherein, setting the thread waiting time for saving tile images as S8 milliseconds, the saving image thread comprising: judging whether the "pyramid layer creating thread" is ended and the number of images needing to save tiles is 0; if not ended and the number of images needing to save tiles is not 0, entering the next step; if ended and the number of images needing to save tiles is 0, ending the tile image saving thread; judging whether the number of images needing to save tiles is greater than 0, then saving the tile images, and reducing the number of images needing to save tiles by 1 and continuing the step; if equal to 0, turning to the first step.
10. A multi-threaded based digital slide scanning apparatus, characterized in that, The device is used for implementing the multi-thread based digital slice scanning method as claimed in any one of claims 1-9, and comprises: an instruction sending module for executing a device movement instruction sending thread; an image acquisition module for executing an image acquisition thread; an image processing module for executing an image processing thread; an image registration module for executing an image registration thread; an image fusion module for executing an image fusion thread; an image segmentation module for executing an image segmentation thread; a pyramid layer module for executing a pyramid layer thread; an image saving module for executing a saving image thread.
Citation Information
Patent Citations
Multi-thread multi-core microscope cell image rapid scanning processing method based on computer
CN107479961A
Context pyramid fusion network and image segmentation method
CN110689083A