private DicomStreamMetaData copyMeta(DicomImageReader reader, String tsuid) throws IOException { DicomStreamMetaData oldMeta = (DicomStreamMetaData) reader.getStreamMetadata(); DicomStreamMetaData ret = new DicomStreamMetaData(); DicomObject ds = oldMeta.getDicomObject(); DicomObject newDs = new BasicDicomObject(); ds.copyTo(newDs); newDs.putString(Tag.TransferSyntaxUID, VR.UI, tsuid); ret.setDicomObject(newDs); return ret; }
private void testColorMultiFrame(String name, String objectName, String transferSyntax) throws IOException { DicomImageReader reader = createImageReader(objectName); DicomStreamMetaData copyMeta = copyMeta(reader, transferSyntax); int numberOfFrames = copyMeta.getDicomObject().getInt(Tag.NumberOfFrames); List<BufferedImage> bufferedImages = new ArrayList<BufferedImage>(); for (int frame = 1; frame <= numberOfFrames; frame++) { BufferedImage biNew = readRawBufferedImage(reader, frame); bufferedImages.add(biNew); } ImageInputStream inputStream = writeImageFrames(copyMeta, bufferedImages, name); DicomImageReader readerNew = createImageReader(inputStream); int frameNumber = 1; for (BufferedImage bufferedImage : bufferedImages) { BufferedImage biNew = readRawBufferedImage(readerNew, frameNumber++); ImageDiff diff = new ImageDiff(bufferedImage, biNew, "target/" + name, 0); assertTrue("Color Frame " + frameNumber + " is different", diff.getMaxDiff() == 0); } }