Disclosure of Invention
The invention aims to provide a method and a system for generating a DICOMDIR file, which are used for realizing anonymization processing on patient information or examination information existing in image data.
In order to achieve the purpose, the invention provides the following scheme:
a method for generating a DICOMDIR file, the method comprising the steps of:
extracting DICOM images or DICOM animations of all DICOM files in a folder needing to generate the DICOMDIR files;
obtaining a DICOM image or a first frame DICOM image of a DICOM animation to obtain a DICOM image to be processed;
carrying out binarization processing on the DICOM image to be processed to obtain a binary image;
defining the upper left corner, the upper right corner, the lower left corner and the lower right corner of the binary image as 4 character search areas;
horizontally projecting each character search area to determine the upper boundary and the lower boundary of the character line in each character search area;
performing vertical projection on each character search area to determine the left boundary and the right boundary of each character in each character search area and the number of the characters;
determining a character search area with characters in the 4 character search areas according to the number of the characters;
determining the coordinates of a cutting area according to the upper boundary and the lower boundary of a character line of a character search area with characters and the left boundary and the right boundary of each character;
cutting the DICOM image or each frame of DICOM image of the DICOM animation according to the coordinates of the cutting area to obtain a cut DICOM image, and storing the cut DICOM image into a designated file;
returning to the step of obtaining the DICOM image or the first frame DICOM image of the DICOM animation to obtain a DICOM image to be processed, and cutting the next DICOM image or DICOM animation until all DICOM images and DICOM animation in the folder needing to generate the DICOMDIR file are cut;
and generating a DICOMDIR file from all the cut DICOM images in the designated file.
Optionally, the extracting a DICOM image or a DICOM animation of all DICOM files in a folder in which the DICOM dir file needs to be generated further includes:
extracting DICOM TAG information of all DICOM files in a folder needing to generate the DICOMDIR files;
modifying the DICOM TAG information according to the TAG information which is designated by a user in a set file and needs anonymization to obtain the modified DICOM TAG information;
and writing the modified DICOM TAG information into a DICOM file corresponding to the DICOM TAG information to obtain the DICOM file modified by the DICOM TAG information.
Optionally, the horizontally projecting each text search area to determine an upper boundary and a lower boundary of a character row in each text search area specifically includes:
and projecting the character search area of the binary image in the horizontal direction, and determining the upper boundary and the lower boundary of the character line of the character search area according to the fact that the average value of the integral projection of the character in the horizontal direction is higher than the average value of the integral projection of the character in the horizontal direction of the background.
Optionally, the vertical projection is performed on each word search area to determine the left boundary and the right boundary of each character and the number of characters in each word search area, and specifically includes
And performing vertical projection on a character search area of the binary image, and determining the left boundary and the right boundary of each character and the number of the characters in the character search area according to the fact that the average value of the vertical integral projection of the character is higher than the average value of the vertical integral projection of the background and the threshold ranges of the width, the height and the interval of the characters.
Optionally, the generating a DICOM dir file from all the cut DICOM images in the designated file specifically includes:
calculating the sum of the sizes of all the cut DICOM images in the appointed folder;
calculating the number of DICOMDIR files to be generated according to the sum of the sizes of all the cut DICOM images in the appointed folder;
and generating the number of DICOMDIR files by using a DICOMDIR creating function to all the cut DICOM images in the appointed folder.
A system for generating a DICOMDIR file, the system comprising:
the DICOM image or DICOM animation extracting module is used for extracting DICOM images or DICOM animation of all DICOM files in a folder needing to generate the DICOMDIR files;
the DICOM image acquisition module to be processed is used for acquiring a DICOM image or a first frame DICOM image of the DICOM animation to obtain the DICOM image to be processed;
the binarization processing module is used for carrying out binarization processing on the DICOM image to be processed to obtain a binary image;
a character search area determining module, configured to define an upper left corner, an upper right corner, a lower left corner, and a lower right corner of the binary image as 4 character search areas;
the upper and lower boundary determining module is used for horizontally projecting each character searching area to determine the upper boundary and the lower boundary of the character line in each character searching area;
the left and right boundary determining module is used for performing vertical projection on each character searching area to determine the left boundary and the right boundary of each character in each character searching area and the number of the characters;
the character search area determination module is used for determining character search areas with characters in 4 character search areas according to the number of the characters;
the cutting area determining module is used for determining the coordinates of the cutting area according to the upper boundary and the lower boundary of the character row of the character search area with the characters and the left boundary and the right boundary of each character;
the cutting module is used for cutting the DICOM image or each frame of DICOM image of the DICOM animation according to the coordinates of the cutting area to obtain the cut DICOM image, and storing the cut DICOM image into a specified file;
the return module is used for returning to the step of obtaining the DICOM image or the first frame DICOM image of the DICOM animation to obtain a DICOM image to be processed, and cutting the next DICOM image or DICOM animation until all DICOM images and DICOM animation in the folder needing to generate the DICOMDIR file are cut;
and the DICOMDIR file generating module is used for generating the DICOMDIR file from all the cut DICOM images in the appointed file.
Optionally, the generating system further includes:
the DICOM TAG information extraction module is used for extracting DICOM TAG information of all DICOM files in a folder needing to generate the DICOM DIR files;
the DICOM TAG information modifying module is used for modifying the DICOM TAG information according to the TAG information which is designated by a user in a set file and needs anonymization to obtain the modified DICOM TAG information;
and the modified DICOM TAG information storage module is used for writing the modified DICOM TAG information into a DICOM file corresponding to the DICOM TAG information to obtain the DICOM file modified by the DICOM TAG information.
Optionally, the upper and lower boundary determining module specifically includes:
and the upper and lower boundary determining submodule is used for projecting the character searching area of the binary image in the horizontal direction, and determining the upper boundary and the lower boundary of the character line of the character searching area according to the fact that the average value of the integral projection of the character in the horizontal direction is higher than the average value of the integral projection of the character in the horizontal direction of the background.
Optionally, the left-right boundary determining module specifically includes
And the left and right boundary determining submodule is used for performing vertical direction projection on a character searching area of the binary image, and determining the left boundary, the right boundary and the number of characters of each character in the character searching area according to the vertical direction integral projection average value of the character characters which is higher than the vertical direction integral projection average value of the background and the threshold range of the width, the height and the interval of the character.
Optionally, the DICOMDIR file generating module specifically includes:
the size and sum calculating submodule is used for calculating the sum of the sizes of all the cut DICOM images in the appointed folder;
the number calculation submodule of the DICOMDIR files required to be generated is used for calculating the number of the DICOMDIR files required to be generated according to the sum of the sizes of all the cut DICOM images in the appointed folder;
and the DICOMDIR file generation submodule is used for generating the number of the DICOMDIR files from all the cut DICOM images in the appointed folder by utilizing a DICOMDIR creating function.
Compared with the prior art, the invention has the beneficial effects that:
the invention provides a method and a system for generating a DICOMDIR file, wherein the method comprises the steps of firstly, obtaining a DICOM image in a folder needing to generate the DICOMDIR file or a first frame DICOM image of DICOM animation to obtain a DICOM image to be processed; carrying out binarization processing on the DICOM image to be processed to obtain a binary image; defining the upper left corner, the upper right corner, the lower left corner and the lower right corner of the binary image as 4 character search areas; horizontally projecting each character search area to determine the upper boundary and the lower boundary of the character line in each character search area; performing vertical projection on each character search area to determine the left boundary and the right boundary of each character in each character search area and the number of the characters; determining a character search area with characters in the 4 character search areas according to the number of the characters; determining the coordinates of a cutting area according to the upper boundary and the lower boundary of a character line of a character search area with characters and the left boundary and the right boundary of each character; then, the DICOM image or each frame of DICOM image of the DICOM animation is cut according to the coordinates of the cutting area to obtain the cut DICOM image, and the cut DICOM image is stored in a designated file; after the DICOM images or DICOM animation in the folder needing to generate the DICOMDIR file are completely cut, all the cut DICOM images in the appointed file are generated into the DICOMDIR file. The invention firstly determines the character search area in the DICOM image, then searches the character characters by adopting the modes of horizontal projection and vertical projection, determines the coordinates of the cutting area, cuts the DICOM image, and generates the DICOMDIR file from the cut DICOM image, thereby realizing the anonymization processing of the patient information or the checking information in the image data.
The invention modifies the DICOM TAG which is appointed in the DICOM image file and needs anonymization while removing the characters in the DICOM image data, thereby realizing the anonymization processing for generating the DICOM image file.
Detailed Description
The technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the drawings in the embodiments of the present invention, and it is obvious that the described embodiments are only a part of the embodiments of the present invention, and not all of the embodiments. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present invention.
The invention aims to provide a method and a system for generating a DICOMDIR file, which are used for realizing anonymization processing on patient information or examination information existing in image data.
In order to make the aforementioned objects, features and advantages of the present invention comprehensible, embodiments accompanied with figures are described in further detail below.
As shown in fig. 1 and 2, the present invention provides a method for generating a DICOMDIR file, wherein the method comprises the following steps:
in the process of generating the DICOM dir file, the DICOM TAG information of the DICOM image also contains information of the patient, so that anonymization of the DICOM TAG information of the DICOM image is also required. The invention also provides an anonymization method of DICOM TAG information related to patient association and diagnosis in DICOM images, which specifically comprises the following steps: extracting DICOM TAG information of all DICOM files in a folder needing to generate the DICOMDIR files; modifying the DICOM TAG information according to DICOM TAG information such as patient information needing anonymization and designated by a user in a set file to obtain the modified DICOM TAG information; and writing the modified DICOM TAG information into a DICOM file corresponding to the DICOM TAG information to obtain the DICOM file modified by the DICOM TAG information. Setting DICOM TAG information needing anonymization to include patient information and examination information; the DICOM file managed by the DICOMDIR stores the information such as subdirectories and the like into an XML or CSV file, when the DICOMDIR file is made, the setting information of the setting file in the designated file is read, the setting information comprises the content which is specified by a user and needs anonymization, such as patient name, patient ID and diagnostician name, and when the DICOMDIR is generated, the DICOM image stores the subdirectory information (the subdirectory can be included, or the subdirectory can not be included and is set by the user).
Step 101, extracting DICOM images or DICOM animations of all DICOM files in the folder needing to generate the DICOMDIR files.
And step 102, acquiring the DICOM image or a first frame DICOM image of the DICOM animation to obtain a DICOM image to be processed.
Steps 101 and 102 specifically include: and designating a folder in which the DICOM images needing to generate the DICOMDIR exist, reading all DICOM image files in the folder, and reading DICOM TAG information of all images to enter a memory. And simultaneously, taking the DICOM image as a unit, reading the image data in each DICOM file to a memory, and if the image is an animation DICOM image, reading the first frame image in the DICOM file to the memory.
And 103, performing binarization processing on the DICOM image to be processed to obtain a binary image.
Specifically, in consideration of the characteristics of uneven gray distribution of the medical image, a Niblack local binarization method is adopted to carry out binarization processing on the DICOM image to be processed, which is stored in the memory, so as to obtain a frame of binary image.
And 104, defining the upper left corner, the upper right corner, the lower left corner and the lower right corner of the binary image as 4 character search areas.
Specifically, if there is patient information in the DICOM image data, generally, 4 ROI regions at 4 corners of the image are set as text search regions at the upper left corner, the upper right corner, the lower left corner, or the lower right corner of the image.
And 105, horizontally projecting each character search area to determine the upper boundary and the lower boundary of the character line in each character search area.
Step 106, performing horizontal projection on each text search area to determine an upper boundary and a lower boundary of a character row in each text search area, specifically including: and projecting the character search area of the binary image in the horizontal direction, and determining the upper boundary and the lower boundary of the character line of the character search area according to the fact that the average value of the integral projection of the character in the horizontal direction is higher than the average value of the integral projection of the character in the horizontal direction of the background.
And 106, vertically projecting each character search area to determine the left boundary and the right boundary of each character in each character search area and the number of the characters.
Step 106, performing vertical projection on each text search area to determine the left boundary and the right boundary of each character and the number of characters in each text search area, specifically including: and performing vertical projection on a character search area of the binary image, and determining the left boundary and the right boundary of each character and the number of the characters in the character search area according to the fact that the average value of the vertical integral projection of the character is higher than the average value of the vertical integral projection of the background and the threshold ranges of the width, the height and the interval of the characters.
The steps 105 and 106 specifically include: deleting the undersized or oversized area region of the obtained binary image before projection processing according to the characteristic that the area size of the characters is within a certain range, only reserving the region within the area range of the characters, and then performing projection processing; projecting the 2-value image of each character search area in the horizontal direction, positioning the upper and lower boundaries of the character line and storing the character line in an internal memory; and then, projecting the binary image of the character search area in the vertical direction, positioning the left and right boundaries of each character and storing the left and right boundaries in a memory.
According to the situation that the characters existing on the medical image are English letters or Arabic numerals or Chinese characters, the width, height and width-height ratio of the characters are within a certain threshold range. After the width, height, ratio of width to height of each block area are calculated, the width, height and width-height characteristics of the block areas of the characters are used for judging the existing character areas and storing the coordinate values of the characters in a memory.
And step 107, determining character search areas with characters in the 4 character search areas according to the number of the characters.
And step 108, determining the coordinates of the cutting area according to the upper boundary and the lower boundary of the character row of the character search area with the characters and the left boundary and the right boundary of each character.
Specifically, according to the results calculated in steps 105, 106, and 107, if the text search area has a character area, the maximum X and Y coordinates and the minimum X and Y coordinate ranges of each character area are calculated, a rectangular area of the middle portion of the image excluding the character is calculated from the rectangles of the entire image area as a cropping rectangle, and the rectangular coordinates are stored in the memory, the cropping rectangle ranges are as shown in fig. 3, and text areas exist in the upper left corner and the upper right corner. If no literal character exists in each literal search region, the rectangular coordinates of the cropped region (dotted line portion in FIG. 3) are not saved.
Step 109, cutting the DICOM image or each frame DICOM image of the DICOM animation according to the coordinates of the cutting area to obtain a cut DICOM image, and storing the cut DICOM image into a designated file; and returning to the step of obtaining the DICOM image or the first frame DICOM image of the DICOM animation in the folder needing to generate the DICOMDIR file to obtain the DICOM image to be processed, and cutting the next DICOM image or DICOM animation until all the DICOM images and DICOM animation in the folder needing to generate the DICOMDIR file are cut.
Specifically, if no text area exists in the image, only the patient name (0010) needing to be modified, the patient ID (0010,0020) and other information (xxxx ) needing to be modified in the TAG information stored in the memory are modified, and the modified TAG information is stored in each DICOM file again; if the image has a text area, in addition to modifying the patient information and other information which need to be modified in the TAG information stored in the memory, the DICOM image data of each frame is read, the image of each frame is cut by using the cutting rectangle obtained in the step 108 and then stored in a DICOM file, and meanwhile, the TAG values of the image width (0028,0011) and the height (0028,0010) in the DICOM file are modified to be the width and the height of the cutting rectangle area.
And step 110, generating the DICOMDIR file from all the cut DICOM images in the appointed file.
Step 110, generating a DICOM dir file from all the cut DICOM images in the designated file, specifically including: calculating the sum of the sizes of all the cut DICOM images in the appointed folder; calculating the number of DICOMDIR files to be generated according to the sum of the sizes of all the cut DICOM images in the appointed folder; and generating the number of DICOMDIR files by using a DICOMDIR creating function to all the cut DICOM images in the appointed folder.
Specifically, the sum of the file sizes of all DICOM images in a designated folder is calculated, the number of DICOMDIR files (the number of CDs or DVDs) needing to be generated is calculated according to a DICOMDIR file identifier which is used for generating CDs or DVDs and exists in a set file, then a DICOMDIR creating function is used for generating the DICOMDIR files, and if a DICOM file storage sub-directory which needs to be generated and is managed by the DICOMDIR is not designated in the set file, the DICOM files are generated under the same directory of the DICOMDIR files according to rules of the DIROMDIROMDIRs; if the setting file designates the subdirectory for storing the DICOM file managed by the DICOMDIR which needs to be generated, the DICOM file is generated according to the rule of the DICOMDIR and is stored in the designated subdirectory.
The invention also provides a DICOMDIR file generation system, which comprises:
the DICOM image or DICOM animation extracting module is used for extracting DICOM images or DICOM animation of all DICOM files in a folder needing to generate the DICOMDIR files;
the DICOM image acquisition module to be processed is used for acquiring a DICOM image or a first frame DICOM image of the DICOM animation to obtain the DICOM image to be processed;
the binarization processing module is used for carrying out binarization processing on the DICOM image to be processed to obtain a binary image;
a character search area determining module, configured to define an upper left corner, an upper right corner, a lower left corner, and a lower right corner of the binary image as 4 character search areas;
and the upper and lower boundary determining module is used for horizontally projecting each character searching area to determine the upper boundary and the lower boundary of the character line in each character searching area.
The upper and lower boundary determining module specifically includes: and the upper and lower boundary determining submodule is used for projecting the character searching area of the binary image in the horizontal direction, and determining the upper boundary and the lower boundary of the character line of the character searching area according to the fact that the average value of the integral projection of the character in the horizontal direction is higher than the average value of the integral projection of the character in the horizontal direction of the background.
And the left and right boundary determining module is used for performing vertical projection on each character searching area to determine the left boundary and the right boundary of each character in each character searching area and the number of the characters.
The left and right boundary determining module specifically comprises a left and right boundary determining submodule for performing vertical direction projection on a character search area of the binary image, and determining the left boundary, the right boundary and the number of characters of each character in the character search area according to the vertical direction integral projection average value of the character characters which is higher than the vertical direction integral projection average value of the background and the threshold ranges of the width, the height and the interval of the characters.
The character search area determination module is used for determining character search areas with characters in 4 character search areas according to the number of the characters;
the cutting area determining module is used for determining the coordinates of the cutting area according to the upper boundary and the lower boundary of the character row of the character search area with the characters and the left boundary and the right boundary of each character;
the cutting module is used for cutting the DICOM image or each frame of DICOM image of the DICOM animation according to the coordinates of the cutting area to obtain the cut DICOM image, and storing the cut DICOM image into a specified file;
the return module is used for returning to the step of obtaining the DICOM image or the first frame DICOM image of the DICOM animation to obtain a DICOM image to be processed, and cutting the next DICOM image or DICOM animation until all DICOM images and DICOM animation in the folder needing to generate the DICOMDIR file are cut;
and the DICOMDIR file generating module is used for generating the DICOMDIR file from all the cut DICOM images in the appointed file.
The DICOMDIR file generation module specifically comprises: the size and sum calculating submodule is used for calculating the sum of the sizes of all the cut DICOM images in the appointed folder; the number calculation submodule of the DICOMDIR files required to be generated is used for calculating the number of the DICOMDIR files required to be generated according to the sum of the sizes of all the cut DICOM images in the appointed folder; and the DICOMDIR file generation submodule is used for generating the number of the DICOMDIR files from all the cut DICOM images in the appointed folder by utilizing a DICOMDIR creating function.
The generation system further includes: the DICOM TAG information extraction module is used for extracting DICOM TAG information of all DICOM files in a folder needing to generate the DICOM DIR files; the DICOM TAG information modifying module is used for modifying the DICOM TAG information according to the TAG information which is designated by a user in a set file and needs anonymization to obtain the modified DICOM TAG information; and the modified DICOM TAG information storage module is used for writing the modified DICOM TAG information into a DICOM file corresponding to the DICOM TAG information to obtain the DICOM file modified by the DICOM TAG information.
In order to illustrate the technical solution of the present invention, the present invention also provides a specific embodiment.
DICOMDIR is a variable length mini database file. With group (0002, xxxx) and group (0004, xxxx) as topics, a 4-level tree structure is described. Composed of Patient, student, Series and Image. DICOM images stored in DICOM CDs or DVDs are managed by a DICOMDIR file, and DICOM image browsing software attached thereto realizes DICOM image browsing managed by DICOMDIR.
(1) Setting DICOM TAG information needing anonymization, including patient information, examination information, DICOM image storage subdirectory information managed by DICOMDIR, and the like, into a CSV (Comma-Separated Values) file, reading the setting information in the setting file when the DICOMDIR file is made, reading contents needing anonymization, such as patient name, patient ID, and diagnostician name, from the setting file, and storing the subdirectory information (with or without subdirectory or user setting) when the DICOMDIR is generated.
In the setting file, the patient name and the ID information are set to be anonymized in the embodiment, the patient name is required to be modified into a TEST1 character string during anonymization, the patient ID is modified into a 00000000 character string, the storage medium is a CD of 640 megabits, and the DICOM file for setting DICOMDIR file management is stored in a subdirectory DCM.
(2) A DICOM folder for generating DICOMDIR file is specified, wherein the folder contains 8 DSA animation DICOM images and 10 ultrasound animation images, wherein the DSA images are 16-bit grayscale images, the image resolution is 1024 × 768 pixels, and the ultrasound images are 24-bit color images, and the image resolution is 640 × 480 pixels. All DICOM images in this folder are images of the same patient, named Anonymous and checked for 2012.11.07. In the ultrasound image, information such as the name and sex of the patient is shown in the upper right corner of the image, and information such as the date and time of examination is shown in the upper left corner of the image. Wherein no text information exists in the DSA image, and the patient ID and the patient name information exist in the upper right corner of the image in the ultrasonic image. And opening and reading all files in the directory, and reading DICOM TAG information of all 18 DICOM images to a memory.
And then, taking the DICOM file as a unit, reading the image data in each DICOM file into a memory. All the DICOM files in the folder are moving DICOM images, the first frame in each DICOM file is read to a memory by taking a frame as a unit, a 16-bit DSA image is converted into an 8-bit gray-scale image through gray-scale conversion, and a 24-bit ultrasonic color image is converted into an 8-bit gray-scale image through color-to-gray-scale image conversion.
(3) And (4) in consideration of the characteristic of uneven gray level distribution of the medical image, carrying out binarization on the image data by adopting a Niblack local binarization method. The Niblack binarization method is characterized in that the mean value and the variance in a neighborhood taking a pixel point as a center jointly determine a binarization segmentation threshold value of the pixel. And taking the pixel (i, j) as a center, and taking the window with the size kxk, wherein the mean value of the gray values of all pixels in the window is m, the variance is s, and the point threshold t is m + c s, wherein c is an adjustment quantity parameter. For the DSA and ultrasound images of the present example, c was chosen to be-0.2 and k was chosen to be 5.
And after binarization is carried out by a Niblack binarization method, obtaining a binary image of the first frame image of each DICOM file stored in the memory.
(4) And removing block areas outside the threshold range of the obtained binary image according to the threshold of the area size of the character. Each character search area with 4 corners is set to be a rectangular area with the width and height of 128X160 pixels, and can include character areas with corners. And (3) projecting the binary image of each character search area in the horizontal direction, and confirming the upper boundary and the lower boundary of the character line according to the characteristic that the integral projection average value in the horizontal direction of the character is obviously higher than that in the background area. Obtaining the coordinates of the upper and lower boundaries of the possible character area and storing the coordinates into a memory; and then, carrying out vertical direction projection on the binary image in the character search area, determining the left and right boundary coordinates of each character according to the characteristics that the average value of the integral projection in the vertical direction of the character is higher than that of the integral projection in the vertical direction of the background area, and the width, height and spacing of the character are within a certain range, and storing the left and right boundary coordinates of each character in a memory. The maximum width and height of the characters in the image is 20x 12 pixels, and the average distance is 5 pixels.
And judging the character search areas with the character characters in the 4 character search areas by using the character number information stored in each character search area in the memory. And judging whether characters exist in the upper left corner and the upper right corner of the ultrasonic image according to the character of whether the character exists in the character search area, and judging that no character area exists in the DSA image.
(5) According to the result obtained by the calculation in (4), no text region exists in the DSA image, a text region of the examination date exists in the upper left corner of the ultrasonic image, a text region of the patient name exists in the upper right corner, and no text region exists in the lower left corner ROI and the lower right corner ROI. The maximum X coordinate of the text of the ROI area in the upper left corner is 170, and the maximum Y coordinate is 48; the text of the upper right ROI has a minimum X coordinate of 460 and a maximum Y coordinate of 64. The image size is 640X 480 pixels, and it is calculated that the upper left-hand X coordinate of the cropping zone is 170, the Y coordinate is 64, the upper right-hand X coordinate is 460, the Y coordinate is 64, the lower left-hand X coordinate is 170, the Y coordinate is 480, the lower right-hand X coordinate is 460, the Y coordinate is 480, and the width and height of the cropping zone is 290X 416 pixels.
(6) According to the result obtained in the step (5), no character region exists in the DSA image, the patient name (0010 ) in the TAG information stored in the memory of the DSA image obtained in the step (2) is modified to be TEST1 character string, and the patient ID (0010,0020) is 00000000 character string and then is stored in the DICOM file of the DSA.
The ultrasonic image has character areas, except that the patient name (0010) in the TAG information stored in the memory obtained in the step (2) is modified to be TEST1 character string, the patient ID (0010,0020) is 00000000 character string, the image data of each frame in the DICOM file is read, the image of each frame is cut by using the cutting rectangle obtained in the step (5) and then stored in the DICOM file, and meanwhile, the image width (0028,0011) and the height (0028,0010) of the TAG value in the DICOM file are modified to be the width and the height of the cutting rectangle area; if the settings file does not have the anonymization settings such as DICOM patient information, the DICOM file is not modified.
(7) Calculating the sum of the sizes of all DICOM images in the specified folder, wherein the sum of the sizes of 18 animation DICOM images in the specified folder is 976 million; the number of DICOMDIR files to be generated is calculated to be 2 (2 CDs) according to the conditions for generating 640 Mm of CDs set in the setting file. And then, calling a DICOMDIR creating function to generate 2 DICOMDIR files, setting a DICOM file storage subdirectory managed by the DICOMDIR in the file to be DCM, and storing the DICOM file managed by the DICOMDIR into the DCM subdirectory according to the rules of the DICOMDIR while generating the DICOMDIR file.
Compared with the prior art, the invention has the beneficial effects that:
the invention provides a method and a system for generating a DICOMDIR file, wherein the method comprises the steps of firstly, obtaining a DICOM image in a folder needing to generate the DICOMDIR file or a first frame DICOM image of DICOM animation to obtain a DICOM image to be processed; carrying out binarization processing on the DICOM image to be processed to obtain a binary image; defining the upper left corner, the upper right corner, the lower left corner and the lower right corner of the binary image as 4 character search areas; horizontally projecting each character search area to determine the upper boundary and the lower boundary of the character line in each character search area; performing vertical projection on each character search area to determine the left boundary and the right boundary of each character in each character search area and the number of the characters; determining a character search area with characters in the 4 character search areas according to the number of the characters; determining the coordinates of a cutting area according to the upper boundary and the lower boundary of a character line of a character search area with characters and the left boundary and the right boundary of each character; then, the DICOM image or each frame of DICOM image of the DICOM animation is cut according to the coordinates of the cutting area to obtain the cut DICOM image, and the cut DICOM image is stored in a designated file; after the DICOM images or DICOM animation in the folder needing to generate the DICOMDIR file are completely cut, all the cut DICOM images in the appointed file are generated into the DICOMDIR file. The method comprises the steps of firstly determining a character search area in a DICOM image, then searching character characters by adopting a horizontal projection and vertical projection mode, determining the coordinates of a cutting area, cutting the DICOM image, generating a DICOMDIR file from the cut DICOM image, removing the characters of the DICOM image, and realizing anonymization processing of patient information or inspection information in image data.
The equivalent embodiments in the present specification are described in a progressive manner, each embodiment focuses on differences from other embodiments, and the same and similar parts between the equivalent embodiments can be referred to each other.
The principles and embodiments of the present invention have been described herein using specific examples, which are provided only to help understand the method and the core concept of the present invention; meanwhile, for a person skilled in the art, according to the idea of the present invention, the specific embodiments and the application range may be changed. In summary, this summary should not be construed to limit the present invention.