Disclosure of Invention
The invention aims to provide a DICOMDIR file generation method and system containing icon images, which can realize rapid previewing of DICOM images and improve the working efficiency of medical staff.
In order to achieve the above object, the present invention provides the following solutions:
a DICOMDIR file generating method including an icon image, comprising:
acquiring a DICOM image file; the DICOM image file includes a plurality of DICOM images;
selecting a DICOM image, and compressing the DICOM image to obtain an icon image;
judging whether the DICOM image is a gray level image or a color image, and obtaining a first judging result;
extracting palette data of three colors of the DICOM image if the first judging result is a color chart; storing an icon image corresponding to the DICOM image, the height and the width of the icon image and palette data corresponding to the icon image in a DICOMDIR file; wherein the three colors are red, green and blue respectively; the icon images are stored in icon image sequence labels;
if the first judging result is a gray level image, storing an icon image corresponding to the DICOM image and the height and width of the icon image in a DICOMDIR file;
judging whether all DICOM images in the DICOM image file are selected or not to obtain a second judging result;
if the second judgment result is yes, obtaining a DICOMDIR file containing the icon image;
if the second judgment result is negative, returning to the step of selecting a DICOM image, and performing compression processing on the DICOM image to obtain an icon image.
Optionally, the compressing the DICOM image to obtain an icon image specifically includes:
acquiring a preset width of an image icon;
extracting the width and the height of the DICOM image, and determining the aspect ratio according to the width and the height of the DICOM image;
calculating the height of the image icon according to the preset width of the image icon and the aspect ratio;
and compressing the DICOM image according to the preset width of the image icon and the height of the image icon to obtain an icon image.
Optionally, the determining whether the DICOM image is a gray scale image or a color image specifically includes:
extracting luminosity interpretation degree information of the DICOM image;
judging whether the DICOM image is a gray level image or a color image according to the luminosity interpretation degree information;
wherein,,
the color map comprises a 24-bit true color image, a JPEG compressed color image and a color image with a palette;
when the luminosity interpretation information is "MONOCHROME1" or "MONOCHROME2", the DICOM image is a gray scale image;
when the luminosity interpretation information is 'RGB', the DICOM image is a 24-bit true color image;
when the luminosity interpretation information is YBR_FULL or YBR_FULL_422, the DICOM image is a JPEG compressed color image;
when the luminosity interpretation information is "PALETTE COLOR", the DICOM image is a COLOR image with a PALETTE.
Optionally, the extracting palette data of three colors of the DICOM image specifically includes:
when the color image is a 24-bit true color image, converting the 24-bit true color image into a 256-color image by adopting an octree color quantization method to obtain a first color image, and extracting palette data of three colors of the first color image;
when the color image is a JPEG compressed color image, converting the JPEG compressed color image into a 24-bit true color image, converting the 24-bit true color image into a 256-color image by adopting an octree color quantization method to obtain a second color image, and extracting palette data of three colors of the second color image;
and extracting palette data of three colors of the color image with the palette when the color image is the color image with the palette.
Alternatively to this, the method may comprise,
the storing the icon image corresponding to the DICOM image, the height and width of the icon image and the palette data corresponding to the icon image in a DICOMDIR file further comprises:
determining that the luminosity interpretation degree information of the icon image corresponding to the DICOM image is PALETTE COLOR, and storing the luminosity interpretation degree information of the icon image corresponding to the DICOM image in a DICOMDIR file;
and storing the icon image corresponding to the DICOM image and the height and width of the icon image in a DICOMDIR file, and then further comprising:
determining that the luminosity interpretation information of the icon image corresponding to the DICOM image is MONOCHROME2, and storing the luminosity interpretation information of the icon image corresponding to the DICOM image in a DICOMDIR file.
The invention also provides a DICOMDIR file generation system containing the icon image, which comprises the following steps:
the DICOM image file acquisition module is used for acquiring a DICOM image file; the DICOM image file includes a plurality of DICOM images;
the image compression module is used for selecting a DICOM image and carrying out compression processing on the DICOM image to obtain an icon image;
the first judging module is used for judging whether the DICOM image is a gray level image or a color image, and obtaining a first judging result; executing a color map processing module when the first judgment result is a color map; executing a gray scale image processing module when the first judgment result is a gray scale image;
the color map processing module is used for extracting palette data of three colors of the DICOM image; storing an icon image corresponding to the DICOM image, the height and the width of the icon image and palette data corresponding to the icon image in a DICOMDIR file; wherein the three colors are red, green and blue respectively; the icon images are stored in icon image sequence labels;
the gray level image processing module is used for storing the icon image corresponding to the DICOM image and the height and the width of the icon image in a DICOMDIR file;
the second judging module is used for judging whether all DICOM images in the DICOM image file are selected or not to obtain a second judging result; executing a DICOMDIR file generation module when the second judgment result is yes, and executing the image compression module when the second judgment result is no;
the DICOMDIR file generation module is used for obtaining a DICOMDIR file containing an icon image.
Optionally, the image compression module specifically includes:
the preset width acquisition unit is used for acquiring the preset width of the image icon;
an aspect ratio determining unit for extracting a width and a height of the DICOM image and determining an aspect ratio according to the width and the height of the DICOM image;
an image icon height calculating unit for calculating an image icon height according to the preset image icon width and the aspect ratio;
and the icon image generating unit is used for compressing the DICOM image according to the preset width of the image icon and the height of the image icon to obtain an icon image.
Optionally, the first judging module specifically includes:
a luminosity interpretation information extraction unit for extracting luminosity interpretation information of the DICOM image;
the first judging unit is used for judging whether the DICOM image is a gray level image or a color image according to the luminosity interpretation information;
wherein,,
the color map comprises a 24-bit true color image, a JPEG compressed color image and a color image with a palette;
when the luminosity interpretation information is "MONOCHROME1" or "MONOCHROME2", the DICOM image is a gray scale image;
when the luminosity interpretation information is 'RGB', the DICOM image is a 24-bit true color image;
when the luminosity interpretation information is YBR_FULL or YBR_FULL_422, the DICOM image is a JPEG compressed color image;
when the luminosity interpretation information is "PALETTE COLOR", the DICOM image is a COLOR image with a PALETTE.
Optionally, the color map processing module specifically includes:
the first palette data generating unit is used for converting the 24-bit true color image into a 256-color image by adopting an octree color quantization method when the color image is the 24-bit true color image, so as to obtain a first color image, and extracting palette data of three colors of the first color image;
the second palette data generating unit is used for converting the JPEG-compressed color image into a 24-bit true color image when the color image is a JPEG-compressed color image, converting the 24-bit true color image into a 256-color image by adopting an octree color quantization method to obtain a second color image, and extracting palette data of three colors of the second color image;
and the third palette data generating unit is used for extracting palette data of three colors of the color image with the palette when the color image is the color image with the palette.
Optionally, the system further includes:
the first luminosity interpretation information storage module is used for determining that luminosity interpretation information of the icon image corresponding to the DICOM image is PALETTE COLOR, and storing the luminosity interpretation information of the icon image corresponding to the DICOM image in a DICOMDIR file;
and the second luminosity interpretation information storage module is used for determining that the luminosity interpretation information of the icon image corresponding to the DICOM image is MONOCHROME2 and storing the luminosity interpretation information of the icon image corresponding to the DICOM image in a DICOMDIR file.
Compared with the prior art, the invention has the beneficial effects that:
the invention provides a DICOMDIR file generation method and system containing icon images, which acquire DICOM image files; selecting a DICOM image, and compressing the DICOM image to obtain an icon image; judging whether the DICOM image is a gray level image or a color image, if the DICOM image is the color image, extracting palette data of three colors of the DICOM image, and storing an icon image corresponding to the DICOM image, the height and the width of the icon image and the palette data corresponding to the icon image in a DICOMDIR file; if the icon image is a gray scale image, the icon image corresponding to the DICOM image and the height and width of the icon image are stored in the DICOMDIR file. When the DICOMDIR file is generated, icon images of DICOM images which are required to be managed by the DICOMDIR are made into icon image sequence labels in advance and stored, and when the DICOM images managed in the DICOMDIR are used for carrying out icon image reading, the icon images are generated without opening the image reading data of each DICOM image, and the icon images in the icon image sequence are directly read by the browsing software, so that the quick preview of the DICOM images can be realized, and the working efficiency of medical staff is improved.
Detailed Description
The following description of the embodiments of the present invention will be made clearly and completely with reference to the accompanying drawings, in which it is apparent that the embodiments described are only some embodiments of the present invention, but not all embodiments. All other embodiments, which can be made by those skilled in the art based on the embodiments of the invention without making any inventive effort, are intended to be within the scope of the invention.
The invention aims to provide a DICOMDIR file generation method and system containing icon images, which can realize rapid previewing of DICOM images and improve the working efficiency of medical staff.
In order that the above-recited objects, features and advantages of the present invention will become more readily apparent, a more particular description of the invention will be rendered by reference to the appended drawings and appended detailed description.
Examples
Fig. 1 is a flowchart of a method for generating a DICOMDIR file containing an icon image according to an embodiment of the present invention, as shown in fig. 1, the method for generating a DICOMDIR file containing an icon image includes:
step 101: acquiring a DICOM image file; the DICOM image file includes a plurality of DICOM images;
step 102: selecting a DICOM image, and compressing the DICOM image to obtain an icon image;
step 102, specifically includes:
acquiring a preset width of an image icon;
extracting the width and the height of the DICOM image, and determining the aspect ratio according to the width and the height of the DICOM image;
calculating the height of the image icon according to the preset width and the preset aspect ratio of the image icon;
and compressing the DICOM image according to the preset width and the image icon height to obtain an icon image.
Step 103: judging whether the DICOM image is a gray level image or a color image, and obtaining a first judging result; if the first judgment result is a color chart, executing step 104; if the first determination result is a gray scale, step 105 is performed.
Step 103, specifically includes:
extracting luminosity interpretation degree information of the DICOM image;
judging whether the DICOM image is a gray level image or a color image according to the luminosity interpretation degree information;
wherein,,
the color map includes a 24-bit true color image, a JPEG-compressed color image, and a color image with a palette;
when the luminosity interpretation information is "MONOCHROME1" (MONOCHROME 1) or "MONOCHROME2" (MONOCHROME 2), the DICOM image is a gray scale image;
when the luminosity interpretation information is RGB, the DICOM image is a 24-bit true color image;
when the luminosity interpretation information is "ybr_full" or "ybr_full_422", the DICOM image is a JPEG compressed color image;
when the luminosity interpretation information is "PALETTE COLOR", the DICOM image is a COLOR image with a PALETTE.
Step 104: extracting palette data of three colors of the DICOM image; storing icon images corresponding to the DICOM images, heights and widths of the icon images and palette data corresponding to the icon images in a DICOMDIR file; wherein the three colors are red, green and blue respectively; the icon image is stored in an icon image sequence tag.
Meanwhile, determining that the luminosity interpretation degree information of the icon image corresponding to the DICOM image is PALETTE COLOR, and storing the luminosity interpretation degree information of the icon image corresponding to the DICOM image in a DICOMDIR file.
Step 104 specifically includes:
when the color image is a 24-bit true color image, converting the 24-bit true color image into a 256-color image by adopting an octree color quantization method to obtain a first color image, and extracting palette data of three colors of the first color image;
when the color image is a JPEG compressed color image, converting the JPEG compressed color image into a 24-bit true color image, converting the 24-bit true color image into a 256-color image by adopting an octree color quantization method to obtain a second color image, and extracting palette data of three colors of the second color image;
in the case where the color image is a color image with a palette, palette data of three colors of the color image with a palette are extracted.
Step 105: and storing the icon image corresponding to the DICOM image in a DICOMDIR file, wherein the height and the width of the icon image are stored in the DICOMDIR file.
Meanwhile, determining that the luminosity interpretation degree information of the icon image corresponding to the DICOM image is MONOCHROME2, and storing the luminosity interpretation degree information of the icon image corresponding to the DICOM image in a DICOMDIR file.
Step 106: judging whether all DICOM images in the DICOM image file are selected or not to obtain a second judging result; if the second determination result is yes, go to step 107; if the second determination result is no, the step returns to step 102.
Step 107: a DICOMDIR file is generated.
In particular, the method comprises the steps of,
the invention provides a DICOMDIR file generation method containing icon images, which comprises the following steps:
(1) And opening the DICOM image files in the designated folder needing to generate the DICOMDIR files one by one, reading (0028, 0004) (Photometric Interpretation, luminosity interpretation) label values in the DICOM image files to obtain luminosity interpretation degree information of the DICOM image, and judging whether the generated icon image is a gray image or a 256-color image according to the luminosity interpretation degree information. Reading the value in the (0028, 0011) (Columns) label in the DICOM image file header information to obtain the width of the DICOM image, reading the value in the (0028, 0010) (Rows ) label in the DICOM image file header information to obtain the height of the DICOM image, obtaining the ratio of the width to the height of the DICOM image, and keeping the aspect ratio of the icon image consistent with the DICOM image when generating the icon image.
(2) If the luminosity interpretation information of the DICOM image obtained in (1) is 'MONOCHROME1' or 'MONOCHROME2', it means that the DICOM image is a gray scale image, and an icon image of the gray scale image needs to be generated. And reading a first frame image in the DICOM image file to a memory, generating gray icon image data according to the width-height ratio, and storing the gray icon image data to the memory.
If the photometric interpretation degree information of the DICOM image obtained in (1) is RGB, it means that the image is a 24-bit true color image, and palette data of three colors of 256 colors of red, green, and blue is generated using the 24-bit true color image data.
The 24-bit true color chart is converted into a 256-color chart, and common algorithms include a stream color algorithm, a median segmentation algorithm, an octree color quantization algorithm and the like, wherein as shown in fig. 2, the basic ideas of the octree color quantization algorithm are as follows: RGB color values used in the image are distributed into layered octree. The depth of the octree can reach 9 layers, i.e. the root node layer plus 8-layer nodes for each bit representing a R, G, B value of 8 bits, respectively. The lower node layer corresponds to the bits of the less important RGB values (right bits). Leaf node codes store the number of pixels and the value of R, G, B color component; while the middle nodes constitute the path from the topmost layer to the leaf nodes. The method is an efficient storage mode, can store colors and the times of occurrence of the colors in the image, does not waste memory to store colors which do not occur in the image, and has high efficiency and good effect of the octree color quantization algorithm.
In order to generate high-quality icon images, an octree color quantization algorithm is adopted to realize that a 24-bit true color image is converted into a 256-color image, then color palette data of 256 colors of red, green and blue are obtained, icon image data are generated according to a certain size, and the icon image data are stored in a memory.
If the photometric interpretation degree information of the DICOM image obtained in (1) is ybr_full, ybr_full_422, the DICOM image is a JPEG-compressed color image. The method comprises the steps of reading color image data of a first frame of a DICOM image file corresponding to an icon image, converting the color image data into a 24-bit true color image after the color image data is stored in a memory, converting the 24-bit true color image into a 256-color image by adopting an octree color quantization algorithm, obtaining palette data of 256 colors of red, green and blue, generating the icon image data according to a certain size, and storing the icon image data in the memory.
If the luminosity interpretation information PALETTE COLOR of the DICOM image obtained in (1), the DICOM image is a COLOR image with a PALETTE. The label (0028,1201) Red Palette Color Lookup Table Data (red palette color lookup table data), (0028,1202) Green Palette Color Lookup Table Data (green palette color lookup table data), (0028,1203) Blue Palette Color Lookup Table Data (blue palette color lookup table data) in the header of the DICOM image file corresponding to the icon image is read, and palette data of three colors of palette red, green and blue are obtained. And reading a first frame image of the DICOM image file corresponding to the icon image, generating icon image data according to a certain size, and storing the icon image data into a memory.
(3) After the DICOM images in the DICOM image folder are designated to be processed completely, a DICOM dir file is generated by using a DICOM dir creation function, after an icon image sequence (0088,0200) label is inserted into the header of the created DICOM dir file, a photometric interpretation degree (0028, 0004) label of the icon image is written into the icon image sequence (0088,0200) label, if the icon image is a gray image, a MONOCHROME2 is written into the (0028, 0004) label, if the icon image is a 256-COLOR image, a PALETTE COLOR is written into the (0028, 0004) label, and three labels are written into the (0028,1201), (0028,1202), (0028,1203) and red, green and blue COLOR PALETTE data obtained in (2) are written into the three labels, respectively. An image width label (0028, 0011) is written in the icon image sequence (0088,0200) label and an image width value is written in the label, and an image height label (0028, 0010) is written in the icon image sequence (0088,0200) label and an image height value is written in the label. And finally, sequentially writing the icon image data obtained in the step (2) into the label (0088,0200), and finally storing the generated DICOMDIR file.
For example, the number of the cells to be processed,
DICOMDIR is a variable length mini database file. The subject matter of group (0002, xxxx) and group (0004, xxxx) is a 4-level tree structure. Consists of Patient (Patient), study (Study), sequence (Series) and Image (Image). The DICOM images stored in the DICOM CD or DVD are managed by the DICOMDIR file, and the DICOM images managed by the DICOMDIR are browsed by the DICOM image browsing software.
(a) A DICOM image folder is designated in which there are 36 ultrasound DICOM images. The (0028, 0004) (Photometric Interpretation) tag values in DICOM in the DICOM image folder are read one by one to obtain a luminosity interpretation degree of an icon image as 'RGB', representing that the icon image is a 24-bit color image, the (0028, 0011) (Columns) tag values are read to obtain a number of lines of the DICOM image as 640, representing that the width of the DICOM image is 640, and the (0028, 0010) (Rows) tag values are read to obtain a number of Columns of the DICOM image as 480, representing that the height of the icon image is 480. The aspect ratio of the DICOM image is calculated to be 4:3.
(b) Reading a first frame of the DICOM image into a memory, converting a 24-bit true color image into a 256-color image by using an octree color quantization algorithm, obtaining palette data of three colors of red, green and blue of 256 colors, setting the width of an icon image to be 128, and calculating the height of the image to be 96 according to the aspect ratio of the DICOM image obtained in the step (a). According to the width and height values of the icon image, the first frame 24-bit true color image in the memory is used for generating 256-color 128X96 icon image data, and the 256-color 128X96 icon image data is stored in the memory.
(c) After 36 DICOM images are circularly processed, a DICOMDIR creation function is called to generate a DICOMDIR file. According to the DICOM standard, an icon image sequence (0088,0200) label is inserted into the head of a DICOMDIR file, because the DICOM image is a color image, the icon image is a 256-color image, when the photometric interpretation degree (0028, 0004) label of the icon image is written into the icon image sequence (0088,0200) label, (0028, 0004) label value is written into PALETTECOLOR, three labels are written simultaneously (0028,1201), (0028,1202), (0028,1203), and the palette data of three colors of red, green and blue obtained in (b) are written into the three labels respectively. The width of the icon image is 128, and when the width label (0028, 0011) of the icon image is written in the label of the icon image sequence (0088,0200), the label value (0028, 0011) is 128. The height of the icon image is 96, and when the height label (0028, 0010) of the icon image is written in the label of the icon image sequence (0088,0200), the label value (0028, 0010) is 96.
And finally, storing the generated DICOMDIR file.
Fig. 3 is a diagram of a DICOMDIR file generating system including icon images according to an embodiment of the present invention. As shown in fig. 3, a DICOMDIR file generating system including an icon image, comprising:
a DICOM image file obtaining module 201, configured to obtain a DICOM image file; the DICOM image file includes a plurality of DICOM images.
The image compression module 202 is configured to select a DICOM image, and compress the DICOM image to obtain an icon image.
The image compression module 202 specifically includes:
the preset width acquisition unit is used for acquiring the preset width of the image icon;
an aspect ratio determining unit for extracting a width and a height of the DICOM image and determining an aspect ratio according to the width and the height of the DICOM image;
an image icon height calculating unit for calculating an image icon height according to the preset width and the aspect ratio of the image icon;
and the icon image generating unit is used for compressing the DICOM image according to the preset width of the image icon and the height of the image icon to obtain an icon image.
A first judging module 203, configured to judge whether the DICOM image is a gray scale image or a color image, to obtain a first judging result; executing a color map processing module 204 when the first judgment result is a color map; when the first determination result is a gray scale, the gray scale processing module 205 is executed.
The first judging module 203 specifically includes:
a luminosity interpretation information extraction unit for extracting luminosity interpretation information of the DICOM image;
the first judging unit is used for judging whether the DICOM image is a gray level image or a color image according to the luminosity interpretation degree information;
wherein,,
the color map includes a 24-bit true color image, a JPEG-compressed color image, and a color image with a palette;
when the luminosity interpretation information is "MONOCHROME1" or "MONOCHROME2", the DICOM image is a gray scale image;
when the luminosity interpretation information is RGB, the DICOM image is a 24-bit true color image;
when the luminosity interpretation information is "ybr_full" or "ybr_full_422", the DICOM image is a JPEG compressed color image;
when the luminosity interpretation information is "PALETTE COLOR", the DICOM image is a COLOR image with a PALETTE.
A color map processing module 204 for extracting palette data of three colors of the DICOM image; storing icon images corresponding to the DICOM images, heights and widths of the icon images and palette data corresponding to the icon images in a DICOMDIR file; wherein the three colors are red, green and blue respectively; the icon image is stored in an icon image sequence tag.
The color map processing module 204 specifically includes:
the first palette data generating unit is used for converting the 24-bit true color image into a 256-color image by adopting an octree color quantization method when the color image is the 24-bit true color image, so as to obtain a first color image, and then extracting palette data of three colors of the first color image;
the second palette data generating unit is used for converting the JPEG compressed color image into a 24-bit true color image when the color image is the JPEG compressed color image, converting the 24-bit true color image into a 256-color image by adopting an octree color quantization method to obtain a second color image, and extracting palette data of three colors of the second color image;
and a third palette data generating unit for extracting palette data of three colors of the color image with palette when the color image is the color image with palette.
The gray scale image processing module 205 is configured to store the icon image corresponding to the DICOM image and the height and width of the icon image in the DICOMDIR file.
A second judging module 206, configured to judge whether all DICOM images in the DICOM image file have been selected, so as to obtain a second judging result; when the second determination result is yes, the DICOMDIR file generating module 207 is executed, and when the second determination result is no, the image compressing module 202 is executed.
The DICOMDIR file generating module 207 is configured to generate a DICOMDIR file.
The invention provides a DICOMDIR file generation system containing icon images, which further comprises:
the first luminosity interpretation information storage module is used for determining that luminosity interpretation information of the icon image corresponding to the DICOM image is PALETTE COLOR, and storing the luminosity interpretation information of the icon image corresponding to the DICOM image in a DICOMDIR file.
And the second luminosity interpretation information storage module is used for determining that the luminosity interpretation information of the icon image corresponding to the DICOM image is MONOCHROME2 and storing the luminosity interpretation information of the icon image corresponding to the DICOM image in a DICOMDIR file.
For the system disclosed in the embodiment, since it corresponds to the method disclosed in the embodiment, the description is relatively simple, and the relevant points refer to the description of the method section.
The principles and embodiments of the present invention have been described herein with reference to specific examples, the description of which is intended only to assist in understanding the methods of the present invention and the core ideas thereof; also, it is within the scope of the present invention to be modified by those of ordinary skill in the art in light of the present teachings. In summary, the present description should not be construed as limiting the invention.