Image stitching grayscale processing method, image stitching method, device and medium
By performing grayscale equalization processing on the images to be stitched before stitching, the problem of brightness differences in the stitched images is solved, ensuring the brightness uniformity and analytical accuracy of the stitched images.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- E COM TECHNOLOGY LTD
- Filing Date
- 2023-04-28
- Publication Date
- 2026-04-14
AI Technical Summary
In existing image stitching methods, there are obvious brightness differences between the individual images to be stitched together, which affects the integrity of the imaging and image analysis.
By acquiring the overlapping areas of the images to be stitched, calculating the grayscale difference, determining whether it meets the grayscale threshold, and performing grayscale equalization processing until the difference meets the threshold or the number of iterations is reached, it is ensured that each image to be stitched is within the same or similar grayscale range.
This method achieves uniform brightness in the stitched image, improves the overall integrity of the image and the accuracy of analysis, avoids the impact of over-processing on image quality, and reduces the amount of computation.
Smart Images

Figure CN116681620B_ABST
Abstract
Description
[0001] This application is a divisional application of application number 202310473374.4, filed on April 28, 2023, entitled "Method for grayscale processing of spliced images, image splicing method, apparatus and medium". Technical Field
[0002] This invention belongs to the field of data image processing technology, and particularly relates to a method for processing grayscale of stitched images, an image stitching method, an apparatus, and a medium. Background Technology
[0003] Image stitching is widely used in data image processing. Whether it's optical images captured by a digital camera or digital X-ray images generated by X-ray photography, there are always situations where image stitching is necessary. For example, due to focal length limitations, a single lens often cannot capture the entire scene. In such cases, it's necessary to use a digital camera to capture different parts of the scene separately, and then stitch these images together to obtain a complete image. Similarly, in digital X-ray imaging, because it uses a detector to receive X-rays emitted from an X-ray source, the size of the detector and the effective irradiation area of the X-ray source limit the size of the object that can be photographed. Commonly used detectors have limited sizes, and the effective irradiation area of X-ray sources is also limited. Therefore, when capturing images of the spine, the entire lower limb, or the whole skeleton, it is necessary to capture multiple images of different parts and then stitch these images together to obtain a complete image.
[0004] The current image stitching process is as follows: Starting with the two images to be stitched, located at the top (or bottom, or left, or right), the two images are first preprocessed to reduce the influence of environmental and other factors on the registration images and improve the registration accuracy; then, the two images are registered to determine the relative translation amount between them; then, the overlapping parts of the two images are merged to obtain the first merged image; then, the first merged image is combined with the third image at the top (or bottom, or left, or right) to perform the above steps from preprocessing to fusion to obtain the second merged image; the next adjacent image is extracted and the previous steps are repeated until all images to be stitched are completed.
[0005] It should be noted that the above description of the technical background is only for the purpose of providing a clear and complete explanation of the technical solutions of the present invention and facilitating understanding by those skilled in the art. It should not be assumed that the above technical solutions are known to those skilled in the art simply because they have been described in the background section of this invention. Summary of the Invention
[0006] The applicant discovered that existing image stitching methods do not process the brightness of each image to be stitched in the stitched image. Due to differences in exposure parameters during shooting, the influence of ambient lighting, or the differences in the ability of the subject to absorb X-rays, there are often significant brightness differences between the corresponding areas of each image to be stitched in the stitched image, which affects the overall integrity of the stitched image and even the analysis of the image.
[0007] To address the aforementioned technical problems, this application aims to propose a grayscale processing method, image stitching method, apparatus, and medium for stitching images, so as to perform grayscale processing on each image to be stitched, making each image to be stitched within the same or similar grayscale range, thereby solving the technical problem in the prior art where brightness differences exist between corresponding areas of each image to be stitched in the stitched image, affecting the overall imaging and even the analysis of the image.
[0008] The technical solution of the present invention is as follows:
[0009] One aspect of the present invention provides a method for processing grayscale values of stitched images, the method comprising the following steps:
[0010] Obtain the images to be stitched together, and extract the overlapping regions of each of the images to be stitched together;
[0011] The sum of gray-level differences is obtained by summing the gray-level differences in the overlapping regions of each pair of overlapping images to be stitched together.
[0012] Determine whether the grayscale difference meets the grayscale threshold;
[0013] When the grayscale difference does not meet the grayscale threshold, grayscale equalization processing is performed on each of the images to be stitched together.
[0014] The grayscale difference sum is recalculated for each of the images to be stitched after grayscale equalization, and it is determined whether the recalculated grayscale difference sum meets the grayscale threshold.
[0015] When the recalculated grayscale difference does not meet the grayscale threshold, the grayscale equalization process is repeated for each of the images to be stitched, and the grayscale difference is recalculated until the grayscale difference meets the grayscale threshold, or until the number of iterations of the grayscale equalization process for each of the images to be stitched reaches a preset number.
[0016] Furthermore, the step of summing the grayscale differences of the overlapping regions of each pair of overlapping images to be stitched together to obtain the sum of grayscale differences specifically includes:
[0017] The overlapping regions of two mutually overlapping images to be stitched together are recorded as a group, thus obtaining the overlapping region group;
[0018] Calculate the sum of the grayscale differences of each corresponding pixel in the group of regions to be overlapped, and record it as the grayscale value of the overlapping region;
[0019] The grayscale difference is obtained by summing the grayscale values of the overlapping regions of each of the groups of regions to be overlapped.
[0020] or,
[0021] The method of summing the gray-level differences in the overlapping regions of each pair of overlapping images to be stitched together, specifically includes:
[0022] The overlapping regions of two mutually overlapping images to be stitched together are recorded as a group, thus obtaining the overlapping region group;
[0023] Calculate the sum of the grayscale differences of each corresponding pixel in the group of regions to be overlapped, and record it as the grayscale value of the overlapping region;
[0024] Calculate the weights of each of the groups of regions to be overlapped;
[0025] Based on the weights of each of the groups of regions to be overlapped, the sum of the gray values of the overlapping regions of each group of regions to be overlapped is calculated to obtain the gray value difference.
[0026] Further, the step of calculating the weights of each of the groups of regions to be overlapped includes:
[0027] The weights of each of the overlapping regions are assigned based on the number of pixels in each of the overlapping regions.
[0028] Alternatively, the weights of each group of regions to be overlapped can be assigned based on the proportion of each group of regions to be overlapped in the stitched image.
[0029] Alternatively, the weights of each of the groups of regions to be overlapped can be assigned based on the proportion of the foreground in each group of regions to the foreground in the stitched image.
[0030] Furthermore, the sum of the grayscale differences of each corresponding pixel is the sum of the grayscale differences of each pair of matched pixels corresponding to the foreground.
[0031] Furthermore, the grayscale equalization processing of each of the images to be stitched specifically includes the following steps:
[0032] Based on the grayscale range and grayscale mean of the overlapping regions of each of the images to be stitched, determine the grayscale range equalization value and the grayscale mean equalization value.
[0033] Based on the grayscale range equalization value corresponding to the image to be stitched, a grayscale equalization coefficient is obtained to stretch or shrink the grayscale range of the overlapping area of the image to be stitched.
[0034] The grayscale correction parameters of the image to be stitched are obtained based on the grayscale mean equalization value, grayscale equalization coefficient, and grayscale mean value of the overlapping area of the image to be stitched.
[0035] The foreground of each of the images to be stitched is processed based on the grayscale equalization coefficient and grayscale correction parameters of each image.
[0036] Further, determining the grayscale range equalization value and the grayscale mean equalization value based on the grayscale range and grayscale mean of the overlapping regions of each of the images to be stitched specifically includes:
[0037] The individual images to be stitched together that have the same overlapping area are divided into a group to obtain at least one group of images to be stitched together;
[0038] Calculate the grayscale range equalization value and the grayscale mean equalization value of the overlapping region of each of the image groups to be stitched; the grayscale range equalization value is the average grayscale range value of the overlapping region of each image in the image group to be stitched; the grayscale mean equalization value is the average grayscale mean value of the overlapping region of each image in the image group to be stitched.
[0039] Alternatively, determining the grayscale range equalization value and the grayscale mean equalization value based on the grayscale range and grayscale mean of the overlapping regions of each of the images to be stitched specifically includes:
[0040] The individual images to be stitched together that have the same overlapping area are divided into a group to obtain at least one group of images to be stitched together;
[0041] Calculate the grayscale range equalization value and the grayscale mean equalization value of the foreground of the overlapping region of each of the image groups to be stitched; the grayscale range equalization value is the average grayscale range value of the foreground of the overlapping region of each image in the image group to be stitched; the grayscale mean equalization value is the average grayscale mean value of the foreground of the overlapping region of each image in the image group to be stitched.
[0042] Alternatively, determining the grayscale range equalization value and the grayscale mean equalization value based on the grayscale range and grayscale mean of the overlapping regions of each of the images to be stitched specifically includes:
[0043] Based on the size of the overlapping region in each of the images to be stitched, the sum of the grayscale range values of the overlapping region in each of the images to be stitched is calculated to obtain the grayscale range equalization value.
[0044] Based on the size of the overlapping region in each of the images to be stitched, the average gray value of the overlapping region in each of the images to be stitched is calculated to obtain the gray value equalization value.
[0045] Alternatively, determining the grayscale range equalization value and the grayscale mean equalization value based on the grayscale range and grayscale mean of the overlapping regions of each of the images to be stitched specifically includes:
[0046] Based on the size of the foreground of the overlapping region in each of the images to be stitched, the sum of the grayscale range values of the foreground of the overlapping region in each of the images to be stitched is calculated to obtain the grayscale range equalization value.
[0047] Based on the size of the foreground of the overlapping region in each of the images to be stitched, the average grayscale value of the foreground of the overlapping region in each of the images to be stitched is calculated to obtain the grayscale mean equalization value.
[0048] Furthermore, in one of the grayscale equalization processes, when one of the images to be stitched belongs to multiple groups of images to be stitched, the grayscale equalization process further includes:
[0049] Extract the grayscale equalization coefficient and grayscale correction parameter of each image to be stitched in each group of images to be stitched;
[0050] The average value of each gray-level equalization coefficient is extracted as the corrected gray-level equalization coefficient, and the average value of each gray-level correction parameter is extracted as the corrected gray-level correction parameter; or, a first weight of each overlapping region is determined based on the ratio of the number of pixels in each overlapping region of the image to be stitched; the sum of each gray-level equalization coefficient is obtained based on the first weight as the corrected gray-level equalization coefficient, and the sum of each gray-level correction parameter is obtained based on the first weight as the corrected gray-level correction parameter; or, a second weight of each overlapping region is determined based on the ratio of the foreground of each overlapping region of the image to be stitched to the foreground of the stitched image; the sum of each gray-level equalization coefficient is obtained based on the second weight as the corrected gray-level equalization coefficient, and the sum of each gray-level correction parameter is obtained based on the second weight as the corrected gray-level correction parameter.
[0051] The foreground of the image to be stitched is processed using the corrected gray-level equalization coefficient and the corrected gray-level correction parameters.
[0052] Further, based on the size of the overlapping regions in each of the images to be stitched, the sum of the grayscale range values of the overlapping regions in each of the images to be stitched is calculated to obtain the grayscale range equalization value. Additionally, based on the size of the overlapping regions in each of the images to be stitched, the total average of the grayscale mean values of the overlapping regions in each of the images to be stitched is calculated to obtain the grayscale mean equalization value. Specifically, this includes:
[0053] The number of pixels in the overlapping region of each of the images to be stitched is extracted, and a third weight is determined for each overlapping region of each image to be stitched based on the number of pixels. The sum of the grayscale range values of the overlapping regions of each image to be stitched is calculated based on the third weight to obtain the grayscale range balance value. The total average value of the average grayscale values of the overlapping regions of each image to be stitched is calculated based on the third weight to obtain the average grayscale value.
[0054] or,
[0055] The area occupied by the foreground of each overlapping region in the foreground of the stitched image is extracted respectively. The fourth weight of each overlapping region of each image to be stitched is determined based on the occupied area. The sum of the gray range values of the overlapping regions of each image to be stitched is calculated based on the fourth weight to obtain the gray range balance value. The total average value of the gray mean of the overlapping regions of each image to be stitched is calculated based on the fourth weight to obtain the gray mean balance value.
[0056] Furthermore, it also includes processing the background of each foreground image in each group of images to be stitched, which has already been processed by the grayscale equalization coefficient and the grayscale correction parameter. The processing methods include direct transformation processing and / or stretching transformation processing; the group of images to be stitched includes each image to be stitched with the same overlapping area.
[0057] The direct transformation process includes:
[0058] Extract the maximum gray value in the background and the minimum gray value in the foreground of the image to be stitched, and obtain the background gray value difference based on the difference between the maximum and minimum gray values;
[0059] The background of the image to be stitched is processed based on the background grayscale difference to make the grayscale values between the foreground and background of the image to be stitched continuous.
[0060] The stretching transformation process includes:
[0061] Extract the minimum gray value in the foreground of the image to be stitched, and the minimum gray value in the background of another image to be stitched, and stretch the background of the image to be stitched.
[0062] The formula for background stretching is: ,
[0063] Where I(m,n) is the gray value of the pixel at position (m,n) in the image to be stitched. , These are the minimum and maximum grayscale values of the background of the image to be stitched, respectively. The minimum grayscale value of the foreground of the image to be stitched together. The minimum grayscale value of the background of the other image to be stitched together.
[0064] Furthermore, the background of each image in the image group to be stitched is processed, specifically including:
[0065] Perform direct transformation processing on one of the images to be stitched together;
[0066] The image to be stitched is then stretched based on the image to be stitched after direct transformation.
[0067] Alternatively, the background of each image in the image group to be stitched can be processed, specifically including:
[0068] Perform direct transformation processing on one of the images to be stitched together;
[0069] Determine whether the minimum gray value in the background of the image to be stitched after the direct transformation is less than the minimum gray value in the foreground of the image to be stitched without background processing;
[0070] When the minimum gray value in the background is less than the minimum gray value in the foreground, the unprocessed background image to be stitched is stretched based on the image to be stitched after direct transformation.
[0071] When the minimum gray value in the background is greater than the minimum gray value in the foreground, the direct transformation processing is performed on the unprocessed background image to be stitched, and the stretching transformation processing is performed on another image to be stitched based on the image to be stitched after the direct transformation processing.
[0072] Furthermore, the extraction of the foreground and background of each image to be stitched specifically involves applying a triangular thresholding method to segment each image to be stitched.
[0073] Furthermore, the number of images to be stitched is at least three; the number of overlapping areas is at least two.
[0074] In another aspect, the present invention provides an image stitching method, comprising processing each image to be stitched using the image grayscale processing method described in any of the preceding claims.
[0075] Furthermore, the image stitching method includes the following steps:
[0076] The overlapping regions of each image to be stitched are analyzed to determine the overlapping regions of each image to be stitched.
[0077] The image to be stitched is processed using the image grayscale processing method described in any of the preceding claims;
[0078] The overlapping regions of the processed images to be stitched are fused using either a direct averaging method or a weighted averaging method.
[0079] Further, the step of performing overlapping region analysis on each image to be stitched, and determining the overlapping region of each image to be stitched, includes:
[0080] Determine the gradient field of each of the images to be stitched together;
[0081] The cross power spectrum of each image to be stitched is determined based on the gradient field of each image to be stitched.
[0082] Based on the inverse Fourier transform of each cross-power spectrum, the coordinates corresponding to the peak values of the inverse Fourier transform of each overlapping region are extracted and used as the offset between the two images to be stitched in the corresponding overlapping region.
[0083] The overlapping regions of each image to be stitched are determined based on the offset between the two images to be stitched in each overlapping region.
[0084] In another aspect, the present invention provides a grayscale processing apparatus for stitched images, the apparatus comprising a processor and a memory, the memory storing computer instructions, the processor executing the computer instructions stored in the memory, and the apparatus performing the steps of the method as described above when the computer instructions are executed by the processor.
[0085] In another aspect, the present invention provides a computer storage medium having a computer program stored thereon, which, when executed by a processor, performs the steps of the method described above.
[0086] The present invention provides a grayscale processing method, image stitching method, apparatus, and medium for stitching images. Addressing the technical problem in existing technologies where brightness differences exist between regions corresponding to the images to be stitched in the stitched image, affecting the overall imaging and even image analysis, the invention extracts the sum of grayscale differences between the overlapping regions. It then determines the difference between the images to be stitched based on whether the sum of the grayscale differences meets a grayscale threshold. For overlapping regions that do not meet the grayscale threshold, grayscale equalization processing is performed on each image to be stitched. This achieves overall grayscale processing of each image to be stitched before stitching, ensuring that the grayscale values of the processed images are in similar or identical grayscale ranges. Furthermore, to avoid excessive grayscale processing affecting the quality of each image to be stitched, and even the stitched image, and to reduce computational load, this application only judges the sum of grayscale differences in the overlapping regions. By using an appropriate grayscale threshold, it effectively ensures the quality of the images to be stitched after grayscale processing, the image processing speed, and the quality of the stitched image. Attached Figure Description
[0087] The accompanying drawings, which are provided to further illustrate the invention and form part of this application, are not intended to limit the scope of the invention.
[0088] Figure 1 A flowchart illustrating an embodiment of the image grayscale processing method of the present invention is shown;
[0089] Figure 2 A flowchart illustrating an embodiment of the present invention is provided, which calculates the sum of grayscale differences in overlapping regions of pairs of mutually overlapping images to be stitched.
[0090] Figure 3 A flowchart illustrating another embodiment of the present invention is shown, which calculates the sum of grayscale differences in overlapping regions of pairs of mutually overlapping images to be stitched.
[0091] Figure 4 A flowchart illustrating an embodiment of the present invention for performing grayscale equalization processing on the images to be stitched together is shown;
[0092] Figure 5 A flowchart illustrating another embodiment of the present invention for performing grayscale equalization processing on the images to be stitched is shown;
[0093] Figure 6 The image stitching method of the present invention is shown to obtain the stitched image. Figure 6 b) The stitched image obtained by existing technology ( Figure 6 a) An exemplary comparison chart. Implementation
[0094] To make the objectives, technical solutions, and advantages of this invention clearer, the invention will be further described in detail below with reference to the embodiments and accompanying drawings. Here, the illustrative embodiments and descriptions of this invention are used to explain the invention, but are not intended to limit the invention.
[0095] It should also be noted that, in order to avoid obscuring the invention with unnecessary details, only the structures and / or processing steps closely related to the solution according to the invention are shown in the accompanying drawings, while other details that are not closely related to the invention are omitted.
[0096] It should also be noted that, unless otherwise specified, the embodiments and features described in this application can be combined with each other.
[0097] As indicated in this application and claims, unless the context clearly indicates otherwise, the words "a," "an," "an," and / or "the" do not specifically refer to the singular and may also include the plural. Generally speaking, the terms "comprising" and "including" only indicate the inclusion of explicitly identified steps and elements, which do not constitute an exclusive list, and the method or apparatus may also include other steps or elements.
[0098] Flowcharts are used in this application to illustrate the operations performed by the system according to embodiments of this application. It should be understood that the preceding or following operations are not necessarily performed precisely in sequence. Instead, the steps can be processed in reverse order or simultaneously. Furthermore, other operations can be added to these processes, or one or more steps can be removed from them.
[0099] Figures 1 to 5 This is an exemplary flowchart of the image grayscale processing method of this application. The basic idea of this image grayscale processing method is to determine the grayscale of each image to be stitched before image stitching, corresponding to one or more overlapping regions. By calculating the sum of the grayscale differences between each overlapping region, the overall brightness difference of each image involved in the calculation is determined. When the overall brightness difference between each image is large, grayscale equalization processing is performed on each image to be stitched to reduce the brightness difference between each image to be stitched. When the overall brightness difference between each image is small or within a certain threshold, the possibility of significant brightness differences between the corresponding regions of each image to be stitched in the stitched image is smaller, and the brightness of the stitched image is more balanced.
[0100] See Figure 1 The diagram shown is a flowchart of an embodiment of the image grayscale processing method of the present invention. The image grayscale processing method in this embodiment includes the following steps:
[0101] S1: Obtain the images to be stitched together and extract the overlapping areas of each of the images to be stitched together;
[0102] S2: Calculate the sum of gray level differences in the overlapping regions of each pair of overlapping images to be stitched together, and obtain the sum of gray level differences;
[0103] S3: Determine whether the grayscale difference meets the grayscale threshold;
[0104] S4: When the gray level difference does not meet the gray level threshold, perform gray level equalization processing on each of the images to be stitched.
[0105] S5: Recalculate the sum of grayscale differences for each of the images to be stitched after grayscale equalization, and determine whether the recalculated sum of grayscale differences meets the grayscale threshold.
[0106] S6: When the recalculated grayscale difference does not meet the grayscale threshold, repeat the grayscale equalization process on each of the images to be stitched, and recalculate the grayscale difference until the grayscale difference meets the grayscale threshold, or until the number of iterations of the grayscale equalization process on each of the images to be stitched reaches a preset number.
[0107] To ensure the uniformity of brightness among the corresponding regions of each image to be stitched in the stitched image, when calculating the grayscale difference, it is preferable to include all images to be stitched in the calculation for a single stitched image.
[0108] In this embodiment, step S1 above involves acquiring images to be stitched and extracting overlapping regions from each of the images to be stitched. To acquire all images to be stitched into the final image, when the final image is composed of two images, two images are acquired; when the final image is composed of three or more images, three or more images are acquired. This embodiment is particularly suitable for processing images with three or more images to be stitched, i.e., at least three images, in which case there are at least two overlapping regions.
[0109] The image grayscale processing method of the present invention performs overall judgment and processing on each image to be stitched before image stitching. Overall judgment: the grayscale difference is amplified by the grayscale difference between the two images to be stitched corresponding to an overlapping area, and then the amplified grayscale differences of each overlapping area are summed.
[0110] In this invention, when amplifying the grayscale difference between two images to be stitched corresponding to an overlapping region, to avoid the influence of the size of the images to be stitched on the amplification result, to avoid excessive grayscale processing affecting the quality of the stitched image, and to reduce computational load, only the grayscale difference of the overlapping region of the images to be stitched is statistically analyzed. Figure 2 , 3 As shown, this embodiment provides two methods for obtaining the sum of grayscale differences, wherein... Figure 2 As shown, the sum of the grayscale differences in the overlapping regions of each pair of overlapping images to be stitched together, to obtain the sum of grayscale differences, specifically includes:
[0111] S201: The overlapping areas of two mutually overlapping images to be stitched together are recorded as a group to obtain the overlapping area group;
[0112] S202: Calculate the sum of the grayscale differences of each corresponding pixel in the group of regions to be overlapped, and record it as the grayscale value of the overlapping region;
[0113] S203: Calculate the sum of the gray values of the overlapping areas of each of the groups of areas to be overlapped, and obtain the gray value difference.
[0114] This method calculates the sum of grayscale differences in the images to be stitched for each overlapping region, then sums these sums to obtain the total grayscale difference across all overlapping regions—that is, the sum of the differences between each pair of pixels in all overlapping regions. The grayscale value of the overlapping region is the sum of the absolute values of the grayscale differences between corresponding pixels at each position. Summing the grayscale differences between corresponding pixels at each position amplifies the grayscale differences between the groups of overlapping regions, providing a valid basis for subsequent determination of whether grayscale processing is required for the images to be stitched.
[0115] Since the sizes of the overlapping regions often differ, to further eliminate the impact of these size differences on subsequent grayscale differences, the total grayscale difference between each overlapping region is accurately obtained based on their contribution to the stitched image. For example... Figure 3 The flowchart of another embodiment of the present invention, which calculates the sum of grayscale differences in the overlapping regions of each pair of overlapping images to be stitched, is shown. In this embodiment, the calculation of the sum of grayscale differences in the overlapping regions of each pair of overlapping images to be stitched, specifically includes:
[0116] S211: The overlapping areas of two mutually overlapping images to be stitched together are recorded as a group to obtain the overlapping area group;
[0117] S212: Calculate the sum of the grayscale differences of each corresponding pixel in the group of regions to be overlapped, and record it as the grayscale value of the overlapping region;
[0118] S213: Calculate the weights of each of the groups of regions to be overlapped;
[0119] S214: Based on the weights of each of the groups of regions to be overlapped, the sum of the gray values of the overlapping regions of each group of regions to be overlapped is calculated to obtain the gray difference.
[0120] Specifically, S213, which involves calculating the weights of each of the groups of regions to be overlapped, includes:
[0121] The weights of each of the groups of regions to be overlapped are assigned based on the number of pixels in each group. In this method, the weight of any region to be overlapped is the ratio of the number of pixels in that group to the sum of the number of pixels in all the groups to be overlapped.
[0122] Alternatively, the weights of each of the groups to be overlapped can be assigned based on the proportion of each group in the stitched image; in this method, the sum of the weights of each group to be overlapped is set to 1, and the ratio of the weights of each group to be overlapped is the ratio of the proportion of each group to be overlapped in the stitched image.
[0123] Alternatively, the weights of each of the groups to be overlapped can be assigned based on the proportion of the foreground in each group to the foreground of the stitched image; in this method, the sum of the weights of each group to be overlapped is 1, and the ratio of the weights of each group to be overlapped is the ratio of the proportion of the foreground in each group to the foreground of the stitched image.
[0124] This embodiment provides several methods for determining the weights of each group of regions to be overlapped. The first two methods are based on the number of pixels in the entire overlapping region, which are simple and facilitate rapid determination of the weights of each group. While the third method requires identifying the foreground of each group and the foreground of the stitched image, making the calculation more complex, it fully considers the importance of the foreground—the main object of the stitched image—to the stitched image, eliminates background interference, and captures the contribution of key areas of each image to the brightness of the stitched image. This ensures that the calculation of the grayscale difference sum fully considers the influence of each overlapping region on the stitched image. The sum of the grayscale differences of the corresponding pixels is the sum of the grayscale differences of each pair of matched pixels corresponding to the foreground. This synergy, combined with an appropriate grayscale threshold, effectively guarantees the quality of the image after grayscale processing and the quality of the stitched image. This method improves the reliability of the grayscale processing method and ensures the quality of the foreground in the stitched image.
[0125] In this embodiment, the pixels in the overlapping areas of the two images to be stitched together correspond one-to-one, and the overlapping area group consists of multiple pairs of pixels with corresponding positions. Step S202, calculating the sum of the grayscale differences of each corresponding pixel in the overlapping area group, and recording it as the grayscale value of the overlapping area, includes: subtracting the grayscale values of each pair of corresponding pixels to obtain the grayscale difference of each pair of pixels, and then summing the grayscale differences of each pair of pixels to obtain the grayscale value of the overlapping area.
[0126] Of course, for images that differ in size and whose overlapping areas do not have a one-to-one pixel correspondence during stitching, such as an image that needs to be scaled to 1 / 4 before it overlaps with another image of the same size, the image to be scaled can be scaled to 1 / 4 of the original image (4 pixels combined into 1 pixel) when determining the overlapping area, so that the pixels in the overlapping area correspond one-to-one; or, when determining the overlapping area, several pixels of the image to be scaled can be grouped together, so that the pixel group of the image to be scaled corresponds one-to-one with the pixels of the other image. For cases where there is a one-to-one correspondence between pixel groups in the overlapping region of one image and pixel groups in the overlapping region of another image, the sum of the grayscale differences of each corresponding pixel can be calculated as follows: First, process the grayscale of each pixel group according to the grayscale processing method during image stitching and fusion to obtain the grayscale value of each pixel group. Then, subtract the grayscale value of each pixel group from the grayscale value of the corresponding pixel in the other image to obtain the grayscale difference of each pair. Finally, sum all the grayscale differences to obtain the grayscale value of the overlapping region.
[0127] The steps described above in this embodiment evaluate and judge the brightness difference between the images to be stitched. When the grayscale difference calculated based on the overlapping areas of the images to be stitched does not meet the grayscale threshold, grayscale equalization processing needs to be performed on each image to be stitched. To ensure the effectiveness of the grayscale equalization processing and to avoid affecting the characteristics of the images to be stitched, the images to be stitched need to be processed as a whole, and the characteristics of each image to be stitched must be fully considered during the processing.
[0128] In this embodiment, the grayscale equalization processing of each of the images to be stitched specifically includes the following steps:
[0129] S410: Determine the grayscale range balance value and the grayscale mean balance value based on the grayscale range and grayscale mean of the overlapping regions of each of the images to be stitched together.
[0130] S420: Based on the grayscale range equalization value corresponding to the image to be stitched, obtain the grayscale equalization coefficient for stretching or shrinking the grayscale range of the overlapping area of the image to be stitched.
[0131] S430: Based on the gray-level mean equalization value, gray-level equalization coefficient, and gray-level mean value of the overlapping area of the image to be stitched, obtain the gray-level correction parameters of the image to be stitched.
[0132] S440: The foreground of each of the images to be stitched is processed based on the grayscale equalization coefficient and grayscale correction parameters of each image to be stitched.
[0133] In this embodiment, based on the grayscale range of the overlapping region of each of the images to be stitched, a target value for adjusting the grayscale span of each image to be stitched—a grayscale range equalization value—is determined. Then, a grayscale equalization coefficient is obtained for each image to be stitched based on the grayscale range equalization value. Processing with the grayscale equalization coefficient makes the grayscale span values of each image to be stitched the same or similar. Then, the grayscale correction parameter moves the foreground of images to be stitched with the same or similar grayscale spans (i.e., the same or similar grayscale interval lengths) to the same interval range. Through the processing of the grayscale equalization coefficient and the grayscale correction parameter, the grayscale interval lengths of each image to be stitched are made the same, and the upper and lower limits of the grayscale intervals are similar. Moreover, the determination of the grayscale equalization coefficient and the grayscale correction parameter comprehensively considers the characteristics of each image to be stitched corresponding to the overlapping region, so that while the foreground of the processed image to be stitched is similar, the characteristics of the original image are also well preserved, which helps to improve the quality of the stitched image.
[0134] In this embodiment, different grayscale range equalization values affect the length of the grayscale interval in the foreground of the image to be stitched, i.e., the grayscale span. A grayscale span that is too large can easily cause discontinuities in the grayscale of the foreground of the image to be stitched, while a grayscale span that is too small will compress the grayscale of the foreground of the image to be stitched into a very small interval, resulting in indistinct contrast between different areas. Therefore, this embodiment provides multiple methods for determining the grayscale range equalization value and the grayscale mean equalization value.
[0135] The first method involves determining a grayscale range equalization value and a grayscale mean equalization value based on the grayscale range and mean grayscale value of the overlapping regions of the images to be stitched together. This specifically includes:
[0136] The individual images to be stitched together that have the same overlapping area are divided into a group to obtain at least one group of images to be stitched together;
[0137] Calculate the grayscale range equalization value and the grayscale mean equalization value of the overlapping region of each of the image groups to be stitched together; the grayscale range equalization value is the average grayscale range value of the overlapping region of each image in the image group to be stitched together; the grayscale mean equalization value is the average grayscale mean value of the overlapping region of each image in the image group to be stitched together.
[0138] Based on the first method for determining the grayscale range equalization value and grayscale mean equalization value of the images to be stitched, the grayscale equalization processing is performed on each of the images to be stitched, such as... Figure 4 As shown.
[0139] like Figure 4 The diagram shown is a flowchart of an embodiment of the present invention for performing grayscale equalization processing on the images to be stitched together; wherein, the grayscale equalization processing on the images to be stitched together specifically includes the following steps:
[0140] S401: Divide the individual images to be stitched into a group that have the same overlapping area to obtain at least one group of images to be stitched;
[0141] S402: Calculate the grayscale mean balance value and grayscale range balance value for each of the image groups to be stitched; the grayscale range balance value is the average grayscale range value of the overlapping area of each image to be stitched in the image group to be stitched; the grayscale mean balance value is the average grayscale mean value of the overlapping area of each image to be stitched in the image group to be stitched.
[0142] S403: Extract the foreground and background of each of the images to be stitched together;
[0143] S404: Based on the grayscale range values of the overlapping areas of each image to be stitched and the grayscale range equalization values of the corresponding image groups to be stitched, obtain the grayscale equalization coefficients of each image to be stitched.
[0144] S405: Based on the average gray value of the overlapping area of each of the images to be stitched, the gray level equalization coefficient, and the average gray level equalization value of the corresponding image group to be stitched, the gray level correction parameters of each of the images to be stitched are obtained respectively.
[0145] S406: The foreground of each of the images to be stitched is processed based on the grayscale equalization coefficient and grayscale correction parameters of each image to be stitched.
[0146] The grayscale equalization processing method provided in this embodiment uses each overlapping region as a processing unit. Multiple images to be stitched together that have the same overlapping region are grouped together and denoted as a group of images to be stitched. Each group of images to be stitched is processed independently. During processing, the grayscale equalization value and the total grayscale range are first obtained based on the grayscale mean and grayscale range values of the overlapping regions of each image to be stitched.
[0147] The grayscale mean equalization value is: (1);
[0148] in, This is the grayscale mean balance value. This represents the average grayscale value of the overlapping region in an image to be stitched together. This is the average grayscale value of the overlapping region of another image to be stitched together.
[0149] The grayscale range equalization value is: (2);
[0150] in, This is the grayscale range equalization value. and These represent the grayscale range values of the overlapping areas of the two images to be stitched together; ; The grayscale range value. and These are the maximum and minimum grayscale values, respectively.
[0151] Steps S404 and S405 specifically include using the following formulas to calculate the grayscale equalization coefficient and grayscale correction parameter of each image to be stitched:
[0152] (3);
[0153] (4);
[0154] Where k is the gray-level equalization coefficient, and b is the gray-level correction parameter. The grayscale range of the overlapping regions of the images to be stitched together; The grayscale mean of the overlapping regions of the images to be stitched together.
[0155] For two images P1 and P2 in a group of images to be stitched, the grayscale equalization coefficient of image P1 is... k 1 represents the ratio of the grayscale range equalization value to the grayscale range value of the overlapping region of the image P1 to be stitched; the grayscale correction parameter b1 of the image P1 to be stitched is the grayscale mean equalization value minus the product of the grayscale equalization coefficient k1 and the average grayscale value of the overlapping region of the image P1 to be stitched; the grayscale equalization coefficient of the image P2 to be stitched is... k 2 is the ratio of the grayscale range equalization value to the grayscale range value of the overlapping area of the image P2 to be stitched. The grayscale correction parameter b2 of the image P2 to be stitched is the grayscale mean equalization value minus the product of the grayscale equalization coefficient k2 and the average grayscale value of the overlapping area of the image P2 to be stitched.
[0156] Step S406 above processes the foreground of the image to be stitched based on the gray-level equalization coefficient and the gray-level correction parameter. This involves processing the gray-level values of each pixel in the foreground of the image to be stitched according to the gray-level equalization coefficient and the gray-level correction parameter. The formula that can be used is:
[0157] (5);
[0158] in, k This is the grayscale equalization coefficient. b These are grayscale correction parameters. Let be the gray value of the pixel at coordinate (m,n) in the image to be stitched, and I be the gray value of the pixel after processing.
[0159] For each image in each group of images to be stitched, a set can be obtained using the above formula. k, b Value. When multiple regions of an image to be stitched overlap with other images to be stitched, the image to be stitched will exist simultaneously in multiple groups of images to be stitched. Accordingly, after the above processing, there may be multiple pairs of gray-level equalization coefficients and gray-level correction parameters. Each pair of gray-level equalization coefficients and gray-level correction parameters can be used to process the images to be stitched separately. To quickly determine the parameters for gray-level equalization processing of such images to be stitched, each pair of gray-level equalization coefficients and gray-level correction parameters can also be corrected.
[0160] In one instance of grayscale equalization processing, for an image to be stitched that has multiple regions overlapping with other images to be stitched, that image simultaneously belongs to multiple groups of images to be stitched. When an image to be stitched belongs to multiple groups of images to be stitched, the grayscale equalization processing in the image stitching grayscale processing method provided in this embodiment further includes...
[0161] S407: Extract the grayscale equalization coefficient and grayscale correction parameter of each image to be stitched in each group of images to be stitched;
[0162] S4081: Extract the mean value of each of the gray-level equalization coefficients as the gray-level equalization coefficient for correction, and extract the mean value of each of the gray-level correction parameters as the gray-level correction parameters for correction.
[0163] Alternatively, S4082: Determine a first weight for each overlapping region based on the ratio between the number of pixels in each overlapping region of the image to be stitched; obtain the sum of each gray-level equalization coefficient as a corrected gray-level equalization coefficient based on the first weight, and obtain the sum of each gray-level correction parameter as a corrected gray-level correction parameter based on the first weight.
[0164] Alternatively, S4083: Determine the second weight of each overlapping region based on the ratio of the foreground of each overlapping region of the image to be stitched to the foreground of the stitched image; obtain the sum of each gray-level equalization coefficient based on the second weight as the corrected gray-level equalization coefficient; obtain the sum of each gray-level correction parameter based on the second weight as the corrected gray-level correction parameter.
[0165] S409: Process the foreground of the image to be stitched using the corrected gray-level equalization coefficient and the corrected gray-level correction parameters.
[0166] Wherein, the sum of the first weights of each of the overlapping regions is 1, the corrected gray-scale equalization coefficient is the sum of the products of the weights of each overlapping region and the corresponding gray-scale equalization coefficients, and the corrected gray-scale correction parameter is the sum of the products of the weights of each overlapping region and the corresponding gray-scale correction parameter; the sum of the second weights of each of the overlapping regions is 1, the corrected gray-scale equalization coefficient is the sum of the products of the weights of each overlapping region and the corresponding gray-scale equalization coefficients, and the corrected gray-scale correction parameter is the sum of the products of the weights of each overlapping region and the corresponding gray-scale correction parameter.
[0167] The grayscale equalization processing method described above processes each image to be stitched in each overlapping region as a whole. The processing of each image to be stitched is based on the same logic, process and change target, which ensures the effectiveness of grayscale equalization processing.
[0168] The second method involves determining the grayscale range equalization value and the grayscale mean equalization value based on the grayscale range and grayscale mean of the overlapping regions of each of the images to be stitched together. This specifically includes:
[0169] The individual images to be stitched together that have the same overlapping area are divided into a group to obtain at least one group of images to be stitched together;
[0170] Calculate the grayscale range equalization value and the grayscale mean equalization value of the foreground of the overlapping region of each of the image groups to be stitched. The grayscale range equalization value is the average grayscale range value of the foreground of the overlapping region of each image in the image group to be stitched. The grayscale mean equalization value is the average grayscale mean value of the foreground of the overlapping region of each image in the image group to be stitched.
[0171] The second method is an improvement on the first method. In calculating the grayscale range equalization value and the grayscale mean equalization value, the second method is based on the foreground of the overlapping region of the images to be stitched in the image group. Similarly, the determination of the grayscale equalization coefficient and the grayscale correction parameter also uses the foreground of the overlapping region of the images to be stitched. Other processing steps are the same as in the first method and will not be elaborated further here.
[0172] The grayscale range equalization value and grayscale mean equalization value determined by the first and second methods mentioned above are processed using the image groups to be stitched as processing units. This results in low correlation and poor uniformity between the various image groups. Furthermore, multiple calculations are required to obtain the grayscale range equalization value and grayscale mean equalization value for each image group, leading to long processing times and poor parallel processing capabilities. This embodiment also provides the following third and fourth methods to obtain grayscale range equalization values and grayscale mean equalization values applicable to all images to be stitched.
[0173] The third method involves determining the grayscale range equalization value and the grayscale mean equalization value based on the grayscale range and mean grayscale value of the overlapping regions of each of the images to be stitched together. This specifically includes:
[0174] Based on the size of the overlapping region in each of the images to be stitched, the sum of the grayscale range values of the overlapping region in each of the images to be stitched is calculated to obtain the grayscale range equalization value.
[0175] Based on the size of the overlapping region in each of the images to be stitched, the average gray value of the overlapping region in each of the images to be stitched is calculated to obtain the gray value equalization value.
[0176] The fourth method involves determining the grayscale range equalization value and the grayscale mean equalization value based on the grayscale range and mean grayscale value of the overlapping regions of each of the images to be stitched together. This specifically includes:
[0177] Based on the size of the foreground of the overlapping region in each of the images to be stitched, the sum of the grayscale range values of the foreground of the overlapping region in each of the images to be stitched is calculated to obtain the grayscale range equalization value.
[0178] Based on the size of the foreground of the overlapping region in each of the images to be stitched, the average grayscale value of the foreground of the overlapping region in each of the images to be stitched is calculated to obtain the grayscale mean equalization value.
[0179] The difference between the third and fourth methods is that the third method calculates the grayscale value based on the grayscale values of all pixels in the overlapping areas of the images to be stitched, while the fourth method calculates it based on the grayscale values of the foreground pixels in the overlapping areas of the images to be stitched. The following explanation uses the third method as an example to further illustrate its grayscale equalization process.
[0180] See Figure 5 The diagram shown is a flowchart illustrating another embodiment of the present invention for performing grayscale equalization processing on the images to be stitched together; wherein, the grayscale equalization processing on the images to be stitched together specifically includes the following steps:
[0181] S411: Based on the size of the overlapping region in each of the images to be stitched, calculate the sum of the grayscale range values of the overlapping region in each of the images to be stitched, and obtain the grayscale range equalization value.
[0182] S412: Based on the size of the overlapping region in each of the images to be stitched, calculate the total average value of the grayscale mean of the overlapping region in each of the images to be stitched, and obtain the grayscale mean equalization value.
[0183] S413: Extract the foreground and background of each of the images to be stitched together;
[0184] S414: Based on the grayscale range equalization value, obtain the grayscale equalization coefficients for stretching or shrinking the grayscale range of the overlapping area of each of the images to be stitched.
[0185] S415: Based on the gray-level mean equalization value, the gray-level equalization coefficient of each of the images to be stitched together, and the gray-level mean of the overlapping area, the gray-level correction parameters of each of the images to be stitched together are obtained respectively.
[0186] S416: The foreground of each of the images to be stitched is processed based on the grayscale equalization coefficient and grayscale correction parameters of each image to be stitched.
[0187] In this embodiment, steps S411 to S412 specifically include:
[0188] The number of pixels in the overlapping region of each of the images to be stitched is extracted. A third weight is determined for each overlapping region of each image to be stitched based on the number of pixels. The sum of the grayscale range values of the overlapping regions of each image to be stitched is calculated based on the third weight to obtain the grayscale range balance value. The total average value of the grayscale mean of the overlapping regions of each image to be stitched is calculated based on the third weight to obtain the grayscale mean balance value.
[0189] or,
[0190] The area occupied by the foreground of each overlapping region in the foreground of the stitched image is extracted. The fourth weight of each overlapping region of each image to be stitched is determined based on the occupied area. The sum of the grayscale range values of the overlapping regions of each image to be stitched is calculated based on the fourth weight to obtain the grayscale range balance value. The total average value of the grayscale mean of the overlapping regions of each image to be stitched is calculated based on the fourth weight to obtain the grayscale mean balance value.
[0191] The following is a brief introduction to the statistical methods of the gray-scale mean balance value and the gray-scale range balance value, using the third weight as an example:
[0192] For a-1 overlapping regions, a images P1 to P2 to be stitched together a The number of pixels in the overlapping regions of the 2(a-1) images to be stitched, corresponding to the a-1 overlapping regions, are W respectively. 11 and W 21 W 22 and W 31 ...to W a-1 2 and W a1 The average gray values of the overlapping regions of the 2(a-1) images to be stitched, corresponding to the a-1 overlapping regions, are M respectively. 11 and M 21 M 22and M 31 ...to M a-1 2 and M a1 The grayscale ranges of the overlapping regions of the 2(a-1) images to be stitched, corresponding to the a-1 overlapping regions, are R... 11 and R 21 R 22 and R 31 ...to R a-1 2 and R a1 ;
[0193] The third weights of the overlapping regions of the 2a images to be stitched are C 11 and C 21 C 22 and C 31 ...to C a-1 2 and C a1 ;
[0194] C 11 +C 21 + C 22 +C 31 …+ C a-1 2 +C a1 =1;
[0195] C 11 :C 21 : C 22 :C 31 …: C a-1 2 :C a1 = W 11 :W 21 :W 22 :W 31 …:W a-1 2 :W a1 ;
[0196] The grayscale mean equalization value M1 = C 11 * M 11 +C 21 * M 21 +C 22 * M 22 +C 31 * M 31 …+ C a-1 2 * M a-1 2 +C a1 * M a1 ;
[0197] The grayscale range equalization value R1=C 11 * R 11 +C 21 * R 21 +C 22 * R22 +C 31 * R 31 …+ C a-1 2 * R a-1 2 +C a1 * R a1 .
[0198] For ease of statistical analysis, the two subscripts of the above parameters represent the nth image to be stitched and the nth overlapping region within that image when the images to be stitched are arranged in any order, such as top to bottom, left to right, or any other arrangement. For example, subscript 1 1 represents the first overlapping region of the first image to be stitched, subscript a-1 2 represents the second overlapping region of the (a-1)th image to be stitched, and subscript a 1 represents the first overlapping region of the ath image to be stitched. The first image to be stitched and the last image to be stitched each have only one overlapping region. In medical image stitching, the number of overlapping regions is usually 2 or 3. When there are 3 images to be stitched and 2 overlapping regions, the weight is C. 11 C 21 C 22 C 31 Fourthly, those skilled in the art can set the weight of the overlapping region of each image to be stitched according to the number of images to be stitched and the number of overlapping regions, and determine the gray-scale mean balance value and the gray-scale range balance value according to the above formula, which will not be elaborated further here.
[0199] In this embodiment, either the third weight or the fourth weight can be used to obtain the grayscale range equalization value and the grayscale mean equalization value. The third weight has the advantages of simple calculation method and few calculation steps, and is suitable for situations where the foreground occupies a large overlapping area, or where the accuracy requirement for each grayscale equalization process is not high, or where a fast computing speed is required. The fourth weight is slightly more complex to calculate, requiring the identification of the foreground of the image to be identified and the preliminary stitching of the images to be stitched to obtain the foreground of the stitched image. It is suitable for situations with high computing power and high requirements for grayscale equalization processing accuracy.
[0200] The specific steps of steps S413 to S416 are the same as those of steps S403 to S406, except that in steps S414 and S415, each image to be stitched shares a set of grayscale range equalization values and grayscale mean equalization values, instead of each group of images to be stitched having a set of grayscale range equalization values and grayscale mean equalization values as in steps S404 and S405. The specific calculation formulas will not be elaborated here.
[0201] Figure 5The method shown for grayscale equalization of the images to be stitched is to obtain the grayscale range equalization value and grayscale mean equalization value of each image at once. When processing each image, the influence of the grayscale range and mean of the entire overlapping region is considered, resulting in high uniformity. The processed images can more easily and quickly achieve grayscale equalization; that is, with fewer iterations, the brightness of each image can be made to be within a similar or identical grayscale range. Furthermore, in the above process, each grayscale equalization operation only requires calculating the grayscale range equalization value and the grayscale mean equalization value once. The grayscale equalization coefficient and grayscale correction parameters of each image can be quickly obtained through parallel computation, offering advantages such as low computational load and increased parallel computation capacity. This facilitates rapid completion of grayscale equalization processing and improves the speed of grayscale processing of the images to be stitched.
[0202] The grayscale threshold described in this embodiment can be used to determine the brightness difference between the images to be stitched. It is affected by the ambient light level of the environment in which the images are stitched, their location, the number of pixels in each overlapping area, and the proportion of the overlapping area in the stitched image. When the images to be stitched are spinal or full-body skeletal images, the number of pixels in the overlapping area, or the proportion of the overlapping area in the stitched image is large, the grayscale threshold is usually set relatively high. Similarly, when the images to be stitched are digital images taken under strong lighting conditions, the overlapping areas have significantly different brightness levels and a large number of pixels, and the overlapping area accounts for a large proportion of the stitched image, the grayscale threshold is also relatively high. Those skilled in the art can set the threshold according to actual needs, and further details are omitted here.
[0203] In this embodiment, the gray levels of each image to be stitched will be more similar after each gray-level equalization process. The more times the gray-level equalization process is performed, the closer the brightness of each image to be stitched will be. However, the more times the process is performed, the more time is required and the greater the computational resources are needed. Therefore, the processing can be stopped or the current gray-level processing can be completed after the gray-level equalization process has reached a preset number of iterations. The specific value of the preset number of iterations can be set by those skilled in the art according to actual needs, and will not be elaborated on here.
[0204] The above processing can adjust the foreground images of each image to be stitched to the same or similar grayscale range, reducing the brightness difference of the foreground in the stitched image. The grayscale correction parameters and grayscale equalization coefficients obtained in the above manner can also be used to directly process the background of the images to be stitched.
[0205] Since the background of the image to be stitched typically contains few or no feature regions, the background image can be stretched or offset to a greater extent. To ensure the continuity and integrity of the grayscale between the background of the image to be stitched and the foreground image after the above processing, and to avoid the problem of missing background information caused by inappropriate background processing when the foreground and background are not effectively separated, this application also provides the following method for processing the background of the image to be stitched.
[0206] The image grayscale processing method provided in this embodiment further includes processing the background of each foreground image in each image group to be stitched, which has been processed by the grayscale equalization coefficient and the grayscale correction parameter. The processing methods include direct transformation processing and / or stretching transformation processing. The image group to be stitched includes each image to be stitched with the same overlapping area.
[0207] The direct transformation process includes:
[0208] Extract the maximum gray value in the background and the minimum gray value in the foreground of the image to be stitched, and obtain the background gray value difference based on the difference between the maximum and minimum gray values;
[0209] The background of the image to be stitched is processed based on the background grayscale difference to make the grayscale values between the foreground and background of the image to be stitched continuous.
[0210] The stretching transformation process includes:
[0211] Extract the minimum gray value in the foreground of the image to be stitched, and the minimum gray value in the background of another image to be stitched, and stretch the background of the image to be stitched.
[0212] The formula for background stretching is:
[0213] ,
[0214] Where I(m,n) is the gray value of the pixel at position (m,n) in the image to be stitched. , These are the minimum and maximum grayscale values of the background of the image to be stitched, respectively. The minimum grayscale value of the foreground of the image to be stitched. The minimum grayscale value of the background of the other image to be stitched together.
[0215] In this embodiment, a background grayscale difference is obtained based on the maximum grayscale value in the background and the minimum grayscale value in the foreground. The background of the image to be stitched is then processed according to the background grayscale difference, specifically: the difference between the maximum grayscale value in the background and the minimum grayscale value in the foreground is calculated to obtain the background grayscale difference; the grayscale value of each background pixel in the image to be stitched is then filled in using the background grayscale difference.
[0216] In this embodiment, the method of processing the background image using the direct transformation process ensures the continuity and uniformity of the grayscale between the foreground and background of the processed image to be stitched. This processing method can be used to process the background of each image to be stitched in the image group, and of course, the above-mentioned stretching transformation method can also be used to process the background of each image to be stitched.
[0217] Preferably, in this embodiment, the direct transformation processing and the stretching transformation processing are used to process the two images to be stitched in the image group, respectively. Specifically, this includes: performing a direct transformation processing on one of the images to be stitched; and performing a stretching transformation processing on the other image based on the image to be stitched after the direct transformation processing. This processing method effectively ensures the balance of the background grayscale values of the two images to be stitched corresponding to the overlapping area; thus ensuring the balance of the background between corresponding areas of each image to be stitched in the stitched image.
[0218] For two images to be stitched together with a large difference in grayscale range, it's possible that after directly transforming one image, the minimum grayscale value of the image to be stitched may not be less than the minimum grayscale value of the foreground of the other image to be stitched, which requires stretching transformation. In this case, the backgrounds of the two images to be stitched can be reprocessed, with the processing methods and order reversed. Specifically, the background processing of each image in the image group to be stitched includes:
[0219] Perform direct transformation processing on one of the images to be stitched together;
[0220] Determine whether the minimum gray value in the background of the image to be stitched after the direct transformation is less than the minimum gray value in the foreground of the image to be stitched without background processing;
[0221] When the minimum gray value in the background is less than the minimum gray value in the foreground, the unprocessed background image to be stitched is stretched based on the image to be stitched after direct transformation.
[0222] When the minimum gray value in the background is greater than the minimum gray value in the foreground, the direct transformation processing is performed on the unprocessed background image to be stitched, and the stretching transformation processing is performed on another image to be stitched based on the image to be stitched after the direct transformation processing.
[0223] The above judgment further ensured the effectiveness of the background processing of the images to be stitched, and guaranteed the consistency of the background of each processed image to be stitched.
[0224] In this embodiment, extracting the foreground and background of each image to be stitched specifically involves applying a triangular thresholding method to segment each image. There are various methods for segmenting the foreground and background of an image, and those skilled in the art can choose according to actual needs; these will not be elaborated upon here.
[0225] The grayscale equalization processing method provided by this invention processes the foreground and background of the images to be stitched separately, effectively preserving foreground image features while not omitting any background features; it ensures uniform foreground brightness while maintaining consistency between background and foreground brightness. This application employs different grayscale processing methods for the foreground and background, with the methods complementing each other to effectively guarantee the uniformity of brightness in each image to be stitched after processing. This avoids the loss of effective information caused by large differences in foreground and background brightness, and simultaneously improves the quality of the stitched image.
[0226] When the grayscale processing method for stitched images based on the present invention is used to process the grayscale of the image to be stitched, the shooting parameters during each shooting can be adjusted according to the characteristics of the object to be photographed when capturing X-ray projection images. For example, when stitching together a complete lower limb image, three shots can be taken: the first shot is of the hip, the second of the thigh, and the third of the calf and foot. When shooting the hip, a higher exposure parameter can be used, when shooting the calf and foot, a lower exposure parameter can be used, and when shooting the thigh, a medium-intensity exposure parameter can be used.
[0227] The grayscale processing method for stitched images provided by this invention selects a reasonable overlapping area and combines the grayscale difference of the overlapping area with a grayscale threshold. This enables effective determination of whether to process the brightness of the images to be stitched based on the overall brightness of each image. For images requiring grayscale processing, the foreground and background are processed separately. Foreground processing is performed based on the overall situation of all images belonging to the same overlapping area, while background processing is performed based on the foreground and other images belonging to the same overlapping area. This effectively ensures the uniformity of brightness in the processed images and improves the quality of the stitched images. Moreover, this application approaches both the determination of whether to perform processing and the grayscale processing of the images to be stitched from a holistic perspective, which helps to improve image processing efficiency.
[0228] To quickly obtain the grayscale difference and suitable images for stitching, during grayscale equalization, the average grayscale value and average grayscale range of each overlapping region are acquired. Stretching correction is then applied to the image to be stitched based on its own average grayscale value and grayscale range, compared to the average grayscale value and average grayscale range of the overlapping regions. Simultaneously, to ensure the difference between the foreground and background of each image to be stitched, effective grayscale adjustment is performed on the background of each image while stretching correction is applied. This application uses a holistic approach to determine whether and to what extent grayscale equalization processing should be performed on each image to be stitched. The foreground and background of the images to be stitched are processed separately. When processing the foreground, the average grayscale value and grayscale range of each image are fully considered. Background processing is based on the results of foreground processing. For excessively dark images, the brightness of the background can be increased, allowing "foreground" elements that were mistakenly classified as background due to excessive darkness to be re-identified. For excessively bright images, the brightness can be reduced while maintaining the difference between the foreground and background. This method effectively improves the uniformity of brightness in each region of the stitched image without affecting the effective information of each individual image to be stitched, thereby improving the quality of the stitched image.
[0229] Current image stitching techniques involve stitching one overlapping region first, and then stitching another overlapping region onto the already partially stitched image. For images with multiple parts to be stitched, this requires multiple processing steps, which is cumbersome, time-consuming, and increases image processing time while reducing image stitching efficiency.
[0230] Another embodiment of this application provides an image stitching method, which includes processing each image to be stitched using the image grayscale processing method described above.
[0231] The image stitching method provided in this embodiment includes the following steps:
[0232] The overlapping regions of each image to be stitched are analyzed to determine the overlapping regions of each image to be stitched.
[0233] The image grayscale processing method described above is applied to each of the images to be stitched.
[0234] The overlapping regions of the processed images to be stitched are fused using either a direct averaging method or a weighted averaging method.
[0235] In this embodiment, the step of performing overlapping region analysis on each image to be stitched to determine the overlapping region of each image to be stitched includes:
[0236] Determine the gradient field of each of the images to be stitched together;
[0237] The cross power spectrum of each image to be stitched is determined based on the gradient field of each image to be stitched.
[0238] Based on the inverse Fourier transform of each cross-power spectrum, the peak value of the normalized correlation coefficient corresponding to each overlapping region is extracted and used as the offset between the two images to be stitched in the corresponding overlapping region.
[0239] Based on the inverse Fourier transform of each cross-power spectrum, the coordinates corresponding to the peak values of the inverse Fourier transform of each overlapping region are extracted and used as the offset between the two images to be stitched in the corresponding overlapping region.
[0240] The overlapping regions of each image to be stitched are determined based on the offset between the two images to be stitched in each overlapping region.
[0241] In this embodiment, the gradient field M(x, y) of each image to be processed is determined: ,
[0242] in, These are the partial derivatives of the image to be stitched, f(x, y), in the x and y directions, respectively. The Sobel operator is used to calculate the partial derivatives.
[0243] ,
[0244] * indicates a convolution operation.
[0245] In this embodiment, determining the cross power spectrum of each image to be stitched based on the gradient field of each image to be stitched includes: performing a Fourier transform on the gradient field image of each image to be stitched, and obtaining the spectrum of each image to be stitched; calculating the cross power spectrum of each image to be stitched belonging to the same overlapping region, and obtaining the cross power spectrum of each overlapping region.
[0246] This invention first determines the offset of each image to be stitched based on the gradient field, ensuring accurate alignment of the foreground elements within the overlapping region defined by the offset. This reduces errors caused by misalignment of pixels in the overlapping region when judging grayscale differences between the images to be stitched, thus ensuring the accuracy and effectiveness of grayscale processing. Applying the image stitching method provided by this invention, the overall brightness of the image is judged and processed. The processed images can then be stitched together, improving the efficiency of image stitching.
[0247] The grayscale processing method for stitched images provided by this invention supports redefining the overlapping area of the image to be stitched after grayscale equalization processing, which helps to determine the overlapping area multiple times and ensure the accuracy of the stitching position.
[0248] Another embodiment of the present invention provides an image stitching method that applies the image grayscale processing method described above to process two images to be stitched, and then stitches the images together. The stitched image is obtained as follows: Figure 6 As shown in b.
[0249] like Figure 6 The image stitching method of the present invention is shown to obtain the stitched image. Figure 6 b) The stitched image obtained by existing technology ( Figure 6 a) An exemplary comparison chart.
[0250] Accordingly, the present invention also discloses a grayscale processing apparatus for stitched images, which may include a processor and a memory. The memory stores computer instructions, and the processor executes the computer instructions stored in the memory. When the computer instructions are executed by the processor, the apparatus implements the steps of the method described above.
[0251] The present invention also relates to a computer storage medium having computer program code stored thereon, which, when executed, can implement various embodiments of the method of the present invention. The storage medium may be a tangible storage medium, such as an optical disc, a USB flash drive, a floppy disk, a hard disk, etc.
[0252] Those skilled in the art will understand that the exemplary components, systems, and methods described in conjunction with the embodiments disclosed herein can be implemented in hardware, software, or a combination of both. Whether implemented in hardware or software depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of this invention. When implemented in hardware, it can be, for example, electronic circuits, application-specific integrated circuits (ASICs), appropriate firmware, plug-ins, function cards, etc. When implemented in software, the elements of this invention are programs or code segments used to perform the desired tasks. Programs or code segments can be stored on a machine-readable medium or transmitted over a transmission medium or communication link via data signals carried in a carrier wave. "Machine-readable medium" can include any medium capable of storing or transmitting information. Examples of machine-readable media include electronic circuits, semiconductor memory devices, ROM, flash memory, erasable ROM (EROM), floppy disks, CD-ROMs, optical disks, hard disks, fiber optic media, radio frequency (RF) links, etc. Code segments can be downloaded via computer networks such as the Internet, intranets, etc.
[0253] It should also be noted that the exemplary embodiments mentioned in this invention describe methods or systems based on a series of steps or apparatus. However, this invention is not limited to the order of the steps described above; that is, the steps can be performed in the order mentioned in the embodiments, or in a different order, or several steps can be performed simultaneously.
[0254] In this invention, features described and / or illustrated for one embodiment may be used in the same or similar manner in one or more other embodiments, and / or combined with or in place of features of other embodiments.
[0255] The above description is merely a preferred embodiment of the present invention and is not intended to limit the present invention. For those skilled in the art, various modifications and variations can be made to the embodiments of the present invention. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of the present invention should be included within the protection scope of the present invention.
Claims
1. A method for processing grayscale values in stitched images, characterized in that, The method includes the following steps: Obtain images to be stitched together, and extract overlapping regions of each image to be stitched together; the number of images to be stitched together is at least three, and each image to be stitched together is all the images corresponding to a single stitched image; the overlapping regions are at least two. The sum of grayscale differences in the overlapping regions of the images to be stitched together is obtained. Determine whether the grayscale difference meets the grayscale threshold; When the grayscale difference does not meet the grayscale threshold, grayscale equalization processing is performed on each of the images to be stitched together. The grayscale difference sum is recalculated for each of the images to be stitched after grayscale equalization, and it is determined whether the recalculated grayscale difference sum meets the grayscale threshold. When the recalculated grayscale difference does not meet the grayscale threshold, the grayscale equalization process is repeated for each of the images to be stitched, and the grayscale difference is recalculated until the grayscale difference meets the grayscale threshold, or until the number of iterations of the grayscale equalization process for each of the images to be stitched reaches a preset number. The grayscale equalization processing of each of the images to be stitched includes: Based on the gray range and gray mean of the overlapping regions of each of the images to be stitched, the gray level equalization coefficient and gray level correction parameters are obtained. The foreground of each of the images to be stitched is processed based on the grayscale equalization coefficient and grayscale correction parameters of each image to be stitched. It also includes processing the background of each foreground image in each group of images to be stitched, which has already been processed by the grayscale equalization coefficient and the grayscale correction parameter. Specifically, this includes: The first image to be stitched is directly transformed. Determine whether the minimum gray value in the background of the first image to be stitched after the direct transformation is less than the minimum gray value in the foreground of the second image to be stitched without background processing; When the minimum gray value in the background of the first image to be stitched is less than the minimum gray value in the foreground of the second image to be stitched, the second image to be stitched without background processing is stretched based on the first image to be stitched after direct transformation processing. When the minimum gray value in the background of the first image to be stitched is not less than the minimum gray value in the foreground of the second image to be stitched, the direct transformation processing is performed on the second image to be stitched without background processing, and the stretching transformation processing is performed on the first image to be stitched based on the second image to be stitched after the direct transformation processing. The image group to be stitched includes individual images that have the same overlapping area; The direct transformation process includes: Extract the maximum gray value in the background and the minimum gray value in the foreground of the image to be stitched, and obtain the background gray value difference based on the difference between the maximum and minimum gray values; The background of the image to be stitched is processed based on the background grayscale difference to make the grayscale values between the foreground and background of the image to be stitched continuous.
2. The image grayscale processing method according to claim 1, characterized in that, The process of summing the grayscale differences in the overlapping regions of the images to be stitched together, specifically includes: The overlapping regions of two mutually overlapping images to be stitched together are recorded as a group, thus obtaining the overlapping region group; Calculate the sum of the grayscale differences of each corresponding pixel in the group of regions to be overlapped, and record it as the grayscale value of the overlapping region; The grayscale difference is obtained by summing the grayscale values of the overlapping regions of each of the groups of regions to be overlapped. or, The process of summing the grayscale differences in the overlapping regions of the images to be stitched together, specifically includes: The overlapping regions of two mutually overlapping images to be stitched together are recorded as a group, thus obtaining the overlapping region group; Calculate the sum of the grayscale differences of each corresponding pixel in the group of regions to be overlapped, and record it as the grayscale value of the overlapping region; Calculate the weights of each of the groups of regions to be overlapped; Based on the weights of each of the groups of regions to be overlapped, the sum of the gray values of the overlapping regions of each group of regions to be overlapped is calculated to obtain the gray value difference. The step of calculating the weights of each of the groups of regions to be overlapped includes: The weights of each of the overlapping regions are assigned based on the number of pixels in each of the overlapping regions. Alternatively, the weights of each group of regions to be overlapped can be assigned based on the proportion of each group of regions to be overlapped in the stitched image. Alternatively, the weights of each of the groups of regions to be overlapped can be assigned based on the proportion of the foreground in each group of regions to the foreground in the stitched image.
3. The image grayscale processing method according to claim 1 or 2, characterized in that, The step of obtaining the gray-level equalization coefficient and gray-level correction parameters based on the gray-level range and gray-level mean of the overlapping regions of each of the images to be stitched includes the following steps: Based on the grayscale range and grayscale mean of the overlapping regions of each of the images to be stitched, determine the grayscale range equalization value and the grayscale mean equalization value. Based on the grayscale range equalization value corresponding to the image to be stitched, a grayscale equalization coefficient is obtained to stretch or shrink the grayscale range of the overlapping area of the image to be stitched. The grayscale correction parameters of the image to be stitched are obtained based on the grayscale mean equalization value, grayscale equalization coefficient, and grayscale mean value of the overlapping area of the image to be stitched.
4. The image grayscale processing method according to claim 3, characterized in that, The step of determining the grayscale range equalization value and the grayscale mean equalization value based on the grayscale range and grayscale mean of the overlapping regions of each of the images to be stitched together specifically includes: Calculate the grayscale range equalization value and the grayscale mean equalization value of the overlapping region of each of the image groups to be stitched; the grayscale range equalization value is the average grayscale range value of the overlapping region of each image in the image group to be stitched; the grayscale mean equalization value is the average grayscale mean value of the overlapping region of each image in the image group to be stitched. Alternatively, determining the grayscale range equalization value and the grayscale mean equalization value based on the grayscale range and grayscale mean of the overlapping regions of each of the images to be stitched specifically includes: Calculate the grayscale range equalization value and the grayscale mean equalization value of the foreground of the overlapping region of each of the image groups to be stitched; the grayscale range equalization value is the average grayscale range value of the foreground of the overlapping region of each image in the image group to be stitched; the grayscale mean equalization value is the average grayscale mean value of the foreground of the overlapping region of each image in the image group to be stitched. Alternatively, determining the grayscale range equalization value and the grayscale mean equalization value based on the grayscale range and grayscale mean of the overlapping regions of each of the images to be stitched specifically includes: Based on the size of the overlapping region in each of the images to be stitched, the sum of the grayscale range values of the overlapping region in each of the images to be stitched is calculated to obtain the grayscale range equalization value. Based on the size of the overlapping region in each of the images to be stitched, the average gray value of the overlapping region in each of the images to be stitched is calculated to obtain the gray value equalization value. Alternatively, determining the grayscale range equalization value and the grayscale mean equalization value based on the grayscale range and grayscale mean of the overlapping regions of each of the images to be stitched specifically includes: Based on the size of the foreground of the overlapping region in each of the images to be stitched, the sum of the grayscale range values of the foreground of the overlapping region in each of the images to be stitched is calculated to obtain the grayscale range equalization value. Based on the size of the foreground of the overlapping region in each of the images to be stitched, the average grayscale value of the foreground of the overlapping region in each of the images to be stitched is calculated to obtain the grayscale mean equalization value.
5. The image grayscale processing method according to claim 4, characterized in that, In one instance of the grayscale equalization process, when one of the images to be stitched belongs to multiple groups of images to be stitched, the grayscale equalization process further includes: Extract the grayscale equalization coefficient and grayscale correction parameter of each image to be stitched in each group of images to be stitched; The average value of each gray-level equalization coefficient is extracted as the corrected gray-level equalization coefficient, and the average value of each gray-level correction parameter is extracted as the corrected gray-level correction parameter; or, a first weight of each overlapping region is determined based on the ratio of the number of pixels in each overlapping region of the image to be stitched; the sum of each gray-level equalization coefficient is obtained based on the first weight, and the sum of each gray-level equalization coefficient is used as the corrected gray-level equalization coefficient; the sum of each gray-level correction parameter is obtained based on the first weight, and the sum of each gray-level correction parameter is used as the corrected gray-level correction parameter; or, a second weight of each overlapping region is determined based on the ratio of the foreground of each overlapping region of the image to be stitched to the foreground of the stitched image; the sum of each gray-level equalization coefficient is obtained based on the second weight, and the sum of each gray-level equalization coefficient is used as the corrected gray-level equalization coefficient; the sum of each gray-level correction parameter is obtained based on the second weight, and the sum of each gray-level correction parameter is used as the corrected gray-level correction parameter. The foreground of the image to be stitched is processed using the corrected gray-level equalization coefficient and the corrected gray-level correction parameters.
6. The image grayscale processing method according to claim 5, characterized in that, Based on the dimensions of the overlapping regions in each of the images to be stitched, the sum of the grayscale range values of the overlapping regions in each of the images to be stitched is calculated to obtain the grayscale range equalization value. Additionally, based on the dimensions of the overlapping regions in each of the images to be stitched, the total average of the grayscale mean values of the overlapping regions in each of the images to be stitched is calculated to obtain the grayscale mean equalization value. Specifically, this includes: The number of pixels in the overlapping region of each of the images to be stitched is extracted, and a third weight is determined for each overlapping region of each image to be stitched based on the number of pixels. The sum of the grayscale range values of the overlapping regions of each image to be stitched is calculated based on the third weight to obtain the grayscale range balance value. The total average value of the average grayscale values of the overlapping regions of each image to be stitched is calculated based on the third weight to obtain the average grayscale value. or, The area occupied by the foreground of each overlapping region in the foreground of the stitched image is extracted respectively. The fourth weight of each overlapping region of each image to be stitched is determined based on the occupied area. The sum of the gray range values of the overlapping regions of each image to be stitched is calculated based on the fourth weight to obtain the gray range balance value. The total average value of the gray mean of the overlapping regions of each image to be stitched is calculated based on the fourth weight to obtain the gray mean balance value.
7. An image stitching method, characterized in that, This includes processing all images to be stitched using the image grayscale processing method described in any one of claims 1 to 6.
8. The image stitching method according to claim 7, characterized in that, Includes the following steps: The overlapping regions of each image to be stitched are analyzed to determine the overlapping regions of each image to be stitched. The grayscale processing method for stitched images is applied to process all images to be stitched. The overlapping regions of the processed images to be stitched are fused using either a direct averaging method or a weighted averaging method.
9. The image stitching method according to claim 8, characterized in that, The step of analyzing the overlapping regions of each image to be stitched together to determine the overlapping regions of each image includes: Determine the gradient field of each of the images to be stitched together; The cross power spectrum of each image to be stitched is determined based on the gradient field of each image to be stitched. Based on the inverse Fourier transform of each cross-power spectrum, the coordinates corresponding to the peak values of the inverse Fourier transform of each overlapping region are extracted and used as the offset between the two images to be stitched in the corresponding overlapping region. The overlapping regions of each image to be stitched are determined based on the offset between the two images to be stitched in each overlapping region.
10. A device for processing grayscale values of stitched images, characterized in that, The device includes a processor and a memory, the memory storing computer instructions, the processor executing the computer instructions stored in the memory, and when the computer instructions are executed by the processor, the device implements the method as described in any one of claims 1 to 9.
11. A computer storage medium, characterized in that, It stores a computer program that, when executed by a processor, implements the method as described in any one of claims 1 to 9.
Citation Information
Patent Citations
A digital X-ray image splicing method and device
CN109840887A
Chromatic aberration adjusting method and system
CN114723637A