关闭。这个问题需要细节或清晰。它目前不接受答案。
**想改进这个问题吗?**通过编辑这个帖子来添加细节并澄清问题。
8天前关门了。
改进这个问题
Path srcFilePath = Paths.get("D:\\test.raw");
try (SeekableByteChannel channel = Files.newByteChannel(srcFilePath); DicomOutputStream dos = new DicomOutputStream(new File("D:\\test.dcm"))) {
int samples = 1;
fileMetadata.setInt(Tag.SamplesPerPixel, VR.US, new int[]{samples});
if (samples == 3) {
fileMetadata.setString(Tag.PhotometricInterpretation, VR.CS, "YBR_FULL_422");
fileMetadata.setInt(Tag.PlanarConfiguration, VR.US, new int[]{0});
} else {
fileMetadata.setString(Tag.PhotometricInterpretation, VR.CS, "MONOCHROME");
}
fileMetadata.setInt(Tag.Rows, VR.US, new int[]{2560});
fileMetadata.setInt(Tag.Columns, VR.US, new int[]{3072});
int bitsStored = 8;
fileMetadata.setInt(Tag.BitsAllocated, VR.US, new int[]{bitsStored > 8 ? 16 : 8});
fileMetadata.setInt(Tag.BitsStored, VR.US, new int[]{bitsStored});
fileMetadata.setInt(Tag.HighBit, VR.US, new int[]{bitsStored - 1});
fileMetadata.setInt(Tag.PixelRepresentation, VR.US, new int[]{0});
fileMetadata.setString(Tag.LossyImageCompression, VR.CS, "01");
dos.writeDataset(fileMetadata.createFileMetaInformation("1.2.840.10008.1.2.4.50"), fileMetadata);
dos.writeHeader(Tag.PixelData, VR.OB, -1);
dos.writeHeader(Tag.Item, null, 0);
copyPixelData(channel, 0, dos);
dos.writeHeader(Tag.SequenceDelimitationItem, null, 0);
}
我使用dicom查看器无法打开dcm文件,但我没有任何提示。所以我无法修复原始文件的错误
暂无答案!
目前还没有任何答案,快来回答吧!