A 4K Medical Image Memory Reading Method

By adopting multi-threaded synchronization and queue temporary storage methods in 4K medical image memory reading, the problem of low memory reading efficiency in the prior art is solved, and real-time and efficient image data transmission is achieved.

CN116188246BActive Publication Date: 2025-06-27HAIYUAN LIHENG (QINGDAO) MEDICAL INSTR CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202310050108.0
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-02-01
Publication Date
2025-06-27
Estimated Expiration
2043-02-01

AI Technical Summary

Technical Problem

In the prior art, the 4K resolution memory reading efficiency of medical-grade images is low, especially the single-thread reading method, which leads to low transmission efficiency and cannot meet the needs of real-time output, resulting in lag in the picture.

Method used

The multi-thread synchronization method is adopted to define the shared memory and thread control amount. The write part and the transit space alternately process data through multiple cache areas, and the read part forms a queue for GPU to call, ensuring real-time and efficient data transmission.

Benefits of technology

Through multi-threaded concurrent execution and queue storage, memory reading efficiency is improved, the number of accesses to shared memory is reduced, image data is avoided, and real-time output and efficient transmission are ensured.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116188246B_ABST
    Figure CN116188246B_ABST
Patent Text Reader

Abstract

The present invention discloses a method for reading 4K medical image memory, including: defining a shared memory and a thread control variable step, saving the names of the defined shared memory and the thread control variable in the shared variable segment, an initialization step, applying for a shared memory from the operating system according to the name of the shared memory, and initializing the thread control variable; an image data memory reading step, the GPU calls an interface to read image data from the reading part, processes the image data by the GPU, and sends the processed image data to a display device for display. The 4K medical image memory reading method of the present invention, by opening up multiple shared memories and using a multi-thread synchronization method at the same time, multiple write buffer areas in the writing part are used to alternately receive image data from an image acquisition device, and can efficiently transfer video data into the memory in real time, ensuring that the data will not be in a state of waiting for data.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention belongs to the technical field of image processing, and more specifically, relates to a method for reading 4K medical image memory. Background Art

[0002] With the advent of the intelligent era, the performance of most medical products has also developed in the direction of intelligence. The role of medical-grade images has become increasingly obvious. Excellent medical-grade images can perfectly present lesions and related organs and tissues in front of doctors, reduce the difficulty of surgery, and improve the success rate of surgery. It is an indispensable device for minimally invasive surgery and medical endoscopy systems.

[0003] Medical-grade images use 4K resolution, which belongs to ultra-high definition resolution, and can obtain internal tissue images of the human body or a part of the human body in a non-invasive manner. Image processing devices generally read image information from image acquisition devices by means of memory reading.

[0004] Currently, memory reading basically uses a single-threaded reading method. Due to the singularity of single-threaded execution, the transmission efficiency of this method is not high. Especially for high-definition images with 4K resolution, the amount of data read from memory is very large, and there is currently no good solution to efficiently read big data. In the prior art, when writing data into shared memory in the writing part, the reading part must wait for the shared memory writing to complete. When the reading part reads the shared memory, the writing part must wait for the shared memory reading to complete, which will cause a lot of time waste, and this method far from meets the real-time output requirements of detection devices, resulting in frame freezing. On the other hand, since the reading speed of memory is much higher than the processing speed of the GPU, the read image frames need to be temporarily stored somewhere to avoid data congestion. At this time, concurrent execution of multiple threads is required to improve the reading efficiency of memory storage, and a queue can be set up to temporarily store the image data to avoid loss of image data. Summary of the Invention

[0005] In view of the problem that when a computer device reads an image from an image acquisition device in the prior art, a single-threaded memory reading method is adopted, especially for high-definition images with 4K resolution, the amount of data read from memory is very large, resulting in low transmission efficiency, the present invention proposes a method for reading 4K medical image memory, which can solve the above problems.

[0006] To achieve the above-mentioned invention purpose, the present invention is implemented by the following technical solutions:

[0007] A method for reading 4K medical image memory, comprising:

[0008] Steps for defining shared memory and thread control variables: Save the names of the defined shared memory and thread control variables in the shared variable segment. The shared memory includes a writing part, a transfer space, and a reading part. The writing part includes at least two writing buffers. The transfer space includes at least two transfer buffers. The thread control variables include a first thread for receiving image data sent by an image acquisition device and writing it to the writing part, a second thread for reading the image data from the writing part and writing it to the transfer space, and a third thread for reading the image data from the transfer space and writing it to the reading part.

[0009] Initialization step: Apply for shared memory from the operating system according to the name of the shared memory and initialize the thread control variables.

[0010] Image data memory reading step: Start the first thread and write the image data sent by the image acquisition device to one of the idle writing buffers until the writing buffer is full. The first thread controls writing the image data to the next idle writing buffer. At the same time, start the second thread to read the image data from the full writing buffer and write it to one of the idle transfer buffers until the transfer buffer is full. The second thread controls writing the image data to the next idle transfer buffer. At the same time, start the third thread to read the image data from the full transfer buffer and write it to the reading part.

[0011] The GPU call interface reads the image data from the reading part, processes it by the GPU, and sends the processed image data to the display device for display.

[0012] In some embodiments, after the second thread reads the image data from the writing buffer, the storage space of the writing buffer is released.

[0013] In some embodiments, after the third thread reads the image data from the transfer buffer, the storage space of the transfer buffer is released.

[0014] In some embodiments, after each frame of image data in the reading part is passed to the GPU call interface for processing and completed, the image data is dequeued from the reading part.

[0015] In some embodiments, it further includes a step of writing the image data processed by the GPU in binary form to a storage module for storage.

[0016] In some embodiments, in the steps for defining shared memory and thread control variables, use a shared variable DLL file and save the names of the shared memory and thread control variables in the shared variable segment in string form.

[0017] In some embodiments, in the initialization step, the writing part applies for shared memory from the operating system using the name of the shared memory, the reading part opens the shared memory according to the shared memory name, and then the writing part and the reading part respectively map the shared memory into the handler address space.

[0018] In some embodiments, the initialization step further includes: the writing part and the reading part respectively load the shared variable segment, read the name of the thread control quantity from the shared variable segment, the writing part creates a thread control quantity according to the name of the thread control quantity, and the reading part opens the corresponding thread control quantity according to the name of the thread control quantity.

[0019] In some embodiments, the memory space of the transfer buffer is larger than the memory space of the write buffer. In the step of reading image data from memory, when the write buffer is full, the writing part wakes up the second thread. The second thread first writes the valid data length of the write buffer into the first 8 bytes of the transfer buffer, and then copies the content of the write buffer into the space starting from the 9th byte of the transfer buffer.

[0020] In some embodiments, in the step of reading image data from memory, after the second thread finishes writing to the transfer buffer, it activates a memory update event. The activation of the memory update event controls the reading part to wake up the third thread. The third thread first retrieves the valid data length from the first 8 bytes of the transfer buffer, and then copies the data content of the transfer buffer into the queue space of the reading part according to the valid data length.

[0021] Compared with the prior art, the advantages and positive effects of the present invention are:

[0022] The 4K medical image memory reading method of the present invention: 1. By creating multiple shared memories and using the method of multiple thread synchronizations, multiple write buffers in the writing part are used to alternately receive image data from the image acquisition device, and multiple transfer buffers in the transfer space are used to alternately read and temporarily store the image data in the write buffer, which can clear the space for the write buffer. The reading part is used to read the image data in the transfer space and form a queue for GPU to call, which can efficiently transfer video data into memory in real time and ensure that the memory block does not wait for data. 2. This solution can reduce the number of accesses to the shared memory block, reduce the number of code scheduling times, and improve the operation efficiency. 3. Setting up a queue can temporarily store the continuously loaded new image data to prevent video frame loss. 4. It can reduce the locking and unlocking operations on the shared memory block, reduce the system resource overhead, and improve the operation efficiency of the program by waking up the thread.

[0023] Other features and advantages of the present invention will become more apparent after reading the specific embodiments of the present invention in conjunction with the accompanying drawings. Description of the Drawings

[0024] In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the accompanying drawings required for use in the embodiments will be briefly introduced below. Obviously, the accompanying drawings in the following description are some embodiments of the present invention. For those of ordinary skill in the art, without creative efforts, other accompanying drawings can be obtained based on these drawings. Figure 1 is a flowchart of an embodiment of the 4K medical image memory reading method proposed by the present invention;

[0025] Figure 1 is a schematic diagram of a state of data reading in an embodiment of the 4K medical image memory reading method proposed by the present invention;

[0026] Figure 2 is another schematic diagram of a state of data reading in an embodiment of the 4K medical image memory reading method proposed by the present invention;

[0027] Figure 3 is yet another schematic diagram of a state of data reading in an embodiment of the 4K medical image memory reading method proposed by the present invention;

[0028] Figure 4 is another schematic diagram of a state of data reading in an embodiment of the 4K medical image memory reading method proposed by the present invention;

[0029] Figure 5 is a schematic diagram of the storage space of the transfer buffer in an embodiment of the 4K medical image memory reading method proposed by the present invention. Detailed Embodiments

[0030] To make the objectives, technical solutions, and advantages of the embodiments of the present invention clearer, the technical solutions in the embodiments of the present invention will be clearly and completely described below in conjunction with the accompanying drawings in the embodiments of the present invention. Obviously, the described embodiments are some, but not all, of the embodiments of the present invention. Based on the embodiments of the present invention, all other embodiments obtained by those of ordinary skill in the art without creative efforts fall within the scope of protection of the present invention.

[0031] It should be noted that in the description of the present invention, the terms indicating the direction or positional relationship such as "upper", "lower", "left", "right", "vertical", "horizontal", "inner", "outer", etc. are based on the direction or positional relationship shown in the drawings. This is only for convenience of description and does not indicate or imply that the device or element must have a specific orientation, be constructed and operated in a specific orientation. Therefore, it should not be construed as a limitation to the present invention. In addition, the terms "first" and "second" are only used for descriptive purposes and cannot be construed as indicating or implying relative importance. In the description of the present invention, the meaning of "a plurality" is two or more unless otherwise specifically defined.

[0032] In the present invention, unless otherwise clearly defined and limited, the terms such as "install", "connect", "couple", "fix", etc. should be understood in a broad sense. For example, it can be a fixed connection, a detachable connection, or integrated; it can be a mechanical connection or an electrical connection; it can be directly connected or indirectly connected through an intermediate medium, and it can be the communication inside two elements or the interaction relationship between two elements. For those of ordinary skill in the art, the specific meanings of the above terms in the present invention can be understood according to specific situations. Embodiment

[0033] This embodiment provides a method for reading 4K medical image memory, as Figure 1 shown, including:

[0034] Steps of defining shared memory and thread control variables, saving the names of the defined shared memory and thread control variables in the shared variable segment. The shared memory includes a writing part, a transfer space, and a reading part. The writing part includes at least two writing buffers, the transfer space includes at least two transfer buffers, and the thread control variables include a first thread for receiving image data sent by an image acquisition device and writing it into the writing part, a second thread for reading out the image data in the writing part and writing it into the transfer space, and a third thread for reading out the image data in the transfer space and writing it into the reading part;

[0035] Initialization step, applying for shared memory from the operating system according to the name of the shared memory and initializing the thread control variables;

[0036] Steps of reading image data into memory, as Figures 2 - 4As shown, start the first thread, write the image data sent by the image acquisition device into one of the idle write buffer areas until the write buffer area is full. The first thread controls to write the image data into the next idle write buffer area. At the same time, start the second thread to read and write the image data in the full write buffer area into one of the idle transfer buffer areas until the transfer buffer area is full. The second thread controls to write the image data into the next idle transfer buffer area. At the same time, start the third thread to read and write the image data in the full transfer buffer area into the reading part;

[0037] The GPU call interface reads the image data from the reading part, processes it by the GPU, and sends the processed image data to the display device for display.

[0038] Since the reading speed of the memory is much higher than the processing speed of the GPU, 1. In this solution, by defining and allocating multiple shared memories and thread control variables, multiple write buffer areas in the writing part are used to alternately receive image data from the image acquisition device and temporarily store the read image frames. Multiple transfer buffer areas in the transfer space are used to alternately read and temporarily store the image data in the write buffer area, which can clear the space for the write buffer area and avoid congestion. The reading part is used to read the image data in the transfer space and enter the queue for GPU call, which can efficiently transfer video data into the memory in real time and ensure that the memory block does not wait for data. By adopting concurrent execution of multiple threads, the reading efficiency of the memory is improved, and a queue can be set to temporarily store the image data to avoid loss of image data after reading.

[0039] 2. This solution can reduce the number of accesses to the shared memory block, reduce the number of code scheduling times, and improve the operation efficiency. 3. Setting up a queue can temporarily store the continuously loaded new image data to prevent video frame loss. 4. It can reduce the locking and unlocking operations on the shared memory block, reduce the system resource overhead, and improve the operation efficiency of the program by waking up the thread.

[0040] In some embodiments, after the second thread reads the image data in the write buffer area, the storage space of the write buffer area is released. The write buffer area can continue to receive new image data controlled by the first thread to be written. The write buffer area circulates in this way to avoid the technical problem that the memory reading process needs to wait for the GPU processing process.

[0041] In some embodiments, after the third thread reads the image data in the transfer buffer area, the storage space of the transfer buffer area is released. The transfer buffer area can continue to receive new image data controlled by the second thread to be written. The transfer buffer area circulates in this way to continuously read data from the write buffer area and clear the space for the write buffer area.

[0042] In this solution, multiple write buffers are opened to receive image data from the image acquisition device in turn, and multiple transfer buffers are opened to relay the image data. Compared with the method of simply doubling the number of write buffers, this solution can maximize the increase in data transfer paths.

[0043] In some embodiments, after each frame of image data in the reading part is passed into the GPU call interface for processing and completed, the image data is dequeued from the reading part to avoid memory leakage. The image data does not need to wait. After the GPU finishes processing the relevant image, the processed image can be sent to the display screen in real time through the function interface, and at the same time, the local disk will also save the processed image video.

[0044] In some embodiments, it further includes the step of writing the image data processed by the GPU into the storage module in binary form for storage.

[0045] If new image data is transferred into the memory while the GPU call interface is processing the image data, at this time, the memory management module enqueues the newly transferred image data, and the unprocessed image data will be temporarily stored in the queue of the reading part.

[0046] In some embodiments, in order for the processing program to know the shared memory name and thread control quantity name, in the step of defining the shared memory and thread control quantity, a shared variable DLL file is used, and the names of the shared memory and the thread control quantity are saved in the shared variable segment in the form of strings. The processing program loads this shared segment respectively, and then reads these strings in the shared segment to know the names of the shared memory and the thread control quantity.

[0047] In some embodiments, in the initialization step, the memory management module first creates a shared variable. The writing part applies for shared memory from the operating system using the name of the shared memory. When the application for shared memory is successful, the reading part opens the shared memory according to the shared memory name, and then the writing part and the reading part respectively map the shared memory into the processing program address space.

[0048] In some embodiments, the initialization step further includes: the writing part and the reading part respectively load the shared variable segment, read the name of the thread control quantity from the shared variable segment, the writing part creates a thread control quantity according to the name of the thread control quantity, and the reading part opens the corresponding thread control quantity according to the name of the thread control quantity.

[0049] In some embodiments, the memory space of the transfer buffer is larger than that of the write buffer. In the step of reading the image data memory, when the write buffer is full, the writing part wakes up the second thread, as Figure 5As shown, the second thread first writes the valid data length in the write buffer into the first 8 bytes of the transfer buffer, and then copies the content of the write buffer to the space starting from the 9th byte of the transfer buffer.

[0050] In some embodiments, in the step of reading the image data from memory, after the second thread finishes writing to the transfer buffer, it activates a memory update event. The activation of the memory update event controls the reading part to wake up the third thread. The third thread first retrieves the valid data length from the first 8 bytes of the transfer buffer, and then copies the data content of the transfer buffer to the queue space of the reading part according to this valid data length.

[0051] Taking the example of creating two write buffers A1 and A2, and two transfer buffers α1 and α2, the memory management module continuously obtains image data from the receiving module and starts the first thread to write these data segments into A1. When buffer A1 is full, that is, buffer A1 cannot store more data, the writing part of the memory management module wakes up the second thread. The second thread first writes the valid data length of buffer A1 into the first 8 bytes of α1, and then copies the content of buffer A1 to the space starting from the 9th byte of the transfer buffer α1. The stored content of the transfer buffer α1 is as Figure 4 shown. While the second thread is working, the memory management module calls the first thread to write the image data segments from the reading module into buffer A2, as Figure 3 shown. After the second thread finishes writing to α1, it activates a memory update event. The activation of this event causes the reading part of the memory management module to wake up the third thread. The third thread first retrieves the data length from the first 8 bytes of space α1, and then copies the data content of space α1 to the queue space according to this length. When buffer A2 is full, the writing part of the memory management module notifies the second thread to write the content of A2 into α2. Similar to the previous steps, first write the valid data length of buffer A2 into the first 8 bytes of α2, and then copy the content of buffer A2 to the space starting from the 9th byte of α2. While the second thread is working, the memory management module calls the first thread to receive image data segments and write them into buffer A1. After the second thread finishes writing to α2, it activates a memory update event, and then the writing part of the memory management module starts the third thread, and the third thread appends the content of α2 to the queue.

[0052] The above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit it; although the present invention has been described in detail with reference to the foregoing embodiments, for those of ordinary skill in the art, it is still possible to modify the technical solutions described in the foregoing embodiments, or perform equivalent replacements on some of the technical features; and these modifications or replacements do not make the essence of the corresponding technical solutions deviate from the spirit and scope of the technical solutions required to be protected by the present invention.

Claims

1. A 4K medical image memory reading method, characterized in that, Including: Steps of defining shared memory and thread control variables, saving the names of the defined shared memory and thread control variables in the shared variable segment. The shared memory includes a writing part, a transfer space, and a reading part. The writing part includes at least two writing buffers, the transfer space includes at least two transfer buffers, and the thread control variables include a first thread for receiving image data sent by an image acquisition device and writing it into the writing part, a second thread for reading the image data in the writing part and writing it into the transfer space, and a third thread for reading the image data in the transfer space and writing it into the reading part; Initialization step, applying for shared memory from the operating system according to the name of the shared memory and initializing the thread control variables; Image data memory reading step, starting the first thread, writing the image data sent by the image acquisition device into one of the idle writing buffers until the writing buffer is full. The first thread controls writing the image data into the next idle writing buffer. At the same time, starting the second thread, reading the image data in the full writing buffer and writing it into one of the idle transfer buffers until the transfer buffer is full. The second thread controls writing the image data into the next idle transfer buffer. At the same time, starting the third thread, reading the image data in the full transfer buffer and writing it into the reading part; The GPU call interface reads the image data from the reading part, processes it by the GPU, and sends the processed image data to the display device for display.

2. The 4K medical image memory reading method according to claim 1, wherein After the second thread reads the image data in the writing buffer, the storage space of this writing buffer is released.

3. The 4K medical image memory reading method according to claim 1, wherein After the third thread reads the image data in the transfer buffer, the storage space of this transfer buffer is released.

4. The 4K medical image memory reading method according to claim 1, wherein After each frame of image data in the reading part is passed into the GPU call interface for processing and completed, the image data is dequeued from the reading part.

5. The 4K medical image memory reading method according to claim 4, wherein It further includes the step of writing the image data processed by the GPU in binary form into the storage module for saving.

6. The 4K medical image memory reading method according to claim 1, characterized in that In the steps of defining shared memory and thread control variables, using the shared variable DLL file, saving the names of the shared memory and thread control variables in the shared variable segment in string form.

7. The 4K medical image memory reading method according to claim 6, wherein In the initialization step, the writing part applies for shared memory from the operating system using the name of the shared memory. The reading part opens the shared memory according to the shared memory name, and then the writing part and the reading part respectively map the shared memory into the process address space.

8. The 4K medical image memory reading method according to claim 7, wherein The initialization step further includes: the writing part and the reading part respectively load the shared variable segment, read the name of the thread control variable from the shared variable segment. The writing part creates a thread control variable according to the name of the thread control variable, and the reading part opens the corresponding thread control variable according to the name of the thread control variable.

9. The 4K medical image memory reading method according to any one of claims 1-8, characterized in that, The memory space of the intermediate buffer is larger than that of the write buffer. In the step of reading image data from memory, when the write buffer is full, the writing part wakes up the second thread. The second thread first writes the valid data length of the write buffer into the first 8 bytes of the intermediate buffer, and then copies the content of the write buffer into the space starting from the 9th byte of the intermediate buffer.

10. The 4K medical image memory reading method according to any one of claims 1-8, characterized in that, In the step of reading image data from memory, after the second thread finishes writing to the intermediate buffer, it activates a memory update event. The activation of the memory update event controls the reading part to wake up the third thread. The third thread first retrieves the valid data length from the first 8 bytes of the intermediate buffer, and then copies the data content of the intermediate buffer into the queue space of the reading part according to the valid data length.

Citation Information

Patent Citations

  • Image processing method, device and system, storage medium and computer equipment

    CN110163790A

  • Multi-process communication method based on shared memory backup mechanism

    CN113032162A