Search in sources :

Example 1 with ImageReaderParam

use of org.dcm4che3.imageio.codec.ImageReaderFactory.ImageReaderParam in project dcm4che by dcm4che.

the class LdapImageReaderConfiguration method merge.

private void merge(ConfigurationChanges diffs, ImageReaderFactory prev, ImageReaderFactory factory, String imageReadersDN) throws NamingException {
    for (Entry<String, ImageReaderParam> entry : prev.getEntries()) {
        String tsuid = entry.getKey();
        if (factory.get(tsuid) == null) {
            String dn = dnOf(tsuid, imageReadersDN);
            config.destroySubcontext(dn);
            ConfigurationChanges.addModifiedObject(diffs, dn, ConfigurationChanges.ChangeType.D);
        }
    }
    for (Entry<String, ImageReaderParam> entry : factory.getEntries()) {
        String tsuid = entry.getKey();
        String dn = dnOf(tsuid, imageReadersDN);
        ImageReaderParam prevParam = prev.get(tsuid);
        if (prevParam == null) {
            ConfigurationChanges.ModifiedObject ldapObj = ConfigurationChanges.addModifiedObject(diffs, dn, ConfigurationChanges.ChangeType.C);
            config.createSubcontext(dn, storeTo(ConfigurationChanges.nullifyIfNotVerbose(diffs, ldapObj), tsuid, entry.getValue(), new BasicAttributes(true)));
        } else {
            ConfigurationChanges.ModifiedObject ldapObj = ConfigurationChanges.addModifiedObject(diffs, dn, ConfigurationChanges.ChangeType.U);
            config.modifyAttributes(dn, storeDiffs(ldapObj, prevParam, entry.getValue(), new ArrayList<ModificationItem>()));
            ConfigurationChanges.removeLastIfEmpty(diffs, ldapObj);
        }
    }
}
Also used : ConfigurationChanges(org.dcm4che3.conf.api.ConfigurationChanges) BasicAttributes(javax.naming.directory.BasicAttributes) ImageReaderParam(org.dcm4che3.imageio.codec.ImageReaderFactory.ImageReaderParam) ArrayList(java.util.ArrayList)

Example 2 with ImageReaderParam

use of org.dcm4che3.imageio.codec.ImageReaderFactory.ImageReaderParam in project dcm4che by dcm4che.

the class LdapImageReaderConfiguration method loadChilds.

@Override
protected void loadChilds(Device device, String deviceDN) throws NamingException, ConfigurationException {
    String imageReadersDN = CN_IMAGE_READER_FACTORY + deviceDN;
    try {
        config.getAttributes(imageReadersDN);
    } catch (NameNotFoundException e) {
        return;
    }
    ImageReaderFactory factory = new ImageReaderFactory();
    NamingEnumeration<SearchResult> ne = config.search(imageReadersDN, "(objectclass=dcmImageReader)");
    try {
        while (ne.hasMore()) {
            SearchResult sr = ne.next();
            Attributes attrs = sr.getAttributes();
            factory.put(LdapUtils.stringValue(attrs.get("dicomTransferSyntax"), null), new ImageReaderParam(LdapUtils.stringValue(attrs.get("dcmIIOFormatName"), null), LdapUtils.stringValue(attrs.get("dcmJavaClassName"), null), LdapUtils.stringValue(attrs.get("dcmPatchJPEGLS"), null), LdapUtils.stringArray(attrs.get("dcmImageReadParam"))));
        }
    } finally {
        LdapUtils.safeClose(ne);
    }
    device.addDeviceExtension(new ImageReaderExtension(factory));
}
Also used : ImageReaderParam(org.dcm4che3.imageio.codec.ImageReaderFactory.ImageReaderParam) NameNotFoundException(javax.naming.NameNotFoundException) ImageReaderFactory(org.dcm4che3.imageio.codec.ImageReaderFactory) BasicAttributes(javax.naming.directory.BasicAttributes) Attributes(javax.naming.directory.Attributes) SearchResult(javax.naming.directory.SearchResult) ImageReaderExtension(org.dcm4che3.net.imageio.ImageReaderExtension)

Example 3 with ImageReaderParam

use of org.dcm4che3.imageio.codec.ImageReaderFactory.ImageReaderParam in project dcm4che by dcm4che.

the class DicomImageReader method setMetadata.

private void setMetadata(DicomMetaData metadata) {
    this.metadata = metadata;
    Attributes ds = metadata.getAttributes();
    if (pixelDataLength != 0) {
        frames = ds.getInt(Tag.NumberOfFrames, 1);
        width = ds.getInt(Tag.Columns, 0);
        height = ds.getInt(Tag.Rows, 0);
        samples = ds.getInt(Tag.SamplesPerPixel, 1);
        banded = samples > 1 && ds.getInt(Tag.PlanarConfiguration, 0) != 0;
        bitsAllocated = ds.getInt(Tag.BitsAllocated, 8);
        bitsStored = ds.getInt(Tag.BitsStored, bitsAllocated);
        dataType = bitsAllocated <= 8 ? DataBuffer.TYPE_BYTE : DataBuffer.TYPE_USHORT;
        pmi = PhotometricInterpretation.fromString(ds.getString(Tag.PhotometricInterpretation, "MONOCHROME2"));
        if (pixelDataLength != -1) {
            pmiAfterDecompression = pmi;
            this.frameLength = pmi.frameLength(width, height, samples, bitsAllocated);
        } else {
            Attributes fmi = metadata.getFileMetaInformation();
            if (fmi == null)
                throw new IllegalArgumentException("Missing File Meta Information for Data Set with compressed Pixel Data");
            String tsuid = fmi.getString(Tag.TransferSyntaxUID);
            ImageReaderParam param = ImageReaderFactory.getImageReaderParam(tsuid);
            if (param == null)
                throw new UnsupportedOperationException("Unsupported Transfer Syntax: " + tsuid);
            TransferSyntaxType tsType = TransferSyntaxType.forUID(tsuid);
            if (tsType.adjustBitsStoredTo12(ds)) {
                LOG.info("Adjust invalid Bits Stored: {} of {} to 12", bitsStored, tsType);
                bitsStored = 12;
            }
            pmiAfterDecompression = pmi.isYBR() && TransferSyntaxType.isYBRCompression(tsuid) ? PhotometricInterpretation.RGB : pmi;
            this.rle = tsuid.equals(UID.RLELossless);
            this.decompressor = ImageReaderFactory.getImageReader(param);
            LOG.debug("Decompressor: {}", decompressor.getClass().getName());
            this.patchJpegLS = param.patchJPEGLS;
        }
    }
}
Also used : TransferSyntaxType(org.dcm4che3.imageio.codec.TransferSyntaxType) ImageReaderParam(org.dcm4che3.imageio.codec.ImageReaderFactory.ImageReaderParam) Attributes(org.dcm4che3.data.Attributes)

Aggregations

ImageReaderParam (org.dcm4che3.imageio.codec.ImageReaderFactory.ImageReaderParam)3 BasicAttributes (javax.naming.directory.BasicAttributes)2 ArrayList (java.util.ArrayList)1 NameNotFoundException (javax.naming.NameNotFoundException)1 Attributes (javax.naming.directory.Attributes)1 SearchResult (javax.naming.directory.SearchResult)1 ConfigurationChanges (org.dcm4che3.conf.api.ConfigurationChanges)1 Attributes (org.dcm4che3.data.Attributes)1 ImageReaderFactory (org.dcm4che3.imageio.codec.ImageReaderFactory)1 TransferSyntaxType (org.dcm4che3.imageio.codec.TransferSyntaxType)1 ImageReaderExtension (org.dcm4che3.net.imageio.ImageReaderExtension)1