public boolean matches(String aeTitle, ImageDescriptor imageDescriptor) { return pmis.contains(imageDescriptor.getPhotometricInterpretation()) && matchBitStored(imageDescriptor.getBitsStored()) && matchPixelRepresentation(imageDescriptor.getPixelRepresentation()) && isEmptyOrContains(this.aeTitles, aeTitle) && isEmptyOrContains(this.sopClasses, imageDescriptor.getSopClassUID()) && isEmptyOrContains(this.bodyPartExamined, imageDescriptor.getBodyPartExamined()); }
private PlanarImage getNativeImage(ImageReadParam param) throws IOException { StreamSegment seg = StreamSegment.getStreamSegment(iis, param); ImageDescriptor desc = seg.getImageDescriptor(); int dcmFlags = (canEncodeSigned && desc.isSigned()) ? Imgcodecs.DICOM_IMREAD_SIGNED : Imgcodecs.DICOM_IMREAD_UNSIGNED; // Force JPEG Baseline (1.2.840.10008.1.2.4.50) to YBR_FULL_422 color model when RGB (error made by some // constructors). RGB color model doesn't make sense for lossy jpeg. // http://dicom.nema.org/medical/dicom/current/output/chtml/part05/sect_8.2.html#sect_8.2.1 PhotometricInterpretation pmi = desc.getPhotometricInterpretation(); if (pmi.name().startsWith("YBR") || ("RGB".equalsIgnoreCase(pmi.name()) && params.getJpegMarker() == 0xffc0)) { dcmFlags |= Imgcodecs.DICOM_IMREAD_YBR; } if (seg instanceof FileStreamSegment) { MatOfDouble positions = new MatOfDouble(ExtendSegmentedInputImageStream.getDoubleArray(seg.getSegPosition())); MatOfDouble lengths = new MatOfDouble(ExtendSegmentedInputImageStream.getDoubleArray(seg.getSegLength())); return ImageCV.toImageCV(Imgcodecs.dicomJpgFileRead(((FileStreamSegment) seg).getFilePath(), positions, lengths, dcmFlags, Imgcodecs.IMREAD_UNCHANGED)); } else if (seg instanceof MemoryStreamSegment) { ByteBuffer b = ((MemoryStreamSegment) seg).getCache(); Mat buf = new Mat(1, b.limit(), CvType.CV_8UC1); buf.put(0, 0, b.array()); return ImageCV.toImageCV(Imgcodecs.dicomJpgMatRead(buf, dcmFlags, Imgcodecs.IMREAD_UNCHANGED)); } return null; }
private void adjustDataset() { if (imageDescriptor.getSamples() == 3) { PhotometricInterpretation pmi = imageDescriptor.getPhotometricInterpretation(); int planarConfiguration = imageDescriptor.getPlanarConfiguration(); if (decompressor != null) { pmi = decompressorParam.pmiAfterDecompression(pmi); planarConfiguration = srcTransferSyntaxType.getPlanarConfiguration(); } if (compressor != null) { pmi = pmi.compress(destTransferSyntax); planarConfiguration = destTransferSyntaxType.getPlanarConfiguration(); } dataset.setString(Tag.PhotometricInterpretation, VR.CS, pmi.toString()); dataset.setInt(Tag.PlanarConfiguration, VR.US, planarConfiguration); } }
PhotometricInterpretation pi = desc.getPhotometricInterpretation();