How to obtain hexadecimal data in Java parsing DICOM diagram

preface

In a recent project, it is necessary to use java to analyze DICOM pictures. DICOM is widely used in radiation medicine, cardiovascular imaging and radiation diagnosis and treatment equipment (X-ray, CT, nuclear magnetic resonance, ultrasound, etc.), and is more and more widely used in Ophthalmology, dentistry and other medical fields. Some problems encountered in the implementation are recorded below.

First find a * DCM file. Open it with the editor and you can see the following interface. The editor I use is UltraEdit

The red character indicates the byte code, and the first 8 lines of code are the header information of the file, which is generally useless. The four hexadecimal numbers "44,49,43,4d" starting from the ninth line are very important. Interpreted with ascll code is DICM. Indicates that this is a DICOM file. If the four hexadecimal numbers are lost or damaged, the DICOM picture cannot be opened.

Next, use java to read these hexadecimal numbers

(because the file is too large and has 130000 bytes, it only circulates 10000 times for display. Read the first 10000 bytes)

The above code is very common, which is to read the file stream into the byte array. Use integer Tohexstring (B [i]) converts it to hexadecimal.

There's a problem.

After operation:

Compared with the hexadecimal list opened by the above editor, the red letter should be A6, but ffffa6 is printed.

Find problems

The position of the written error byte is 140. Print system out. pritln(b[140]); The result is - 90. Why - 90?.

Push backward to A6 convert to decimal should be 166.

Well, these problems have been found. 166 + 90 = 256. It's no coincidence. One problem ignored is that the maximum value of byte array is only 127 Therefore, when the array read in the file is greater than 127, the reading of byte array will make an error.

resolvent

summary

The above is the whole content of this article. I hope the content of this article has a certain reference value for your study or work. If you have any questions, you can leave a message. Thank you for your support for programming tips.

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>