An image gradient determination method, apparatus, device and storage medium

By loading and storing the target pixel values ​​of an image in the shared memory of the graphics processor, and utilizing the two-dimensional physical structure and broadcasting mechanism of shared memory, the problem of cache misses is solved, and the image gradient is quickly determined, thus improving the efficiency of image gradient determination in the computer implementation process.

CN115049529BActive Publication Date: 2026-01-20SHANGHAI UNITED IMAGING HEALTHCARE
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202110251014.0
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-03-08
Publication Date
2026-01-20
Estimated Expiration
2041-03-08

AI Technical Summary

Technical Problem

In existing computer implementations, image gradient determination suffers from low performance due to cache misses, especially when calculating image gradients in the y-direction, where the probability of cache misses is high, resulting in slow speed.

Method used

By loading and storing the target pixel values ​​of the image in the shared memory of the graphics processor, utilizing the two-dimensional physical structure of the shared memory to avoid cache misses, employing a broadcast mechanism to resolve bank conflicts, and combining this with registers to store the neighborhood values ​​of edge pixels, the image gradient can be quickly determined.

Benefits of technology

It improves the speed of image gradient determination, avoids cache misses, and enhances the efficiency of image gradient determination in the computer implementation process.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115049529B_ABST
    Figure CN115049529B_ABST
Patent Text Reader

Abstract

Embodiments of the present application disclose a kind of image gradient determination method, device, equipment and storage medium.The method comprises: obtaining the pixel value of each pixel point in digital image that has been loaded into the global memory of graphics processor;According to the storage capacity of shared memory in graphics processor, determine target pixel value from each pixel value, load each target pixel value to the shared memory;Read each target pixel value from shared memory, and determine the image gradient of digital image on the pixel position of each target pixel value based on the reading result respectively.The technical scheme of the embodiment of the present application guarantees the locality of target pixel value in two-dimensional space by loading target pixel value in digital image to shared memory with two-dimensional physical structure, which can avoid cache miss in subsequent data reading process, thereby achieving the effect of improving the determination speed of image gradient in computer implementation process.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The embodiments of the present invention relate to the field of computer application technology, and in particular to an image gradient determination method, apparatus, device and storage medium. Background Technology

[0002] Image gradient is the gradient value of a digital image, commonly used in digital image processing for edge detection, image segmentation, and optimal solution finding. For a given digital image f(x,y), its two-dimensional column vector defined at coordinates (x,y) is expressed as follows:

[0003]

[0004] From a computer implementation perspective, the process of determining image gradients is usually implemented in the form of differences, which can be obtained based on the differences in pixel values ​​between adjacent pixels in the x-direction or y-direction, such as... Figure 1 As shown. However, this determination process is unlikely to achieve good performance if the computer's mechanism is not considered. This is because it often causes the CPU to be unable to obtain the data it needs from the cache, and has to read the data from memory. The bandwidth of the cache is often several orders of magnitude faster than that of memory. This cache miss process is one of the main reasons for poor computer performance.

[0005] Specifically, such as Figure 2 As shown, based on the principle of locality of reference in computer programs, when a computer reads data from memory, it doesn't just read data from a single location, but reads multiple adjacent data simultaneously to fill the cache line. Furthermore, since image matrices in C language are often row-major, the data needed for image gradient calculations in the x-direction can be directly mapped to the cache line, meaning there's a small probability of a cache miss when performing image gradient calculations in the x-direction. However, image gradient calculations in the y-direction require crossing rows. Due to the limited storage capacity of the cache line, the data needed for image gradient calculations in the y-direction inevitably exceeds the cache line's storage capacity, resulting in a high probability of a cache miss in the y-direction. Therefore, determining image gradients in computer implementations is relatively slow. Summary of the Invention

[0006] This invention provides an image gradient determination method, apparatus, device, and storage medium to achieve the effect of quickly determining image gradients during computer implementation.

[0007] In a first aspect, embodiments of the present invention provide an image gradient determination method, which may include:

[0008] Retrieve the pixel values ​​of each pixel in the digital image that has been loaded into the global memory of the graphics processor;

[0009] Based on the storage capacity of the shared memory within the graphics processor, the target pixel value is determined from each pixel value, and each target pixel value is loaded into the shared memory;

[0010] Read the values ​​of each target pixel from the shared memory, and determine the image gradient of the digital image at the pixel position where each target pixel value is located based on the reading results.

[0011] Optionally, loading the target pixel values ​​into shared memory may include:

[0012] For each thread running within the graphics processor, load the first pixel values ​​associated with the thread from each target pixel value into shared memory based on the thread.

[0013] Accordingly, reading the values ​​of each target pixel from shared memory and determining the image gradient of the digital image at the pixel location of each target pixel value based on the reading results can include:

[0014] For each thread, when it is detected that the thread has received a preset synchronization instruction, the thread reads the second pixel values ​​associated with the thread from the shared memory, and determines the image gradient of the digital image at the pixel position where each second pixel value is located from the reading result.

[0015] Optionally, the shared memory stores each first pixel value in a bucket data structure, with each bucket comprising multiple storage units, and the first pixel value is stored in the corresponding storage unit. After reading each second pixel value associated with a thread from the shared memory based on the thread, the above image gradient determination method may further include:

[0016] The second pixel value is obtained from the reading result and stored in the first unit of each storage unit. The result is then broadcast based on the graphics processor.

[0017] Optionally, the shared memory stores each first pixel value using a bucket data structure, where each bucket includes multiple storage units, and the first pixel value is stored in the corresponding storage unit. Determining the image gradient of the digital image at the pixel position of each second pixel value from the read results can include:

[0018] Based on the second pixel values ​​obtained from the reading results, determine the third pixel value located in the second cell of each storage unit, and the fourth pixel value located in the third cell of each storage unit that is adjacent to the second cell and belongs to the same bucket; based on the third pixel value and the fourth pixel value, determine the image gradient of the digital image at the pixel position where the third pixel value is located.

[0019] Based on this, optionally, determining the target pixel value from the pixel values ​​may include:

[0020] The target pixel value is determined from the pixel values ​​that have not yet been loaded into shared memory;

[0021] Accordingly, after determining the image gradient of the digital image at the pixel position of each second pixel value from the reading results, the above image gradient determination method may further include:

[0022] Repeat the steps based on the storage capacity of the shared memory within the graphics processor until there are no more pixel values ​​not loaded into the shared memory.

[0023] Optionally, loading the target pixel values ​​into shared memory may include:

[0024] Each target pixel value is loaded into shared memory, and for each target pixel value loaded into shared memory, the neighboring pixel values ​​adjacent to the edge pixel values ​​are loaded into the graphics processor's registers.

[0025] Accordingly, determining the image gradient of the digital image at the pixel location of each target pixel value based on the reading results can include:

[0026] For each target pixel value read, if the target pixel value is an edge pixel value, then the neighboring pixel values ​​adjacent to the edge pixel value are read from the register; the image gradient of the digital image at the pixel position where the edge pixel value is located is determined based on the neighboring pixel values ​​and the edge pixel values.

[0027] Optionally, the target pixel value includes the target real part value or the target imaginary part value of the magnetic resonance signal. The target real part value and the target imaginary part value belonging to the same magnetic resonance signal are loaded into different buckets in the shared memory.

[0028] Determining the image gradient of the digital image at the pixel location of each target pixel value based on the reading results can include:

[0029] The real and imaginary parts of the target belonging to the same magnetic resonance signal are obtained from the read target pixel values; the real and imaginary parts of the target are weighted, and the image gradient of the digital image at the pixel position corresponding to the weighted result is determined based on the read results.

[0030] Secondly, embodiments of the present invention also provide an image gradient determination apparatus, which may include:

[0031] The pixel value acquisition module is used to acquire the pixel value of each pixel in the digital image that has been loaded into the global memory of the graphics processor;

[0032] The shared memory loading module is used to determine the target pixel value from the pixel values ​​based on the storage capacity of the shared memory in the graphics processor, and load the target pixel value into the shared memory.

[0033] The image gradient determination module is used to read the values ​​of each target pixel from the shared memory and determine the image gradient of the digital image at the pixel position where each target pixel value is located based on the reading results.

[0034] Thirdly, embodiments of the present invention also provide an image gradient determination device, which may include:

[0035] One or more processors;

[0036] Memory, used to store one or more programs;

[0037] When one or more programs are executed by one or more processors, the one or more processors implement the image gradient determination method provided in any embodiment of the present invention.

[0038] Fourthly, embodiments of the present invention also provide a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the image gradient determination method provided in any embodiment of the present invention.

[0039] The technical solution of this invention determines the target pixel value from the pixel values ​​of each pixel in the digital image loaded into the global memory of the graphics processor by utilizing the storage capacity of the shared memory within the graphics processor. Since the shared memory has a two-dimensional physical structure, the locality of the target pixel values ​​in two-dimensional space is well guaranteed when loading them into the shared memory. Furthermore, when reading the target pixel values ​​from the shared memory, due to the locality of the target pixel values ​​in two-dimensional space, cache misses are avoided when determining the image gradient at the pixel location of each target pixel value, thus improving the speed of image gradient determination during computer implementation. The above technical solution, by loading the target pixel values ​​from the digital image into the shared memory with its two-dimensional physical structure, ensures the locality of the target pixel values ​​in two-dimensional space. Therefore, when determining the image gradient based on the target pixel values ​​read from the shared memory, cache misses are avoided, thereby improving the speed of image gradient determination during computer implementation. Attached Figure Description

[0040] Figure 1 This is a first schematic diagram of the process for determining image gradients in the prior art;

[0041] Figure 2 This is a schematic diagram of data reading during the determination of image gradients in existing technologies;

[0042] Figure 3 This is a flowchart of an image gradient determination method according to Embodiment 1 of the present invention;

[0043] Figure 4 This is a flowchart of an image gradient determination method according to Embodiment 2 of the present invention;

[0044] Figure 5 This is a schematic diagram of data reading in an image gradient determination method according to Embodiment 2 of the present invention;

[0045] Figure 6 This is a flowchart of an image gradient determination method according to Embodiment 3 of the present invention;

[0046] Figure 7 This is a flowchart of an image gradient determination method according to Embodiment 4 of the present invention;

[0047] Figure 8 This is a schematic diagram of an image gradient determination method applied to MR in Embodiment 4 of the present invention;

[0048] Figure 9 This is a structural block diagram of an image gradient determination device according to Embodiment 5 of the present invention;

[0049] Figure 10 This is a schematic diagram of the structure of an image gradient determination device according to Embodiment Six of the present invention. Detailed Implementation

[0050] The present invention will now be described in further detail with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative of the invention and not intended to limit it. Furthermore, it should be noted that, for ease of description, the accompanying drawings show only the parts relevant to the present invention, and not all of the structures.

[0051] Example 1

[0052] Figure 3This is a flowchart of an image gradient determination method provided in Embodiment 1 of the present invention. This embodiment is applicable to situations where image gradients are quickly determined during computer implementation, and is particularly suitable for improving the speed of image gradient determination by loading target pixel values ​​into shared memory with a two-dimensional physical structure. This method can be executed by the image gradient determination device provided in this embodiment of the invention. This device can be implemented in software and / or hardware, and can be integrated into an image gradient determination equipment, which can be various user terminals or servers.

[0053] See Figure 3 The method of this invention specifically includes the following steps:

[0054] S110. Obtain the pixel values ​​of each pixel in the digital image that has been loaded into the global memory of the graphics processor.

[0055] Digital images, also known as digital images or digital-to-digital images, are images obtained by digitizing analog images. They are images with pixels as their basic elements and can be stored and processed using digital computers or digital circuits. For example, digital images can be medical images, natural images, etc. Medical images are digital images acquired based on medical imaging equipment, such as magnetic resonance imaging (MR) images, computed tomography (CT) images, positron emission tomography (PET) images, etc. Natural images are digital images acquired based on general imaging equipment, such as mobile phones, digital cameras, webcams, camcorders, etc.

[0056] A graphics processing unit (GPU) is a microprocessor that performs graphics calculations on electronic devices. Global memory is the memory in a GPU that can be accessed by different threads; it can be understood as a memory module in the GPU.

[0057] In practical applications, optionally, the pixel values ​​of each pixel in the digital image can be loaded into memory first, and then loaded from memory into global memory. Therefore, once the pixel values ​​are loaded into global memory, they can be obtained from that global memory.

[0058] S120. Determine the target pixel value from each pixel value based on the storage capacity of the shared memory in the graphics processor, and load each target pixel value into the shared memory.

[0059] Shared memory is a level-one cache within the GPU that can be controlled manually (i.e., programmed by the programmer). It is an abstract concept and does not refer to any specific storage structure. It's important to note that data that meets the requirements of the shared memory storage structure (i.e., a two-dimensional physical structure) and does not exceed its storage capacity can be loaded into shared memory. Furthermore, shared memory offers the advantage of fast data read speeds. Therefore, loading data into shared memory is the preferred solution to improve data processing speed, effectively resolving the access latency issue between main memory and the GPU.

[0060] Based on this, shared memory, with its two-dimensional physical structure, is well-suited for storing two-dimensional images. This allows digital images to be stored in shared memory precisely in a two-dimensional format. In other words, shared memory stores the pixel values ​​of each pixel in the digital image in a two-dimensional format, or the relative position of each pixel value in shared memory corresponds to its relative position in the digital image. Since shared memory has a limited storage capacity and cannot hold all the pixel values ​​of a digital image at once, target pixel values ​​can be determined from the existing pixel values ​​based on the storage capacity. These target pixel values ​​are those that can be loaded into shared memory during this loading process. For example, assuming a storage capacity of N*N, N*N target pixel values ​​that have not yet been loaded into shared memory can be loaded into shared memory.

[0061] S130. Read the values ​​of each target pixel from the shared memory, and determine the image gradient of the digital image at the pixel position where each target pixel value is located based on the reading results.

[0062] Here, the pixel position can be the location of the target pixel value, that is, the location of the pixel corresponding to the target pixel value in the digital image; the image gradient can be the gradient of the digital image in any direction at the pixel position, such as the gradient of the digital image in the x-direction and / or y-direction at the pixel position. Based on this, after reading each target pixel value from shared memory, for each pixel position, the image gradient of the digital image at that pixel position can be determined based on the target pixel value at that pixel position and the target pixel values ​​at adjacent pixel positions. For example, as shown... Figure 1As shown, if the pixel position is (0,0), the target pixel values ​​at (0,0), (0,1) and (1,0) are read respectively. Then, the image gradient of the digital image in the x direction at (0,0) can be determined based on the target pixel values ​​at (0,0) and (0,1), and the image gradient of the digital image in the y direction at (0,0) can be determined based on the target pixel values ​​at (0,0) and (1,0).

[0063] It's important to note that shared memory stores target pixel values ​​using a bucket data structure. In the GPU, a bucket is a two-dimensional data structure, with each row typically containing 32 storage spaces, usually 4 bytes per space. Ideally, a GPU can have 32 threads running concurrently, allowing these 32 threads to access their respective columns of data in parallel. However, if two or more threads access the same column, bucket access conflicts may occur, causing data read latency. Based on this, for target pixel values ​​in the x-direction, since adjacent threads may read target pixel values ​​at the same address within the same storage bank (which is a bucket in this embodiment, and shared memory is implemented through buckets), and for target pixel values ​​in the y-direction, since each thread reads pixel values ​​at different addresses within the same bank, the reading process of target pixel values ​​in both the x and y directions will not cause bank conflicts. This ensures the locality of target pixel values ​​in two-dimensional space; that is, when different threads access the first target pixel value in the same bank, inter-thread broadcasting occurs. This is equivalent to one thread accessing the target pixel value in the bucket, and then broadcasting it to other threads that need the target pixel value, rather than all threads actually accessing the target pixel value. Therefore, the target pixel values ​​involved in the image gradient determination process are all stored in shared memory, eliminating the need to load data from memory. This effectively solves the buffer miss problem in both the x and y directions, improving the speed of image gradient determination in computer implementation.

[0064] The technical solution of this invention determines the target pixel value from the pixel values ​​of each pixel in the digital image loaded into the global memory of the graphics processor by utilizing the storage capacity of the shared memory within the graphics processor. Since the shared memory has a two-dimensional physical structure, this ensures better locality of the target pixel value in two-dimensional space when loading each target pixel value into the shared memory. Furthermore, when reading each target pixel value from the shared memory, since each target pixel value has locality in two-dimensional space, the image gradient of the digital image at the pixel position where each target pixel value is located is determined by reading the results, avoiding cache misses. This improves the speed of image gradient determination in computer implementation.

[0065] Example 2

[0066] Figure 4 This is a flowchart of an image gradient determination method provided in Embodiment 2 of the present invention. This embodiment is based on the above-described technical solutions and optimized. In this embodiment, optionally, loading each target pixel value into shared memory may specifically include: for each thread running in the graphics processor, loading each first pixel value associated with the thread in each target pixel value into shared memory based on the thread; correspondingly, reading each target pixel value from shared memory and determining the image gradient of the digital image at the pixel position where each target pixel value is located based on the reading result may include: for each thread, when it is detected that the thread has received a preset synchronization command, reading each second pixel value associated with the thread from shared memory based on the thread, and determining the image gradient of the digital image at the pixel position where each second pixel value is located based on the reading result. The explanations of terms that are the same as or corresponding to those in the above embodiments will not be repeated here.

[0067] See Figure 4 The method in this embodiment may specifically include the following steps:

[0068] S210. Obtain the pixel value of each pixel in the digital image that has been loaded into the global memory of the graphics processor, and determine the target pixel value from the pixel values ​​according to the storage capacity of the shared memory in the graphics processor.

[0069] S220: For each thread running within the graphics processor, load the first pixel values ​​associated with the thread in each target pixel value into shared memory based on the thread.

[0070] The GPU operates with multiple threads, which load target pixel values ​​into shared memory. Specifically, each thread is responsible for loading certain target pixel values ​​(equal to the storage capacity) into shared memory. These target pixel values ​​are those that the thread is interested in, i.e., the target pixel values ​​associated with that thread during the data loading process; for ease of description, we'll refer to them as the first pixel values. For example, given N*N target pixel values, a thread needs to load M*M first pixel values ​​associated with itself into shared memory. Further exemplifying this, since shared memory uses a bucket data structure for data storage, it can contain multiple buckets. Thread 1 can load its associated first pixel value into bucket 1; thread 2 can load the first pixel value to be loaded into bucket 2; and so on.

[0071] It should be noted that after each thread loads the corresponding first pixel value into shared memory, it can begin to perform a waiting operation. This is because each thread can perform data loading operations in parallel, and the execution speed of each thread may differ. This means that when a thread loads its associated first pixel value into shared memory, it does not know whether the other threads have already loaded their corresponding first pixel values ​​into shared memory. Therefore, it needs to perform a waiting operation until all threads have loaded their corresponding first pixel values ​​into shared memory before proceeding with subsequent data reading operations.

[0072] S230. For each thread, when it is detected that the thread has received a preset synchronization instruction, the thread reads the second pixel values ​​associated with the thread from the shared memory, and determines the image gradient of the digital image at the pixel position where each second pixel value is located from the reading result.

[0073] The image gradient determination device can be equipped with a preset synchronization command, which can be a command sent to each thread after it is detected that all threads have completed the data loading operation. Therefore, for any thread within each thread, when it is detected that the thread has received the preset synchronization command, it indicates that all threads have completed the data loading operation, and the second pixel values ​​associated with that thread can be read from the shared memory. Specifically, the target pixel values ​​stored in the shared memory can be accessed by all threads. That is, assuming a target pixel value is loaded into the shared memory based on thread 1, the target pixel value can be accessed by thread 1, and it can also be accessed by all other threads except thread 1. This is the meaning of "shared" in "shared memory". During the data reading process, a thread only reads the data it is interested in, which may differ from the data it is interested in during the data loading process. For example, continuing with the above example, the data that thread 1 is interested in during the data loading process is the target pixel value to be loaded into bucket 1, while the data it is interested in during the data reading process is a target pixel value stored in bucket 1 and a target pixel value stored in bucket 2. Therefore, for ease of description, the target pixel value that a thread is concerned with during the data reading process can be referred to as the second pixel value associated with that thread.

[0074] Furthermore, based on the thread's reading results, the image gradient of the digital image at the pixel position where each second pixel value is located can be determined. The specific implementation process has been described in Embodiment 1 of this invention and will not be repeated here. For example, as... Figure 5As shown, taking thread 1 as an example, the second pixel value associated with thread 1 can be the target pixel value located in the second unit of bucket 1, the target pixel value in the third unit, and the target pixel value located in the first unit of bucket 2. That is, thread 1 can access the target pixel value loaded into the shared memory by thread 2. Then, the image gradient determined based on these target pixel values ​​can be the gradient of the digital image at the image position where the second unit is located.

[0075] The technical solution of this invention addresses the issue that, for each thread running within a graphics processor, loads the first pixel values ​​associated with each thread from each target pixel value into shared memory, improving data loading speed through parallel data loading by each thread. After all threads have completed data loading, for any thread, it reads the second pixel values ​​associated with that thread from shared memory and determines the image gradient of the digital image at the pixel position of each second pixel value from the reading results. This parallel data reading by each thread further improves data reading speed, and the two processes work together to further improve the speed of determining the image gradient.

[0076] An optional technical solution is that the shared memory stores each first pixel value in a bucket data structure, each bucket includes multiple storage units, and the first pixel value is stored in the corresponding storage unit, that is, the shared memory can store data through the storage units in the bucket; after reading each second pixel value associated with the thread from the shared memory based on the thread, the above image gradient determination method may further include: obtaining the second pixel value stored in the first unit of each storage unit based on the reading result, and broadcasting the obtained result based on the graphics processor.

[0077] In this shared memory, there are O buckets. The GPU can run O threads at a time. Ideally, different threads access different buckets to ensure the fastest data read speed. This is analogous to a highway with O lanes; the fastest speed is when only one car is in each lane. When different threads access the same bucket, a bank conflict occurs. However, in practical applications, there may be situations where at least two threads need to access the same target pixel value within the same bucket, where the target pixel value has the same address within the same bucket. For example,... Figure 5 As shown, threads 1 and 2 both need to access the target pixel value in the first unit of bucket 2. If they access it directly, it will cause a bank conflict.

[0078] To address this issue, this invention proposes a method of broadcasting target pixel values ​​via a broadcast mechanism to achieve the effect of at least two threads accessing the same data. Specifically, after a thread reads a second pixel value associated with itself stored in a first unit (a storage unit among many storage units), the GPU can broadcast the read second pixel value so that other threads with a need to read that first unit can obtain the second pixel value through the broadcast result. The at least two threads with the same read need are precisely those threads that need to read data at the same address within the same bucket. This technical solution resolves the bank conflict problem in the x-direction through the broadcast mechanism, thereby achieving effective determination of the image gradient in the x-direction.

[0079] An optional technical solution involves storing each first pixel value in a bucket data structure within shared memory. Each bucket includes multiple storage units, and the first pixel value is stored in a corresponding storage unit. Determining the image gradient of the digital image at the pixel position of each second pixel value from the reading results may include: determining a third pixel value located in the second unit of each storage unit and a fourth pixel value located in the third unit of each storage unit that is adjacent to the second unit and belongs to the same bucket, based on the second pixel values ​​obtained from the reading results; and determining the image gradient of the digital image at the pixel position of the third pixel value based on the third pixel value and the fourth pixel value.

[0080] In this configuration, the second and third units are adjacent storage units located within the same bucket. The third pixel value is the target pixel value stored in the second unit, and the fourth pixel value is the target pixel value stored in the third unit. The third and fourth pixel values ​​are determined from the read second pixel values, and the image gradient of the digital image at the pixel position where the third pixel value is located is determined based on the third and fourth pixel values. For example, as shown... Figure 5 As shown, the third pixel value and the fourth pixel value located in the second unit of bucket 1 are obtained, and the image gradient of the digital image at the pixel position of the second unit is determined based on these two values. This technical solution, because buckets can store two-dimensional data (i.e., they can store target pixel values ​​in different storage units within the same bucket), allows the corresponding target pixel values ​​to be directly read from shared memory during image gradient determination, without needing to reread data from global memory. This achieves the effect of rapid determination of the image gradient in the y-direction.

[0081] An optional technical solution for determining a target pixel value from various pixel values ​​may include: determining the target pixel value from pixel values ​​that have not yet been loaded into shared memory; correspondingly, after determining the image gradient of the digital image at the pixel positions of each second pixel value from the reading results, the above image gradient determination method may further include: repeatedly executing the step based on the storage capacity of the shared memory in the graphics processor until there are no more pixel values ​​not loaded into shared memory. Since the storage capacity of shared memory is limited and cannot hold all pixel values ​​in the digital image at once, each pixel value can be loaded into shared memory in batches. Therefore, the target pixel value can be determined from the pixel values ​​not yet loaded into shared memory based on the storage capacity. Accordingly, after each thread in the GPU completes its corresponding image gradient determination operation, it can load the number of target pixel values ​​that have not yet been loaded into shared memory equal to the storage capacity into shared memory, and read the data in shared memory to obtain the corresponding image gradient, repeating this process until all pixel values ​​have been loaded into shared memory, thereby achieving the effective determination of the image gradient at each pixel position of the digital image. For example, suppose that each thread in the GPU finishes processing the N*N pixel values ​​located at the top left corner of the digital image during one run. Then it can then process the N*N pixel values ​​located at the (N+1-2*N)th pixel in the x-direction and the (N+1-2*N)th pixel in the y-direction, and repeat this process until all pixel values ​​have been processed.

[0082] Example 3

[0083] Figure 6 This is a flowchart of an image gradient determination method provided in Embodiment 3 of the present invention. This embodiment is based on the above-described technical solutions and optimized. In this embodiment, optionally, loading each target pixel value into shared memory may include: loading each target pixel value into shared memory, and for edge pixel values ​​loaded into shared memory at the edges of each target pixel value, loading the neighboring pixel values ​​adjacent to the edge pixel values ​​into the register of the graphics processor; correspondingly, determining the image gradient of the digital image at the pixel position where each target pixel value is located based on the reading results may include: for each read target pixel value, if the target pixel value is an edge pixel value, reading the neighboring pixel values ​​adjacent to the edge pixel value from the register; determining the image gradient of the digital image at the pixel position where the edge pixel value is located based on the neighboring pixel values ​​and the edge pixel values. The explanations of terms that are the same as or corresponding to those in the above embodiments will not be repeated here.

[0084] See Figure 6 The method in this embodiment may specifically include the following steps:

[0085] S310. Obtain the pixel value of each pixel in the digital image that has been loaded into the global memory of the graphics processor, and determine the target pixel value from the pixel values ​​according to the storage capacity of the shared memory in the graphics processor.

[0086] S320: Load each target pixel value into shared memory, and for each target pixel value loaded into shared memory, load the neighboring pixel values ​​adjacent to the edge pixel values ​​into the graphics processor's registers.

[0087] Since shared memory has limited storage capacity and cannot hold all pixel values ​​in a digital image at once, target pixel values ​​determined from each pixel value based on the storage capacity can be loaded into shared memory. It should be noted that for these target pixel values ​​loaded into shared memory, the image gradient at the pixel locations of target pixel values ​​at edges cannot be directly calculated based on the target pixel values ​​stored in shared memory. For example, ... Figure 5 As shown, the process of determining the image gradient at the pixel position where the ※ is located in a digital image requires the target pixel value stored in the ※ and the neighboring pixel values ​​below the target pixel value. However, the neighboring pixel values ​​have not yet been loaded into the shared memory, which makes it impossible to obtain the image gradient at the pixel position based on the data stored in the shared memory. In other words, there is a cache miss problem when determining the image gradient at the pixel position.

[0088] To address the aforementioned issues, this invention effectively combines global memory and GPU registers. Registers are high-speed storage components within the GPU with limited storage capacity, used to temporarily store instructions, data, and addresses. Specifically, for edge pixel values ​​loaded into shared memory at the edges of each target pixel value (i.e., target pixel values ​​located at the edges of shared memory), neighboring pixel values ​​adjacent to the edge pixel value are loaded into the graphics processor's registers. This allows these neighboring pixel values ​​to be directly loaded from the registers into shared memory when needed later.

[0089] S330: Read the target pixel values ​​from the shared memory. For each target pixel value read, if the target pixel value is an edge pixel value, read the neighboring pixel values ​​adjacent to the edge pixel value from the register.

[0090] In this process, while reading the target pixel values ​​from shared memory, for those target pixel values ​​located at the edges of shared memory (i.e., edge pixel values), it is also necessary to read the neighboring pixel values ​​adjacent to the edge pixel values ​​from the register. The advantage of this setting is that the data reading speed of the register and shared memory is similar during the data reading process. Therefore, even if the corresponding neighboring pixel values ​​need to be read from the register again during the image gradient determination process, this will not have too much impact on the speed of image gradient determination. This further solves the problem of slow image gradient determination speed caused by cache miss.

[0091] Based on this, the neighboring pixel values ​​described in the embodiments of the present invention can be combined with the repetitive execution process in the above technical solution. For example, continuing with the above example, when each thread is processing the N*N pixel values ​​located at the top left corner of the digital image, it can read the neighboring pixel values ​​adjacent to the current edge pixel value from the register into shared memory to achieve the corresponding image gradient determination process. Furthermore, after these N*N pixel values ​​have been processed, each thread can process the (N+1-2*N)th pixel value located in the x-direction and the (N+1-2*N)th pixel value located in the y-direction, repeating this process until all pixel values ​​have been processed.

[0092] S340. Determine the image gradient of the digital image at the pixel position where the edge pixel value is located based on the neighboring pixel value and the edge pixel value.

[0093] The technical solution of this invention solves the problem of cache miss when determining the image gradient at the pixel position of the edge pixel value by loading the neighboring pixel values ​​adjacent to the edge pixel value located at the edge of the shared memory into the register when loading the target pixel value. At this time, it is only necessary to read the neighboring pixel values ​​from the register into the shared memory. It further reduces the performance loss caused by cache miss by utilizing the merging mechanism of global memory data access.

[0094] Example 4

[0095] Figure 7This is a flowchart of an image gradient determination method provided in Embodiment 4 of the present invention. This embodiment is based on and optimized from the above-described technical solutions. In this embodiment, optionally, the target pixel value may include the target real part value or the target imaginary part value of the magnetic resonance signal. The target real part value and the target imaginary part value belonging to the same magnetic resonance signal are loaded into different buckets in shared memory. Determining the image gradient of the digital image at the pixel position where each target pixel value is located based on the reading results may include: obtaining the target real part value and the target imaginary part value belonging to the same magnetic resonance signal from each read target pixel value; weighting the target real part value and the target imaginary part value, and determining the image gradient of the digital image at the pixel position corresponding to the weighted result based on the reading results. The explanations of terms that are the same as or corresponding to those in the above embodiments are not repeated here.

[0096] See Figure 7 The method in this embodiment may specifically include the following steps:

[0097] S410: Obtain the pixel values ​​of each pixel in the digital image that has been loaded into the global memory of the graphics processor.

[0098] S420. Based on the storage capacity of the shared memory in the graphics processor, determine the target pixel value from each pixel value, and load each target pixel value into the shared memory. The target pixel value includes the target real part value or the target imaginary part value of the magnetic resonance signal. The target real part value and the target imaginary part value belonging to the same magnetic resonance signal are loaded into different buckets in the shared memory.

[0099] Since the MR signals acquired during MR scanning are all complex numbers—that is, each MR signal consists of two floating-point data points, a real part and an imaginary part—defining complex number types directly in shared memory would inevitably lead to bank conflicts in many buckets. This is because each floating-point data point requires two adjacent banks for data storage, which would prevent many threads from executing in parallel, thus failing to improve computational performance. Therefore, the real and imaginary parts of the MR signal can be stored in two separate buckets. That is, the target pixel value can be either the target real part or the target imaginary part of the MR signal. When loading target pixel values ​​into shared memory, the target real and target imaginary parts belonging to the same MR signal can be loaded into different buckets within the shared memory, thereby avoiding potential bank conflicts during the reading of target pixel values.

[0100] S430: Read the target pixel values ​​from the shared memory, and obtain the target real part value and target imaginary part value belonging to the same magnetic resonance signal from the read target pixel values.

[0101] S440. Weight the real part and imaginary part of the target, and determine the image gradient of the digital image at the pixel position corresponding to the weighted result based on the reading result, that is, determine the image gradient of the digital image at the pixel position where the MR signal corresponding to the weighted result is located.

[0102] The technical solution of this invention solves the problem of bank conflicts that may occur during the reading process by loading the real part value and the imaginary part value of the target belonging to the same magnetic resonance signal into different buckets of shared memory, thereby achieving the effect of rapid determination of image gradient.

[0103] To better understand the specific implementation process of the above steps, the image gradient determination method described in various embodiments of the present invention will be illustrated below with specific examples. For example, Figure 8 As shown, when this image gradient determination method is applied to the conjugate descent gradient method in the compressed sensing algorithm of MR, each thread loads the MR signal stored in global memory into shared memory. The real and imaginary values ​​of the target belonging to the same MR signal need to be loaded into different buckets within the shared memory. Synchronization waiting operations are performed on each thread until a preset synchronization command is detected. Then, for each thread, based on the relationship between the thread's index and the shared memory, it is determined whether the target pixel value loaded into the shared memory is already at the edge of the shared memory. If so, it needs to be retrieved from global memory and... The MR signals corresponding to the edge pixel values ​​on the edge are loaded into a register, and then these MR signals are loaded from the register into shared memory. This allows the thread to directly read the data it is interested in from the shared memory and perform a weighted subtraction operation on the real and imaginary parts of the target belonging to the same magnetic resonance signal to obtain the corresponding image gradient. Otherwise, the thread can directly read the data it is interested in from the shared memory and perform a weighted subtraction operation on the real and imaginary parts of the target belonging to the same magnetic resonance signal to obtain the corresponding image gradient. Finally, the calculation result is stored in a register. Experimental results, obtained using the Nsight Compute performance analysis tool provided by NVIDIA, show that under the same thread configuration, this solution significantly improves both GPU utilization (SM Frequency) and memory bandwidth utilization compared to existing technologies, and its single call time is also improved by 2 microseconds. When executed in the compressed sensing algorithm, the Nsight System performance analysis tool shows that its total call time is reduced by approximately 25% compared to existing solutions.

[0104] In addition to the above experiments, the applicant also conducted experiments on digital images with a dimension of 288*240. If shared memory with a dimension of 8*8 is used, the cache hit rate can be improved by more than 86%, and the algorithm execution speed can be improved by an average of 25%.

[0105] Example 5

[0106] Figure 9 This is a structural block diagram of an image gradient determination device provided in Embodiment 5 of the present invention. This device is used to execute the image gradient determination method provided in any of the above embodiments. This device and the image gradient determination methods of the above embodiments belong to the same inventive concept. Details not described in detail in the embodiments of the image gradient determination device can be found in the embodiments of the above image gradient determination methods. Figure 9 As shown, the device may specifically include: a pixel value acquisition module 510, a shared memory loading module 520, and an image gradient determination module 530.

[0107] The pixel value acquisition module 510 is used to acquire the pixel value of each pixel in the digital image that has been loaded into the global memory of the graphics processor.

[0108] The shared memory loading module 520 is used to determine the target pixel value from each pixel value according to the storage capacity of the shared memory in the graphics processor, and load each target pixel value into the shared memory;

[0109] The image gradient determination module 530 is used to read the values ​​of each target pixel from the shared memory and determine the image gradient of the digital image at the pixel position where each target pixel value is located based on the reading results.

[0110] Optionally, the shared memory loading module 520 may specifically include:

[0111] The shared memory loading unit is used to load the first pixel values ​​associated with each thread in each target pixel value into shared memory for each thread running in the graphics processor.

[0112] Accordingly, the image gradient determination module 530 can be specifically used for:

[0113] For each thread, when it is detected that the thread has received a preset synchronization instruction, the thread reads the second pixel values ​​associated with the thread from the shared memory, and determines the image gradient of the digital image at the pixel position where each second pixel value is located from the reading result.

[0114] Optionally, the shared memory stores each first pixel value using a bucket data structure, where each bucket includes multiple storage units, and the first pixel value is stored in the corresponding storage unit; the image gradient determination device may further include:

[0115] The data broadcasting module is used to read the second pixel values ​​associated with each thread from the shared memory based on the thread, obtain the second pixel values ​​stored in the first unit of each storage unit based on the reading results, and broadcast the results based on the graphics processor.

[0116] Optionally, the shared memory stores each first pixel value using a bucket data structure, where each bucket includes multiple storage units, and the first pixel value is stored in the corresponding storage unit; the image gradient determination module 530 may specifically include:

[0117] The fourth pixel value determination unit is used to determine the third pixel value located in the second unit of each storage unit and the fourth pixel value located in the third unit of each storage unit that is adjacent to the second unit and belongs to the same bucket, based on the second pixel values ​​obtained from the reading results.

[0118] The first image gradient determination unit is used to determine the image gradient of the digital image at the pixel position where the third pixel value is located, based on the third pixel value and the fourth pixel value.

[0119] Based on this, optionally, the shared memory loading module 520 may specifically include: a target pixel value determination unit, used to determine the target pixel value from the pixel values ​​that have not been loaded into the shared memory;

[0120] Accordingly, the above-mentioned image gradient determination device may further include:

[0121] The repeat execution module is used to repeatedly execute the steps based on the storage capacity of the shared memory in the graphics processor after determining the image gradient of the digital image at the pixel position of each second pixel value from the reading results, until there are no more pixel values ​​that have not been loaded into the shared memory.

[0122] Optionally, the shared memory loading module 520 may specifically include:

[0123] The register loading unit is used to load each target pixel value into shared memory, and for the edge pixel values ​​at the edges of each target pixel value loaded into shared memory, load the neighboring pixel values ​​adjacent to the edge pixel values ​​into the registers of the graphics processor.

[0124] Correspondingly, the image gradient determination module 530 may specifically include:

[0125] The neighboring pixel value reading unit is used to read the neighboring pixel values ​​adjacent to the edge pixel value from the register for each target pixel value read.

[0126] The second image gradient determination unit is used to determine the image gradient of the digital image at the pixel position where the edge pixel value is located, based on the neighboring pixel value and the edge pixel value.

[0127] Optionally, the target pixel value includes the target real part value or the target imaginary part value of the magnetic resonance signal. The target real part value and the target imaginary part value belonging to the same magnetic resonance signal are loaded into different buckets in shared memory. The image gradient determination module 530 may specifically include:

[0128] The real and imaginary part reading unit is used to obtain the real part value and the imaginary part value of the target belonging to the same magnetic resonance signal from each target pixel value read;

[0129] The third image gradient determination unit is used to weight the real part and imaginary part of the target, and determine the image gradient of the digital image at the pixel position corresponding to the weighted result based on the reading result.

[0130] The image gradient determination device provided in Embodiment 5 of the present invention, through the cooperation of a pixel value acquisition module and a shared memory loading module, determines the target pixel value from the pixel values ​​of each pixel in the digital image loaded into the global memory of the graphics processor based on the storage capacity of the shared memory within the graphics processor. Since the shared memory has a two-dimensional physical structure, this ensures better locality of the target pixel values ​​in two-dimensional space when loading each target pixel value into the shared memory. Furthermore, the image gradient determination module reads each target pixel value from the shared memory. Because each target pixel value has locality in two-dimensional space, when determining the image gradient of the digital image at the pixel position of each target pixel value based on the reading results, cache misses are avoided, thereby improving the speed of image gradient determination during computer implementation. The above device, by loading the target pixel values ​​in the digital image into the shared memory with a two-dimensional physical structure, ensures the locality of the target pixel values ​​in two-dimensional space. Furthermore, when determining the image gradient based on the target pixel values ​​read from the shared memory, cache misses are avoided, thus achieving the effect of improving the speed of image gradient determination during computer implementation.

[0131] The image gradient determination device provided in the embodiments of the present invention can execute the image gradient determination method provided in any embodiment of the present invention, and has the corresponding functional modules and beneficial effects of the method execution.

[0132] It is worth noting that in the embodiments of the above-mentioned image gradient determination device, the various units and modules included are only divided according to functional logic, but are not limited to the above division, as long as the corresponding functions can be achieved; in addition, the specific names of each functional unit are only for easy distinction between each other and are not used to limit the scope of protection of the present invention.

[0133] Example 6

[0134] Figure 10 This is a schematic diagram of the structure of an image gradient determination device provided in Embodiment Six of the present invention, as shown below. Figure 10 As shown, the device includes a memory 610, a processor 620, an input device 630, and an output device 640. The number of processors 620 in the device can be one or more. Figure 10 Taking a processor 620 as an example; the memory 610, processor 620, input device 630, and output device 640 in the device can be connected via a bus or other means. Figure 10 Taking the connection between China and Israel via bus 650 as an example.

[0135] The memory 610, as a computer-readable storage medium, can be used to store software programs, computer-executable programs, and modules, such as the program instructions / modules corresponding to the image gradient determination method in this embodiment of the invention (e.g., the pixel value acquisition module 510, the shared memory loading module 520, and the image gradient determination module 530 in the image gradient determination device). The processor 620 executes various functional applications and data processing of the device by running the software programs, instructions, and modules stored in the memory 610, thereby implementing the aforementioned image gradient determination method.

[0136] The memory 610 may primarily include a program storage area and a data storage area. The program storage area may store the operating system and at least one application program required for a given function; the data storage area may store data created based on device usage. Furthermore, the memory 610 may include high-speed random access memory and non-volatile memory, such as at least one disk storage device, flash memory, or other non-volatile solid-state storage device. In some instances, the memory 610 may further include memory remotely located relative to the processor 620, which can be connected to the device via a network. Examples of such networks include, but are not limited to, the Internet, intranets, local area networks, mobile communication networks, and combinations thereof.

[0137] Input device 630 can be used to receive input digital or character information, and to generate key signal inputs related to user settings and function control of the device. Output device 640 may include display devices such as a display screen.

[0138] Example 7

[0139] Embodiment 7 of the present invention provides a storage medium containing computer-executable instructions, which, when executed by a computer processor, are used to perform an image gradient determination method, the method comprising:

[0140] Obtain the pixel values ​​of each pixel in the digital image that has been loaded into the global memory of the graphics processor; determine the target pixel value from the pixel values ​​according to the storage capacity of the shared memory in the graphics processor, and load the target pixel value into the shared memory;

[0141] Read the values ​​of each target pixel from the shared memory, and determine the image gradient of the digital image at the pixel position where each target pixel value is located based on the reading results.

[0142] Of course, the computer-executable instructions provided in the embodiments of the present invention are not limited to the method operations described above, but can also perform related operations in the image gradient determination method provided in any embodiment of the present invention.

[0143] Based on the above description of the implementation methods, those skilled in the art can clearly understand that the present invention can be implemented using software and necessary general-purpose hardware, and of course, it can also be implemented using hardware, but in many cases the former is a better implementation method. According to this understanding, the technical solution of the present invention, or the part that contributes to the prior art, can be embodied in the form of a software product. This computer software product can be stored in a computer-readable storage medium, such as a computer floppy disk, read-only memory (ROM), random access memory (RAM), flash memory, hard disk, or optical disk, etc., including several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute the methods described in the various embodiments of the present invention.

[0144] Note that the above description is merely a preferred embodiment of the present invention and the technical principles employed. Those skilled in the art will understand that the present invention is not limited to the specific embodiments described herein, and various obvious changes, readjustments, and substitutions can be made without departing from the scope of protection of the present invention. Therefore, although the present invention has been described in detail through the above embodiments, the present invention is not limited to the above embodiments, and may include many other equivalent embodiments without departing from the concept of the present invention, the scope of which is determined by the scope of the appended claims.

Claims

1. A method for determining image gradients, characterized in that, include: Retrieve the pixel values ​​of each pixel in the digital image that has been loaded into the global memory of the graphics processor; Based on the storage capacity of the shared memory within the graphics processor, a target pixel value is determined from each of the pixel values, and each of the target pixel values ​​is loaded into the shared memory; wherein, the shared memory has a two-dimensional physical structure, and the relative position of each of the target pixel values ​​in the shared memory is consistent with the relative position of each of the target pixel values ​​in the digital image; The target pixel values ​​are read from the shared memory, and the image gradient of the digital image at the pixel position where each target pixel value is located is determined based on the reading results.

2. The method according to claim 1, characterized in that, The step of loading each of the target pixel values ​​into the shared memory includes: For each thread running within the graphics processor, the first pixel values ​​associated with the thread in each target pixel value are loaded into the shared memory based on the thread. Accordingly, the step of reading each of the target pixel values ​​from the shared memory and determining the image gradient of the digital image at the pixel position where each of the target pixel values ​​is located based on the reading results includes: For each thread, when it is detected that the thread has received a preset synchronization instruction, the second pixel value associated with the thread is read from the shared memory based on the thread, and the image gradient of the digital image at the pixel position where each second pixel value is located is determined from the reading result.

3. The method according to claim 2, characterized in that, The shared memory stores each of the first pixel values ​​in a bucket data structure. Each bucket includes multiple storage units, and the first pixel value is stored in the corresponding storage unit. After reading the second pixel values ​​associated with the thread from the shared memory based on the thread, the method further includes: The second pixel value is obtained based on the reading result and stored in the first unit of each of the storage units. The result is then broadcast based on the graphics processor.

4. The method according to claim 2, characterized in that, The shared memory stores each of the first pixel values ​​in a bucket data structure. Each bucket includes multiple storage units, and the first pixel value is stored in the corresponding storage unit. Determining the image gradient of the digital image at the pixel position of each second pixel value from the reading results includes: Based on the second pixel values ​​obtained from the reading results, determine the third pixel value located in the second unit of each of the storage units, and the fourth pixel value located in the third unit of each of the storage units that is adjacent to the second unit and belongs to the same bucket; Based on the third pixel value and the fourth pixel value, the image gradient of the digital image at the pixel position where the third pixel value is located is determined.

5. The method according to claim 2, characterized in that, Determining the target pixel value from each of the pixel values ​​includes: The target pixel value is determined from the pixel values ​​that have not been loaded into the shared memory; Accordingly, after determining the image gradient of the digital image at the pixel position where each second pixel value is located from the reading result, the method further includes: Repeat the steps based on the storage capacity of the shared memory within the graphics processor until no more pixel values ​​not loaded into the shared memory exist.

6. The method according to claim 1, characterized in that, The step of loading each of the target pixel values ​​into the shared memory includes: Each of the target pixel values ​​is loaded into the shared memory, and for each of the target pixel values ​​loaded into the shared memory, the neighboring pixel values ​​adjacent to the edge pixel values ​​are loaded into the registers of the graphics processor. Accordingly, determining the image gradient of the digital image at the pixel position of each target pixel value based on the reading result includes: For each target pixel value read, if the target pixel value is the edge pixel value, then the neighboring pixel value adjacent to the edge pixel value is read from the register; The image gradient of the digital image at the pixel position where the edge pixel value is located is determined based on the neighboring pixel value and the edge pixel value.

7. The method according to claim 1, characterized in that, The target pixel value includes the target real part value or the target imaginary part value of the magnetic resonance signal. The target real part value and the target imaginary part value belonging to the same magnetic resonance signal are respectively loaded into different buckets of the shared memory. The step of determining the image gradient of the digital image at the pixel position of each target pixel value based on the reading results includes: Obtain the real part value and the imaginary part value of the target belonging to the same magnetic resonance signal from each of the target pixel values ​​read; The real part and the imaginary part of the target are weighted, and the image gradient of the digital image at the pixel position corresponding to the weighted result is determined based on the reading result.

8. An image gradient determination device, characterized in that, include: The pixel value acquisition module is used to acquire the pixel value of each pixel in the digital image that has been loaded into the global memory of the graphics processor; A shared memory loading module is used to determine target pixel values ​​from the pixel values ​​according to the storage capacity of the shared memory in the graphics processor, and load the target pixel values ​​into the shared memory; wherein, the shared memory has a two-dimensional physical structure, and the relative positions of the target pixel values ​​in the shared memory are consistent with the relative positions of the target pixel values ​​in the digital image; The image gradient determination module is used to read each of the target pixel values ​​from the shared memory and determine the image gradient of the digital image at the pixel position where each of the target pixel values ​​is located based on the reading results.

9. An image gradient determination device, characterized in that, include: One or more processors; Memory, used to store one or more programs; When the one or more programs are executed by the one or more processors, the one or more processors implement the image gradient determination method as described in any one of claims 1-7.

10. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by the processor, it implements the image gradient determination method as described in any one of claims 1-7.

Citation Information

Patent Citations

  • Information processing device, information processing method, and storage medium

    US20180150934A1