Abstract: Through analysis of a large number of DICOM images and Analysis of DICOM standard documents, we understand the structure and composition of the image. At the same time, we analyze the BMP image to obtain the structure of the BMP image, this paper proposes a method for converting DICOM images and BMP images.
Keywords DICOM; BMP; data element; Pixel
Graph classification: tp317.4; tn911.73 Document Identification Code: article A No.: 1003-8868 (2004) 01-0013-03
With the application of the dicom3.0 standard in various medical devices, it has become a reality that digital imaging devices of various manufacturers transmit and exchange digital images. Based on this, the PACS (image archiving and transmission system) can achieve digital storage and transmission of image equipment data, achieve network-based and non-film-based management, not only to maintain the original data, but also convenient calls, saves storage space, saves costs, and enables remote transmission and remote medical treatment.
Another advantage of DICOM standards for users is that all devices use this standard, so they can effectively use the image resources of various devices and process them in computers, instead of studying the image storage structure of each device. However, DICOM images cannot be recognized by common image processing software. Therefore, DICOM images must be converted to facilitate processing.
There are many common image formats. BMP images are one of the most widely used image formats and are easy to process. Therefore, BMP images are selected. To achieve this conversion, the specific structure of the two images must be analyzed.
1 device and software
(1) equipment: ① Siemens Plus 4 spiral CT; ② Siemens magic view 50 (mv50) medical image processing workstation; ③ DICOM image processing workstation of mediface Corporation piview (Korea.
(2) software: ① Microsoft's Windows98 drawing software; ② X-ways software technology's hexadecimal editing and analysis software winhex.
2 Method
Output a series of images of different patients and different parts from CT to mv50, use winhex to open DICOM image files in mv50, and analyze the structure and content of DICOM files based on DICOM standard documents, similarities and differences. Then, the image is transmitted to piview, and the structure content is analyzed in combination with the image file provided by piview and the DICOM file converted from the non-DICOM image, and compared with the DICOM file on the original mv50, master key data.
All kinds of DICOM-compliant equipment manufacturers should provide DICOM conformance statement of the device. The data elements in the DICOM image file of the device are described, this allows you to know the elements and content of the DICOM file of the device. On the other hand, a series of BMP image files are manually generated using the Windows98 drawing software. Use winhex to open the BMP file and learn the structure information of the BMP image file.
3 Results
3.1 DICOM image file structure
DICOM image files generally consist of a file header and a DICOM data set.
3.1.1 DICOM file header
DICOM file meta information contains the information that identifies the data set. The beginning of the file header is the file recognition information, which consists of the introduction of a 128-byte file and can be used for application protocols or specific operation definitions, this is to make the images and other data provided in DICOM files easier to be accessed and processed. If the introduction does not express information, the 128 bytes should be filled with the hexadecimal 00. The following is the DICOM prefix, which is a 4-byte string "dicm". You can determine whether a file is a DICOM file based on the value. The header is followed by the DICOM data set described later. Although the DICOM standard description requires that the file header be included, it can also be recognized by DICOM application software. When no file header is available, the file starts with a DICOM data set.
3.1.2 DICOM data set)
Unlike other image files, DICOM files contain not only image data, but also many other image-related information, such as patient name, birth date, check date, patient number, check the location and so on. There are brief characters and numbers. To express this information, the DICOM Standard defines a large number of data elements. The DICOM data set is composed of some data elements selected according to a certain order.
Data elements are mainly composed of four parts: Data Element tag, data description (Vr: value representation), data length, and data value body (figure 1 ).
(1) The label is a 4-byte unsigned integer. The high byte is the group number, and the low byte is the element number. All DICOM data elements have a unique tag. Each standard data elements tag, that is, a tag with an even number, is defined in the DICOM standard data dictionary; users can define their own data elements (private data elements, an odd number of group numbers). in DICOM standard, they can also define their own data elements with detailed rules. (2) Data Description VR indicates the data type in the data element, which is represented by two byte long strings and is the default character set in DICOM standard, the existing VR has a detailed definition in the DICOM standard. For example, "PN" indicates the name type, "as" indicates the age type, "da" indicates the date type, and "FL" indicates that the data in the data element is the floating point data. Data description VR is optional in DICOM files. If explicit transmission is specified, VR is required. This item must be omitted during implicit transmission. (3) The data length is determined based on different VR types (whether explicit or implicit transmission) to 2 bytes or 4 bytes of unsigned integers. It specifies the length of the data value body (excluding the length of tags, VR, and data itself ). (4) the data value body, which is an even byte and contains the content of the data element. In DICOM files, all data except the file header is in the form of data elements.
3.1.3 specific DICOM data
Comparing the DICOM description file with the specific DICOM file structure, the content after the DICOM element label is (,) is a brief description of the file (Specific Character Set ), indicates a record number of the ISO Organization, (,) indicates the type of the image, (,) and (,) are identification codes related to the transmission and identification of DICOM files) is the patient name, (94800) is a number given to the patient by the hospital (such as "CT #"), () is the patient's date of birth, () represents the gender, "M" represents male and "F" represents female. The last one (0010,) Stores DICOM image pixel data. The front is the length of the data, and the back is the specific Image array data.
In addition, DICOM files are divided into implicit and explicit transmission by transmission mode. DICOM files are implicitly transmitted without VR. You must know the Data Types of elements in the files, you can only query the DICOM description file of the device based on the group number and element number of the tag, or query the DICOM standard data dictionary, and the file does not have a file header.
The DICOM file that is explicitly transmitted has 128 bytes in front and its value is "00", followed by the DICOM file recognition mark "dicm ", the element (0002,) after "dicm" represents the length of the "" group, with VR. VR is "Ul", indicating that its content is an unsigned integer; (0002,0001) VR is "ob", indicating that its content is a data type dedicated to transmission; (0002,4955) VR is "UI ", it is the encoding information used for identification in DICOM files.
From the above introduction, you can easily read DICOM files, including image data, text data, transmission information, and other data.
3.2 BMP image file structure
A common BMP image file consists of three parts: File Header, bitmap information, and pixel array. The file header is 14 bytes long and the basic part of the bitmap information is 40 bytes long. The first 54 bytes are fixed-position data, 4 × n Bytes after 55 bytes are the color table (figure 2 ).
3.2.1 file headers of BMP image files
The file header consists of the file identification mark, file size, retention value, and the starting position of the image pixel array:
0th, 1-bit, "42 4D" indicates the ASCII string "BM", which is a mark for BMP file recognition; 2nd ~ 4-bit file size, indicating the total number of bytes of all content in the BMP file including the file header, bitmap information, and pixel array; 6th ~ 9 bits, the system retains the backup, the total value is 0; The ~ D-bit is the starting position of the Image array. In Figure 2, it is "0036" (the low position is in front and the high position is in the back ).
3.2.2 bitmap information of BMP Images
Bitmap information consists of a 40-byte basic bitmap information and an indefinite (multiples of 4) color table. The basic bitmap information is required:
No. E ~ 11 bits indicates the length of basic bitmap information. The total value is "28", and the value is "40" in decimal format. The value ranges from 12th ~ 15 BITs, which is the pixel width "200"; 16th ~ The 19th digit is the pixel height "200". We can see that this is a decimal "512 × 512" image. The 1A and 1B digits are the number of image planes, it is generally "1"; the 1c and 1D bits represent the digits of each pixel. In Figure 2, "0018" indicates that each pixel occupies the "24" bits in decimal format ), that is, it occupies 3 bytes (because BMP is a color image, blue, green, and red take one byte each, and a pixel is composed of three colors); 1E ~ 21 bits, indicating the image compression type. The value "0" without compression; 23rd ~ A 25-bit array is the size of a pixel array. Its value is equal to "pixel width × pixel height × the number of bytes occupied by each pixel ", in Figure 2, "200h × 200h × 3 = c0000h" (h indicates hexadecimal); 26th ~ 29-bit horizontal resolution; 2a ~ 2d is the vertical resolution; 2E ~ 31 bits are the number of colors in the palette; 32nd ~ 35 BITs are important color indexes.
Color Table:
36th ~ The base color is 39 BITs, which are blue, green, red, and "0" in sequence. Each four bits behind a group represent multiple sets of foreground views, until the address offset specified by the starting position of the Image array in the file header is the previous one.
The color ing table is optional and is mainly used for color effect rendering. It should not be used in medical images, therefore, in Figure 2, the basic bitmap information is directly followed by the image pixel array (the address offset is "0036 ").
3.2.3 pixel array of BMP Images
This part of the data records each pixel value of the image. When each pixel occupies three bytes, the values represent blue, green, and red, respectively, you can use a combination of 16 m colors (figure 2 ).
4 Conclusion
To convert a DICOM image to a BMP image, you must first read the parameters in the DICOM image file. You can use the DICOM instruction file or the data dictionary in the DICOM standard to query the relevant data stored in the image, including the image display matrix, that is, the width and height of the image, and the number of digits stored in the image, that is to say, each pixel occupies several bytes. If the image is a standard 12-bit grayscale (black and white) image, two bytes are required. Find the element with the tag number (7fe0, 0010, it specifies the starting position of the image pixel.
The pixel display sequence is from left to right, from top to bottom, the first line is displayed and then the second line is displayed, set the first pixel coordinate in the upper left corner ), the address in the stored file is "A0", and the display matrix is m-width and N-height. When the image is displayed, the coordinates are (x, y) the location of the pixel in the file is: 2 x [x + m x (Y-1)-1] + a0.
With the above data, you can determine the relevant parameters of the BMP image and determine the storage location of each pixel in the file. However, unlike the pixel display sequence in DICOM images, BMP images are displayed from the lower left corner, from left to right, and from bottom to top, therefore, we need to add the lowest pixel in the DICOM image to the top row of the BMP image.
Note: In BMP images, the blue, green, and red values of pixels are equal to each other to form a black-and-white image. Therefore, when displaying a black-and-white image, these three bytes contain only one byte of information, so that the BMP image can only contain 8-bit, 256 grayscale levels. The 12-bit grayscale image of DICOM can contain 4096 (212) gray level. To convert a 12-bit DICOM image to a BMP image, it must be transformed.
Before using the Window Technology (LUT), you must read the display window width and window bit values (in DICOM devices or software, adjust the window width and window position to the optimum), and determine the center value based on the window width. The display lower than the window width is the lowest, and the display higher than the window width is the brightest, values in the window width range are converted to values smaller than 256 through linear or nonlinear transformation. Due to the limited resolution of human eyes, 256 gray-scale images have been fully capable of meeting the identification limits of human eyes.
For 8-bit black and white images or color Doppler ultrasound images, the length structure of a single pixel is the same as that of BMP. You only need to enter the BMP image in the coordinate position.
References
1 Wang Zhiyuan, Yu houjun, Shi Mingguo. Principles and Applications of DICOM in medical image communication standards (I). Modern medical imaging, (2): 84 ~ 87
2 Wang Zhiyuan, Yu houjun, Shi Mingguo. Principles and Applications of DICOM in medical image communication standards (2). Modern medical imaging, 134 (3 ~ 137
3 Wang Zhiyuan, Yu houjun, Shi Mingguo. Principles and Applications of DICOM in medical image communication standards (iii). Modern medical imaging, 177 (4 ~ 179
4. Lin Tianyi, Chen Siping, Tao duchun, et al.. Implementation of Digital Medical Image Communication Standards (DICOM). China's medical imaging technology, 2000, 16 (5): 802 ~ 804
5 sun Xuefeng. Composition and Application of BMP images. Computer development and application, 2000 (7): 26 ~ 27