原文是(https://stackoverflow.com/questions/40482993/creation-of-multi-frame-dicom-image-using-dcm4che3java)
因为dcm4che2版本的jar包已经无法下载了,所以我直接把dcm4che2的class类复制到了项目中。
package yd.jpg2dcmbyJava.dcm2.test;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
import java.util.UUID;
import javax.imageio.IIOImage;
import javax.imageio.ImageIO;
import javax.imageio.ImageWriter;
import javax.imageio.stream.FileImageOutputStream;
import yd.jpg2dcmbyJava.dcm2.data.BasicDicomObject;
import yd.jpg2dcmbyJava.dcm2.data.DicomObject;
import yd.jpg2dcmbyJava.dcm2.data.Tag;
import yd.jpg2dcmbyJava.dcm2.data.UID;
import yd.jpg2dcmbyJava.dcm2.data.VR;
import yd.jpg2dcmbyJava.dcm2.image.DicomImageWriterSpi;
import yd.jpg2dcmbyJava.dcm2.image.DicomStreamMetaData;
import yd.jpg2dcmbyJava.dcm2.util.UIDUtils;
/**
* 封装多图,测试可行
* @author D140
*
*/
public class Mpeg2Dicom {
public Mpeg2Dicom() {
}
public DicomObject createDicomHeader(BufferedImage sampleFrame, int numberOfFrames) {
int colorComponents = sampleFrame.getColorModel().getNumColorComponents();
int bitsPerPixel = sampleFrame.getColorModel().getPixelSize();
int bitsAllocated = (bitsPerPixel / colorComponents);
int samplesPerPixel = colorComponents;
// DICOM对象,它将保存我们的帧
DicomObject dicom = new BasicDicomObject();
// 将患者相关信息添加到DICOM数据集
dicom.putString(Tag.PatientName, VR.PN, "dxy");
dicom