DICOM format conversion method and device based on image content
By analyzing and supplementing the layer thickness and pixel spacing information in JPEG or PNG format images through image content-based methods, the problem of inaccurate parameters in DICOM format conversion is solved, achieving high accuracy and ease of operation in medical image reconstruction.
Patent Information
- Application Number
- CN202411895879.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-23
- Publication Date
- 2025-01-24
AI Technical Summary
In the prior art, DICOM format conversion tools cannot correctly generate parameters matching the original image, such as layer thickness and pixel spacing, resulting in inaccurate medical image reconstruction results.
By image -based methods, analyze the source images of the JPEG or PNG format, extract and supplement the image information data required by the DICOM standard, including layer thickness and pixel spacing, and integrate it into the DICOM format image file.
Ensure that the generated DICOM format files contain key information such as accurate layer thickness and pixel spacing, improve the accuracy and efficiency of medical image reconstruction, simplify the operation process, and enhance the reliability of the data.
Smart Images

Figure CN119361091A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of image data processing, and in particular to a DICOM format conversion method and device based on image content. Background Art
[0002] DICOM (Digital Imaging and Communications in Medicine) medical image reconstruction refers to the reconstruction of a series of medical image data to obtain a three-dimensional model or visualization results for doctors to diagnose and treat. The DICOM standard defines a medical image format that can be used for data exchange with quality that meets clinical needs. It has necessary data such as layer thickness and pixel spacing, and can effectively support the medical image reconstruction process. However, some hospitals currently have difficulties in exporting DICOM format data and can often only provide data in image formats such as JPG or PNG. These image format data cannot be directly imported into reconstruction software, and lack necessary information such as layer thickness and pixel spacing, making medical image reconstruction difficult.
[0003] In the existing technology, although some conversion tools can convert image formats into DICOM format, they cannot correctly generate parameters that match the original image during the conversion process, such as layer thickness and pixel spacing, resulting in inaccurate medical image reconstruction results, further affecting doctors' diagnosis and treatment decisions. Summary of the invention
[0004] The purpose of the present invention is to provide a method for converting JPG / PNG format images into DICOM format, aiming to effectively solve the problem of difficulty in medical image reconstruction due to the lack of necessary parameters such as pixel spacing and layer thickness in the prior art. Through the corresponding calculation method, the missing parameters of the format can be supplemented. The present invention not only simplifies the conversion process, but also ensures that the generated DICOM format file contains accurate key information such as layer thickness and pixel spacing, thereby improving the accuracy and efficiency of medical image reconstruction. Through this method, a convenient and reliable image processing solution can be provided for the medical field, thereby improving the diagnosis and treatment capabilities of doctors.
[0005] To achieve the above purpose, the technical solution adopted by the present invention is as follows: The DICOM format conversion method based on image content includes the following steps: Step S1, converting a source image in JPEG or PNG format into an image file in DICOM format, specifically includes: Step S11: The file service receives the source image in JPEG or PNG format to be converted, and parses and extracts the image information data required by the DICOM standard; Step S12: the file service generates a corresponding DICOM format image file from the extracted image information data according to the calculation method and metadata information input by the user; Step S13: the file service combines the image information data and metadata in the DICOM format image file data set to generate an image file in a format that complies with the DICOM standard; Step S14: the file service saves the image file in the format that complies with the DICOM standard to a designated target folder to obtain a DICOM image file that has undergone a preliminary format conversion; Step S15: Repeat steps S11 to S14 for multiple images in JPEG or PNG format to obtain a DICOM image file data set; Step S2, calculating missing parameters for each DICOM image file in the DICOM image file data set, specifically comprising: Step S21: the file service checks each DICOM image file in the DICOM image file data set, and confirms whether the key tag parameter is missing by parsing the DICOM file header information. For files with missing key tag parameters, the file service adds a Missing-Parameter tag to the file name or metadata, and records it in the missing key tag parameter list for subsequent supplementation; Step S22: The file service calls the image processing library PIL to view the DICOM image file marked with the missing key tag parameters, and then calls the corresponding JPEG or PNG format image to manually read the missing parameters in the source image. For the missing parameters directly read, the data is manually transferred to the file service through the graphical interface to complete the data filling of the DICOM image. For the missing parameters that cannot be read directly, they are filled after being manually calculated.
[0006] As the preferred technical solution: Optionally, the file service refers to an image data processing module in the system, which is responsible for image format conversion and data processing, receives and parses the information in the uploaded source image in JPEG or PNG format to be converted in an automated manner, and converts it into an image file in a format that complies with the DICOM standard.
[0007] Optionally, step S11 includes the following steps: Step S111: The user selects a source image in JPEG or PNG format to be converted and submits a conversion request. After receiving the request, the file service verifies the format and size of the source image to ensure that the source image meets the conversion requirements. The format must be JPEG or PNG, and RGB and grayscale images are supported; the size must meet the minimum size of 512x512 pixels and the maximum size of 4096x4096 pixels. If the source image does not meet the conversion requirements, the file service returns and gives relevant prompts so that the user can adjust the source image. Step S112: After successfully receiving and verifying the image, the file service starts a parsing operation, wherein the parsing is performed by the file service calling the image processing library PIL to read and parse the image information data; the basic data generated in this step will provide the necessary parameters for the subsequent creation of the DICOM data set.
[0008] Step S113: the file service uses the image processing library PIL to load the parsed image information data into pixel data; Step S114: The file service extracts pixel data that complies with the DICOM standard from the loaded pixel data and generates a DICOM file, which specifically includes the following steps: S1141: Use the image processing library PIL to convert the image into an array form and extract the grayscale or RGB value of each pixel data; S1142: For the image size information, read the row and column pixel data of the image, and generate the Rows and Columns parameters required in the DICOM file by the file service.
[0009] Optionally, step S12 includes the following steps: S121: performing grayscale conversion processing on the source image in the JPEG or PNG format to be converted to obtain pixel grayscale data, using histogram equalization technology to enhance image contrast, improve the clarity of detail information, and set pixel data and size information of the image; S122: The file service extracts the metadata information input by the user and sets the corresponding DICOM attributes, including image position, orientation and instance number.
[0010] S123: According to the set DICOM attributes, the image information data, metadata and other necessary DICOM attribute data are integrated to generate a corresponding DICOM format image file to ensure the integrity and availability of the image file.
[0011] Optionally, in step S121, the grayscale conversion process refers to converting the RGB image into a grayscale image through the convert method of the image processing library PIL after the source image in JPEG or PNG format is loaded; the setting refers to the file service extracting row and column pixel data, that is, the pixel matrix and its size data (width and height) from the converted grayscale image, and filling these data into the Columns and Rows fields of the DICOM file; In step S122, the extraction refers to the automatic completion by the file service, which is achieved through the collaboration of the front-end user interface and the back-end data processing module. The metadata information input by the user through the front-end interface is received by the back-end file service and automatically stored as the metadata part of the DICOM object. If the user wants to calibrate a parameter in the image information data, the user can manually enter the precise parameter data in the front-end interface, and the system will automatically integrate the input data into the corresponding field of the DICOM file; the setting refers to the file service setting the ImagePositionPatient and ImageOrientationPatient attributes according to the actual layout of the image. These attributes are standardized to specific directions and coordinates using preset rules, and the instance number is automatically generated according to the file reading order, and increases according to the order of the layers where the images are located. In the case of multi-layer images, the system sets a unique instance number for each image according to the image arrangement order to identify the position in the sequence; In step S123, the integration refers to the file service creating a blank DICOM template, generating a DICOM object by calling the standard library pydicom, and filling all the extracted image information data and metadata into the corresponding fields of the DICOM object respectively. The integration process adopts the predefined format of the DICOM file, serializes the image data and all metadata and saves them as a .DCM file.
[0012] Optionally, in step S13, the image information data and the metadata are derived from user input and / or data extracted from the image, the image information data refers to basic data derived from the image itself, including pixel value, pixel depth, channel information, image resolution and width and height, which are used to form the image information tag in the DICOM file; the metadata includes patient information tag, device information tag, study information tag and device-related information tag.
[0013] Optionally, in step S21, the key label parameters include pixel spacing and layer thickness.
[0014] Optionally, in step S22, the manual calculation refers to the calculation of the pixel spacing, which specifically includes the following steps: S221, the file service calls the image processing library PIL to check the pixel length and pixel width of the source image in JPEG or PNG format corresponding to the DICOM file marked with the missing key tag parameters and calculate the pixel spacing, wherein the pixel spacing includes the pixel center spacing in the horizontal and vertical directions, and the calculation formula is: Pixel spacing_x = image real height / pixel length; Pixel spacing_y = image actual width / pixel width; Among them, the real height and real width of the image are the image size, which can be found directly in some images; S222: If the real height and the real width of the image cannot be directly found in the image, the real size can be determined by using a scale on the image, and then the real size of the image is calculated to finally obtain pixel spacing_x and pixel spacing_y.
[0015] Optionally, in step S222, the method for calculating the real size of the image specifically includes the following steps: S2221, determine the scale pixel spacing: Divide the actual length of the scale bar by the pixel length of the scale bar S pixels , get the actual length corresponding to the pixel, the calculation formula is as follows: ; in, S pixels Represents the pixel length of the scale; S2222, calculate the true height of the image: The calculation formula is as follows: ; in, H real is the actual height of the image, H pixels is the total pixel height of the image; S2223, calculate the true width of the image: The calculation formula is as follows: ; in, W real is the actual width of the image, W pixels is the total pixel width of the image; The present invention also provides a DICOM format conversion device based on image content, comprising: one or more processors; A memory having one or more programs stored thereon, when the one or more programs are executed by the one or more processors, the one or more processors implement the method for DICOM format conversion based on image content as described above.
[0016] Compared with the prior art, the present invention has the following beneficial effects: 1. Improved the feasibility of medical image reconstruction: By automatically supplementing some missing DICOM parameters, JPG / PNG format images can be converted into DICOM format that can be processed by medical image reconstruction software.
[0017] 2. Enhanced data accuracy: It provides a reliable calculation method to obtain key label parameters, ensuring the consistency and accuracy of medical image data, which helps doctors make more accurate diagnoses.
[0018] 3. Simplified operation process: Users can complete complex data conversion and calculation processes through graphical interface operations, reducing the dependence on the operator's professional knowledge and making the operation easier.
[0019] 4. Strong compatibility: The method of the present invention can be applied to medical images from different devices, which improves the scope of application and flexibility of the system and facilitates integration into the existing medical image processing workflow.
[0020] 5. Save time and cost: By simplifying the processing flow of medical image data, it reduces the duplication of work caused by incomplete data, thereby saving manpower and time costs. BRIEF DESCRIPTION OF THE DRAWINGS
[0021] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0022] Figure 1 is an overall flow chart of the method of the present invention; Figure 2 A flowchart for implementing step S11 of the method of the present invention; Figure 3 A flowchart for implementing step S12 of the method of the present invention; Figure 4 This is a flow chart of the DICOM format conversion method according to Embodiment 1 of the present invention. DETAILED DESCRIPTION
[0023] In the following, only some exemplary embodiments are briefly described. As those skilled in the art will appreciate, the described embodiments may be modified in various ways without departing from the spirit or scope of the present invention. Therefore, the drawings and descriptions are considered to be exemplary and non-restrictive in nature.
[0024] The embodiments of the present invention are described in detail below with reference to the accompanying drawings.
[0025] The embodiment of the present invention provides a DICOM format conversion method based on image content, such as Figure 1 As shown, the following steps are included: Step S1, converting a source image in JPEG or PNG format into an image file in DICOM format, specifically includes: Step S11: The file service receives the source image in JPEG or PNG format to be converted, and parses and extracts the image information data required by the DICOM standard, which specifically includes the following steps: Figure 2 As shown: S111: The user selects a source image in JPEG or PNG format to be converted and submits a conversion request. After receiving the request, the file service verifies the format and size of the source image to ensure that the source image meets the conversion requirements. The format must be JPEG or PNG, and RGB and grayscale images are supported; the size must meet the minimum size of 512x512 pixels and the maximum size of 4096x4096 pixels. If the source image does not meet the conversion requirements, the file service returns and gives relevant prompts so that the user can adjust the source image. S112: After successfully receiving and verifying the image, the file service starts a parsing operation, wherein the parsing is performed by the file service calling an image processing library PIL to read and parse the image information data; S113: The file service uses the image processing library PIL to load the parsed image information data into pixel data; S114: The file service extracts pixel data that complies with the DICOM standard from the loaded pixel data and generates a DICOM file, which specifically includes the following steps: S1141: Use the image processing library PIL to convert the image into an array form and extract the grayscale or RGB value of each pixel data; S1142: For the image size information, read the row and column pixel data of the image, and generate the Rows and Columns parameters required in the DICOM file by the file service; Step S12: The file service generates a corresponding DICOM format image file from the extracted image information data according to the calculation method and metadata information input by the user, which specifically includes the following steps: Figure 3 As shown: S121: grayscale conversion is performed on the source image in the JPEG or PNG format to be converted to obtain pixel grayscale data, the image contrast is enhanced by using the histogram equalization technology, the clarity of the detail information is improved, and the pixel data and size information of the image are set, wherein the grayscale conversion refers to converting the RGB image into a grayscale image by using the convert method of the image processing library PIL after the source image in the JPEG or PNG format is loaded; the setting refers to the file service extracting row and column pixel data, that is, the pixel matrix and its size data (width and height) from the converted grayscale image, and filling these data into the Columns and Rows fields of the DICOM file; S122: The file service extracts the metadata information input by the user and sets the corresponding DICOM attributes, including the image position, orientation and instance number, wherein the extraction is automatically completed by the file service through the collaboration of the front-end user interface and the back-end data processing module. The metadata information input by the user through the front-end interface is received by the back-end file service and automatically stored as the metadata part of the DICOM object. If the user wants to calibrate a parameter in the image information data, the user can manually enter the precise parameter data in the front-end interface, and the system will automatically integrate the input data into the corresponding field of the DICOM file; the setting refers to the file service setting the ImagePositionPatient and ImageOrientationPatient attributes according to the actual layout of the image. These attributes are standardized to specific directions and coordinates using preset rules, and the instance number is automatically generated according to the file reading order and increases according to the order of the layers in which the images are located. In the case of multi-layer images, the system sets a unique instance number for each image according to the image arrangement order to identify the position in the sequence.
[0026] S123: According to the set DICOM attributes, the image information data, metadata and other necessary DICOM attribute data are integrated to generate a corresponding DICOM format image file to ensure the integrity and availability of the image file, wherein the integration refers to the file service creating a blank DICOM template, generating a DICOM object by calling the standard library pydicom, and filling all the extracted image information data and metadata into the corresponding fields in the DICOM object to generate a corresponding DICOM format image file. The integration process uses the predefined format of the DICOM file to serialize the image data and all metadata and save them as a .DCM file.
[0027] Step S13: The file service combines the image information data in the DICOM format image file data set with the metadata to generate an image file in a format that complies with the DICOM standard, wherein the image information data and the metadata are derived from data input by a user and / or extracted from the image, and the image information data refers to basic data derived from the image itself, including pixel value, pixel depth, channel information, image resolution and width and height, which are used to form an image information tag in the DICOM file; the metadata includes a patient information tag, a device information tag, a study information tag, and a device related information tag; Step S14: the file service saves the image file in the format that complies with the DICOM standard to a designated target folder to obtain a DICOM image file that has undergone a preliminary format conversion; Step S15: Repeat steps S11 to S14 for multiple images in JPEG or PNG format to obtain a DICOM image file data set; Among them, the file service refers to the image data processing module in the system, which is responsible for image format conversion and data processing. It receives and parses the information in the uploaded JPEG or PNG format source images to be converted in an automated manner, and converts them into image files in a format that complies with the DICOM standard.
[0028] Usually, some data is attached to the edge of medical images, but because these data come from devices of different manufacturers, their naming and display methods are not unified. However, there are several key parameters that must be displayed in the image. If we can find the word "ST" (Slice Thickness) from the image, we can intuitively obtain the slice thickness parameters; if we cannot find it directly, we can calculate the slice thickness parameters by observing the difference (unit: mm) of the "SL" (Slice Location) data of two consecutive DICOM images. For the specific calculation method of the missing parameters, perform the following step S2: Step S2, calculating missing parameters for each DICOM image file in the DICOM image file data set, specifically comprising: Step S21: the file service checks each DICOM image file in the DICOM image file data set, and confirms whether the key tag parameter is missing by parsing the DICOM file header information. For files with missing key tag parameters, the file service adds a Missing-Parameter tag to the file name or metadata, and records it in the missing key tag parameter list for subsequent supplementation; Step S22: The file service calls the image processing library PIL to view the DICOM image file marked with the missing key tag parameters, and then calls the corresponding JPEG or PNG format image, manually reads the missing parameters in the source image, and manually passes the data to the file service through a graphical interface operation for the missing parameters directly read to complete the data filling of the DICOM image. For the missing parameters that cannot be directly read, they are filled after being manually calculated, wherein the manual calculation refers to the calculation of the pixel spacing, which specifically includes the following steps: S221, the file service calls the image processing library PIL to check the pixel length and pixel width of the source image in JPEG or PNG format corresponding to the DICOM file marked with the missing key tag parameters and calculate the pixel spacing, wherein the pixel spacing includes the pixel center spacing in the horizontal and vertical directions, and the calculation formula is: Pixel spacing_x = image real height / pixel length; Pixel spacing_y = image actual width / pixel width; Among them, the real height and real width of the image are the image size, which can be found directly in some images; S222: If the real height and the real width of the image cannot be directly found in the image, the real size can be determined by using a scale on the image, and then the real size of the image is calculated to finally obtain pixel spacing_x and pixel spacing_y.
[0029] Optionally, in step S222, the method for calculating the real size of the image specifically includes the following steps: S2221, determine the scale pixel spacing: Divide the actual length of the scale bar by the pixel length of the scale bar S pixels , get the actual length corresponding to the pixel, the calculation formula is as follows: ; in, S pixels Represents the pixel length of the scale; S2222, calculate the true height of the image: The calculation formula is as follows: ; in, H real is the actual height of the image, H pixels is the total pixel height of the image; S2223, calculate the true width of the image: The calculation formula is as follows: ; in, W real is the actual width of the image, W pixels is the total pixel width of the image.
[0030] The following is a more specific example:
[0031] Example 1 (1) Select the source image to be converted Source folder: / images / source Target folder: / images / source / dicom Image range: 1 - 50 Conversion order: ASC (2) Start executing the conversion steps, such as Figure 4 As shown: a) After the file service receives the image file and submits the conversion request, the file service performs format check and image size verification on the image file after receiving the request, and parses the image information of the source image for the image file that meets the requirements; b) Create a target folder and extract the image information data required by the DICOM standard; c) The file service generates the corresponding DICOM format image file from the extracted image information data according to the calculation method and metadata information input by the user; d) The file service combines the image information data and metadata in the DICOM format image file data set to generate an image file in a format that complies with the DICOM standard; e) The file service saves the image file in the format that complies with the DICOM standard to the specified target folder to obtain the DICOM image file with preliminary format conversion; f) Perform steps a to d on the 50 images in sequence to obtain a DICOM image file dataset; (3) Calculate the missing attributes (parameters). The execution steps are as follows: For DICOM files with missing slice thickness (ST) parameters, the file service calls the image processing library PIL to find the source image, manually read the image information in the source image, find the ST value of 5mm, and pass the value to the file service after manual operation through the graphical interface to complete the data filling of the DICOM image; for the pixel spacing parameter, by checking the dimensions marked in the image, that is, the width (Width) and height (Height) are both 356mm, the pixel size is 512x512, according to the above calculation formula, that is: Pixel spacing_x = image real height / pixel length; Pixel spacing_y = image actual width / pixel width; The pixel spacing_x and pixel spacing_y are retained to 7 decimal places and are both 0.6953125. The values are manually transferred to the file service through the graphical interface to complete the data filling of the DICOM image.
[0032] For DICOM files without missing parameters, the calculation step is skipped directly and saved as DICOM files.
[0033] The process continues to update and progress until all image files to be converted are converted and saved in DICOM format, and the conversion task is completed.
[0034] (4) Effect: After conversion, 50 DICOM files are generated in the / images / source / dicom folder. All files contain correct metadata and slice thickness information and can be imported into 3D Slicer or Mimics reconstruction software for segmentation operations.
[0035] Example 2 (1) Select the source image to be converted Source folder: / images / source Target folder: / images / source / dicom Image range: 51 - 100 Conversion order: ASC (2) Start executing the conversion step, which is the same as in Example 1.
[0036] (3) Calculate the missing attributes (parameters). The execution steps are as follows: a) Manual calculation of the key parameters slice thickness (ST) and pixel spacing in images with missing parameters; b) When viewing two consecutive DICOM images, the difference in SL data is 5 mm, so ST is confirmed to be 5 mm.
[0037] c) Calculation of pixel pitch: The pixel pitch _y is obtained by comparing the real height of the image with the pixel length, and the real width of the image with the pixel width, and then the pixel pitch is obtained to be 0.5 mm.
[0038] (4) Effect: During the conversion process, the missing slice thickness and pixel spacing information were manually entered to ensure the integrity of all generated DICOM files, which could be imported into 3D Slicer or Mimics reconstruction software for segmentation operations.
[0039] Example 3 (1) Select the source image to be converted Source folder: / images / source Image range: 101 - 150 Conversion order: ASC Image size: unknown (2) Start executing the conversion step, which is the same as in Example 1.
[0040] (3) Calculate the missing attributes (parameters). The execution steps are as follows: a) Use the scale bar on the image to determine the true size of the image; find the length of the scale bar on the image, and read the image pixel size to find the pixel length of the scale bar S pixels , the scale length and S pixels The scale pixel spacing is obtained by comparison, and then the calculated scale pixel spacing is compared with the total pixel height of the image. H pixels and the total pixel width of the image W pixels Multiplying them, the real size of the image is obtained, and then the pixel spacing of the missing parameter is obtained by the same calculation method as in Example 2.
[0041] (4) Effect: All generated DICOM files correctly reflect the new pixel spacing and provide accurate slice thickness parameters, and can be imported into 3D Slicer or Mimics reconstruction software for segmentation operations.
[0042] Example 4 The present invention also provides a DICOM format conversion device based on image content, comprising: one or more processors; A memory having one or more programs stored thereon, wherein when the one or more programs are executed by the one or more processors, the one or more processors implement the method for DICOM format conversion based on image content of embodiments 1 to 3 of the present invention.
[0043] The above embodiments are only preferred embodiments of the present invention and are not limitations of the technical solutions of the present invention. Any technical solution that can be implemented on the basis of the above embodiments without creative work should be deemed to fall within the scope of protection of the patent of the present invention.
Claims
1. A DICOM format conversion method based on image content, characterized in that: The steps include: Step S1, converting a source image in JPEG or PNG format into an image file in DICOM format, specifically includes: Step S11: The file service receives the source image in JPEG or PNG format to be converted, and parses and extracts the image information data required by the DICOM standard; Step S12: the file service generates a corresponding DICOM format image file from the extracted image information data according to the calculation method and metadata information input by the user; Step S13: the file service combines the image information data and metadata in the DICOM format image file data set to generate an image file in a format that complies with the DICOM standard; Step S14: the file service saves the image file in the format that complies with the DICOM standard to a designated target folder to obtain a DICOM image file that has undergone a preliminary format conversion; Step S15: Repeat steps S11 to S14 for multiple images in JPEG or PNG format to obtain a DICOM image file data set; Step S2, calculating missing parameters for each DICOM image file in the DICOM image file data set, specifically comprising: Step S21: the file service checks each DICOM image file in the DICOM image file data set, and confirms whether the key tag parameter is missing by parsing the DICOM file header information. For files with missing key tag parameters, the file service adds a Missing-Parameter tag to the file name or metadata, and records it in the missing key tag parameter list for subsequent supplementation; Step S22: The file service calls the image processing library PIL to view the DICOM image file marked with the missing key tag parameters, and then calls the corresponding JPEG or PNG format image to manually read the missing parameters in the source image. For the missing parameters directly read, the data is manually transferred to the file service through the graphical interface to complete the data filling of the DICOM image. For the missing parameters that cannot be read directly, they are filled after being manually calculated.
2. The DICOM format conversion method based on image content according to claim 1, characterized in that: The file service refers to the image data processing module in the system, which is responsible for image format conversion and data processing. It receives and parses the information in the uploaded source image in JPEG or PNG format to be converted in an automated manner, and converts it into an image file in a format that complies with the DICOM standard.
3. The DICOM format conversion method based on image content according to claim 1, characterized in that: Step S11 includes the following steps: Step S111: The user selects a source image in JPEG or PNG format to be converted and submits a conversion request. After receiving the request, the file service verifies the format and size of the source image to ensure that the source image meets the conversion requirements. The format must be JPEG or PNG, and RGB and grayscale images are supported; the size must meet the minimum size of 512x512 pixels and the maximum size of 4096x4096 pixels. If the source image does not meet the conversion requirements, the file service returns and gives relevant prompts so that the user can adjust the source image; Step S112: after successfully receiving and verifying the image, the file service starts a parsing operation, wherein the parsing is performed by the file service calling the image processing library PIL to complete reading and parsing of the image information data; Step S113: the file service uses the image processing library PIL to load the parsed image information data into pixel data; Step S114: The file service extracts pixel data that complies with the DICOM standard from the loaded pixel data and generates a DICOM file, which specifically includes the following steps: S1141: Use the image processing library PIL to convert the image into an array form and extract the grayscale or RGB value of each pixel data; S1142: For the image size information, read the row and column pixel data of the image, and generate the Rows and Columns parameters required in the DICOM file by the file service.
4. The DICOM format conversion method based on image content according to claim 1, characterized in that: Step S12 includes the following steps: S121: performing grayscale conversion processing on the source image in the JPEG or PNG format to be converted to obtain pixel grayscale data, using histogram equalization technology to enhance image contrast, improve the clarity of detail information, and set pixel data and size information of the image; S122: The file service extracts the metadata information input by the user and sets the corresponding DICOM attributes, including image position, orientation and instance number; S123: According to the set DICOM attributes, the image information data, metadata and other necessary DICOM attribute data are integrated to generate a corresponding DICOM format image file to ensure the integrity and availability of the image file.
5. The DICOM format conversion method based on image content according to claim 4, characterized in that: In step S121, the grayscale conversion process refers to converting the RGB image into a grayscale image through the convert method of the image processing library PIL after the source image in JPEG or PNG format is loaded; The setting means that the file service extracts row and column pixel data from the converted grayscale image and fills the data into the Rows and Columns fields of the DICOM file; In step S122, the extraction refers to the automatic completion of the file service through the collaboration of the front-end user interface and the back-end data processing module. The metadata information input by the user through the front-end interface is received by the back-end file service and automatically stored as the metadata part of the DICOM object. If the user wants to calibrate a parameter in the image information data, the user can manually enter the precise parameter data in the front-end interface, and the system will automatically integrate the input data into the corresponding field of the DICOM file; the setting refers to the file service setting the ImagePositionPatient and ImageOrientationPatient attributes according to the actual layout of the image. These attributes are standardized to specific directions and coordinates using preset rules. The instance number InstanceNumber attribute is automatically generated according to the file reading order and increases according to the order of the layers where the images are located. In the case of multi-layer images, the system sets a unique instance number for each image according to the image arrangement order to identify the position in the sequence; In step S123, the integration refers to the file service creating a blank DICOM template, generating a DICOM object by calling the standard library pydicom, and filling all the extracted image information data and metadata into the corresponding fields in the DICOM object to generate the corresponding DICOM format image file. The integration process uses the predefined format of the DICOM file to serialize the image data and all metadata and save them as a .DCM file.
6. The DICOM format conversion method based on image content according to claim 1, characterized in that: In step S13, the image information data and the metadata are derived from data input by a user and / or extracted from the image, and the image information data refers to basic data derived from the image itself, including pixel value, pixel depth, channel information, image resolution and width and height, which are used to form an image information tag in a DICOM file; The metadata includes a patient information tag, a device information tag, a study information tag, and a device related information tag.
7. The DICOM format conversion method based on image content according to claim 1, characterized in that: In step S21, the key label parameters include pixel spacing and layer thickness.
8. The DICOM format conversion method based on image content according to claim 7, characterized in that: In step S22, the manual calculation refers to the calculation of the pixel spacing, which specifically includes the following steps: S221, the file service calls the image processing library PIL to check the pixel length and pixel width of the source image in JPEG or PNG format corresponding to the DICOM file marked with the missing key tag parameters and calculate the pixel spacing, wherein the pixel spacing includes the pixel center spacing in the horizontal and vertical directions, and the calculation formula is: Pixel spacing_x = image real height / pixel length; Pixel spacing_y = image actual width / pixel width; Among them, the real height and real width of the image are the image size, which can be found directly in some images; S222: If the real height and the real width of the image cannot be directly found in the image, the real size can be determined by using a scale on the image, and then the real size of the image is calculated to finally obtain pixel spacing_x and pixel spacing_y.
9. The DICOM format conversion method based on image content according to claim 8, characterized in that: In step S222, the method for calculating the real size of the image specifically includes the following steps: S2221, determine the scale pixel spacing: Divide the actual length of the scale bar by the pixel length of the scale bar S pixels , get the actual length corresponding to the pixel, the calculation formula is as follows: ; in, S pixels Represents the pixel length of the scale; S2222, calculate the true height of the image: The calculation formula is as follows: ; in, H real is the actual height of the image, H pixels is the total pixel height of the image; S2223, calculate the true width of the image: The calculation formula is as follows: ; in, W real is the actual width of the image, W pixels is the total pixel width of the image.
10. A DICOM format conversion device based on image content, characterized in that: include: one or more processors; A memory having one or more programs stored thereon, wherein when the one or more programs are executed by the one or more processors, the one or more processors implement the method for DICOM format conversion based on image content according to any one of claims 1 to 9.
Citation Information
Patent Citations
Method and apparatus for determining the completeness of DICOM image file in three-dimensional reconstruction
CN106652017A
Image registration and follow-up evaluation method, storage medium and computer equipment
CN110766730A
Systems and methods for training a convolutional neural network that is robust to missing input information
US20230162479A1