当前位置: 首页>>代码示例>>Java>>正文


Java DicomObject.getInt方法代码示例

本文整理汇总了Java中org.dcm4che2.data.DicomObject.getInt方法的典型用法代码示例。如果您正苦于以下问题:Java DicomObject.getInt方法的具体用法?Java DicomObject.getInt怎么用?Java DicomObject.getInt使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.dcm4che2.data.DicomObject的用法示例。


在下文中一共展示了DicomObject.getInt方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: maybeGetProxyRawImage

import org.dcm4che2.data.DicomObject; //导入方法依赖的package包/类
protected RawImageImpl maybeGetProxyRawImage() {
    DicomObject imgMetadata = getDicomImageMetaData();
    
    String transferSyntaxUID = imgMetadata.getString(Tag.TransferSyntaxUID);
    //logger.debug(getImageKey());
    //logger.debug("transferSyntaxUID : " + transferSyntaxUID);
    
    //jpeg or rle compressed
    if (transferSyntaxUID != null && 
            (transferSyntaxUID.startsWith("1.2.840.10008.1.2.4") ||
             transferSyntaxUID.startsWith("1.2.840.10008.1.2.5")))
        return null;
    
    int pixelType = getPixelType(imgMetadata);
    if (pixelType == RawImage.PIXEL_TYPE_NOT_SUPPORTED)
        return null;

    int pixelFormat = getPixelFormat(imgMetadata);
    if (pixelFormat == RawImage.PIXEL_FORMAT_NOT_SUPPORTED)
        return null;

    int width = imgMetadata.getInt(Tag.Columns);
    int height = imgMetadata.getInt(Tag.Rows);
    
    return new RawImageImpl(width, height, pixelFormat, pixelType, null);
}
 
开发者ID:Sofd,项目名称:viskit,代码行数:27,代码来源:ViskitDicomImageBase.java

示例2: run

import org.dcm4che2.data.DicomObject; //导入方法依赖的package包/类
@Override
public Double run(DicomObject dobj) {
    try {
        return (double)dobj.getInt(Tag.BitsStored) / 8.0 * dobj.getInt(Tag.Columns) * dobj.getInt(Tag.Rows);
        //TODO: account for frame count
    } catch (Exception ex) {
        logger.error("couldn't determine size of DICOM object " + dobj + ": " + ex.getMessage(), ex);
        return 1e6;
    }
}
 
开发者ID:Sofd,项目名称:viskit,代码行数:11,代码来源:Config.java

示例3: getFilledShortBuffer

import org.dcm4che2.data.DicomObject; //导入方法依赖的package包/类
public static ShortBuffer getFilledShortBuffer(ArrayList<DicomObject> dicomList, boolean rescaling) {
    if (dicomList.isEmpty())
        return null;

    // dicom object with reference values
    DicomObject refDicom = dicomList.get(0);

    int[] dim = new int[3];
    dim[0] = refDicom.getInt(Tag.Columns);
    dim[1] = refDicom.getInt(Tag.Rows);
    dim[2] = dicomList.size();
    
    ShortBuffer dataBuf = NioBufferUtil.newShortBuffer(dim[0] * dim[1] * dim[2]);

    for (DicomObject dicomObject : dicomList)
    {
        
        short[] pixData = dicomObject.getShorts(Tag.PixelData);
        
        if ( rescaling ) {
            float rescaleIntercept = dicomObject.getFloat(Tag.RescaleIntercept);
            float rescaleSlope = dicomObject.getFloat(Tag.RescaleSlope);
            
            if ( rescaleSlope != 0 || rescaleIntercept != 0)
            {
                /*System.out.println("intercept : " + rescaleIntercept);
                System.out.println("slope : " + rescaleSlope);*/
                
                for ( int i = 0; i < pixData.length; ++i )
                    pixData[i] = (short)(pixData[i]*rescaleSlope + rescaleIntercept); 
            }
        }
        
        dataBuf.put(pixData);
    }

    dataBuf.rewind();

    return dataBuf;
}
 
开发者ID:Sofd,项目名称:viskit,代码行数:41,代码来源:DicomUtil.java

示例4: recodeImages

import org.dcm4che2.data.DicomObject; //导入方法依赖的package包/类
/**
 * Recodes the images from the source transfer syntax, as read from the src
 * file, to the specified destination syntax.
 */
public void recodeImages(File src, File dest) throws IOException {
    ImageReader reader = new DicomImageReaderSpi().createReaderInstance();
    ImageWriter writer = new DicomImageWriterSpi().createWriterInstance();
    FileImageInputStream input = new FileImageInputStream(src);
    reader.setInput(input);
    if (dest.exists()) {
        dest.delete();
    }
    FileImageOutputStream output = new FileImageOutputStream(dest);
    writer.setOutput(output);
    DicomStreamMetaData streamMeta = (DicomStreamMetaData) reader.getStreamMetadata();
    DicomObject ds = streamMeta.getDicomObject();
    DicomStreamMetaData writeMeta = (DicomStreamMetaData) writer.getDefaultStreamMetadata(null);
    DicomObject newDs = new BasicDicomObject();
    ds.copyTo(newDs);
    writeMeta.setDicomObject(newDs);
    int frames = ds.getInt(Tag.NumberOfFrames, 1);
    LookupTable lut = prepareBitStrip(writeMeta, reader);
    newDs.putString(Tag.TransferSyntaxUID, VR.UI, destinationSyntax.uid());
    if (overwriteObject != null) {
        overwriteObject.copyTo(newDs);
    }
    writer.prepareWriteSequence(writeMeta);
    for (int i = 0; i < frames; i++) {
        WritableRaster r = (WritableRaster) reader.readRaster(i, null);
        ColorModel cm = ColorModelFactory.createColorModel(ds);
        BufferedImage bi = new BufferedImage(cm, r, false, null);
        if (lut != null) {
            lut.lookup(bi.getRaster(), bi.getRaster());
        }
        IIOImage iioimage = new IIOImage(bi, null, null);
        writer.writeToSequence(iioimage, null);
    }
    writer.endWriteSequence();
    output.close();
    input.close();
}
 
开发者ID:Sofd,项目名称:viskit,代码行数:42,代码来源:Dcm2Dcm.java

示例5: onDimseRSP

import org.dcm4che2.data.DicomObject; //导入方法依赖的package包/类
private void onDimseRSP(DicomObject cmd) {
    int status = cmd.getInt(Tag.Status);
    int msgId = cmd.getInt(Tag.MessageIDBeingRespondedTo);
    FileInfo info = files.get(msgId - 1);
    info.status = status;
    switch (status) {
    case 0:
        info.transferred = true;
        totalSize += info.length;
        ++filesSent;
        System.out.print('.');
        break;
    case 0xB000:
    case 0xB006:
    case 0xB007:
        info.transferred = true;
        totalSize += info.length;
        ++filesSent;
        promptErrRSP("WARNING: Received RSP with Status ", status, info,
                cmd);
        System.out.print('W');
        break;
    default:
        promptErrRSP("ERROR: Received RSP with Status ", status, info, cmd);
        System.out.print('F');
    }
}
 
开发者ID:NCIP,项目名称:national-biomedical-image-archive,代码行数:28,代码来源:DcmSnd.java

示例6: calculatePixelValueRange

import org.dcm4che2.data.DicomObject; //导入方法依赖的package包/类
@Override
protected float[] calculatePixelValueRange(ListModel model) {
    float[] minMaxRange = new float[2];
    if (model.getSize() > 0) {
        int min = Integer.MAX_VALUE;
        int max = Integer.MIN_VALUE;
        CachingDicomImageListViewModelElement element = (CachingDicomImageListViewModelElement) model
                .getElementAt(0);
        DicomObject metadata = element.getDicomImageMetaData();

        // DICOM object contains pixel value range for complete series
        if (metadata.contains(Tag.SmallestPixelValueInSeries) && metadata.contains(Tag.LargestPixelValueInSeries)) {
            min = metadata.getInt(Tag.SmallestPixelValueInSeries);
            max = metadata.getInt(Tag.LargestPixelValueInSeries);
            logger.debug("Pixel value range in series found: " + element);
        }
        // iterate through all model elements and find the smallest
        else {
            logger
                    .debug("Pixel value range in series not found, iterate through all model elements to calculate pixel value range for series");

            long startTime = System.currentTimeMillis();
            for (int i = 0; i < model.getSize(); i++) {
                // TODO if this model element is a frame calculation just
                // for the first frame
                element = (CachingDicomImageListViewModelElement) model.getElementAt(i);
                FloatRange range = element.getImage().getUsedPixelValuesRange();
                float currentMin = range.getMin();
                float currentMax = range.getMax();

                if (currentMin < min) {
                    min = (int) currentMin;
                }
                if (currentMax > max) {
                    max = (int) currentMax;
                }
            }
            logger.debug("[Min,Max] Range Calculation finished! Processing time: "
                    + (System.currentTimeMillis() - startTime) + " ms");
        }
        
        minMaxRange[0] = min;
        minMaxRange[1] = max;
    } else {
        logger.info("Model does not contain any DICOM files!");
    }
    return minMaxRange;
}
 
开发者ID:Sofd,项目名称:viskit,代码行数:49,代码来源:DicomModelFactory.java

示例7: windowMonochrome

import org.dcm4che2.data.DicomObject; //导入方法依赖的package包/类
private BufferedImage windowMonochrome(ImageListViewCell displayedCell, BufferedImage srcImg, float windowLocation, float windowWidth) {
    BufferedImage destImg = new BufferedImage(srcImg.getWidth(), srcImg.getHeight(), BufferedImage.TYPE_INT_RGB);

    boolean isSigned = false;
    int minValue = 0;
    {
        // hack: try to determine signedness and minValue from DICOM metadata if available --
        // the BufferedImage's metadata don't contain that information reliably.
        // Only works for some special cases
        ImageListViewModelElement elt = displayedCell.getDisplayedModelElement();
        if (elt instanceof DicomImageListViewModelElement) {
            DicomImageListViewModelElement delt = (DicomImageListViewModelElement) elt;
            DicomObject imgMetadata = delt.getDicomImageMetaData();
            int bitsAllocated = imgMetadata.getInt(Tag.BitsAllocated);
            isSigned = (1 == imgMetadata.getInt(Tag.PixelRepresentation));
            if (isSigned && (bitsAllocated > 0)) {
                minValue = -(1<<(bitsAllocated-1));
            }
        }
    }


    final int windowedImageGrayscalesCount = 256;  // for BufferedImage.TYPE_INT_RGB
    float scale = windowedImageGrayscalesCount/windowWidth;
    float offset = (windowWidth/2 - windowLocation)*scale;
    if (! (srcImg.getColorModel().getColorSpace().getType() == ColorSpace.TYPE_GRAY)) {
        throw new IllegalArgumentException("source image must be grayscales");
    }
    Raster srcRaster = srcImg.getRaster();
    if (srcRaster.getNumBands() != 1) {
        throw new IllegalArgumentException("grayscale source image must have one color band, but has " + srcRaster.getNumBands() + "??");
    }
    WritableRaster resultRaster = destImg.getRaster();
    for (int x = 0; x < srcImg.getWidth(); x++) {
        for (int y = 0; y < srcImg.getHeight(); y++) {
            int srcGrayValue = srcRaster.getSample(x, y, 0);
            if (isSigned) {
                srcGrayValue = (int)(short)srcGrayValue;  // will only work for 16-bit signed...
            }
            float destGrayValue = scale * srcGrayValue + offset;
            // clamp
            if (destGrayValue < 0) {
                destGrayValue = 0;
            } else if (destGrayValue >= windowedImageGrayscalesCount) {
                destGrayValue = windowedImageGrayscalesCount - 1;
            }
            resultRaster.setSample(x, y, 0, destGrayValue);
            resultRaster.setSample(x, y, 1, destGrayValue);
            resultRaster.setSample(x, y, 2, destGrayValue);
        }
    }
    return destImg;
}
 
开发者ID:Sofd,项目名称:viskit,代码行数:54,代码来源:J2DImageListViewBackend.java

示例8: getPixelType

import org.dcm4che2.data.DicomObject; //导入方法依赖的package包/类
public static int getPixelType(DicomObject dicomObject) {
    int bitsAllocated = dicomObject.getInt(Tag.BitsAllocated);
    if (bitsAllocated <= 0) {
        return RawImage.PIXEL_TYPE_NOT_SUPPORTED;
    }

    int bitsStored = dicomObject.getInt(Tag.BitsStored);
    if (bitsStored <= 0) {
        return RawImage.PIXEL_TYPE_NOT_SUPPORTED;
    }
    boolean isSigned = (1 == dicomObject.getInt(Tag.PixelRepresentation));
    // TODO: return RawImage.PIXEL_TYPE_NOT_SUPPORTED; if compressed
    // TODO: support for RGB (at least don't misinterpret it as luminance)
    // TODO: account for endianness (Tag.HighBit)
    int pixelType;
    // TODO: maybe use static multidimensional tables instead of nested switch statements

    switch (bitsAllocated) {
        case 8:
            if (bitsStored == 8 && !isSigned)
                return RawImage.PIXEL_TYPE_UNSIGNED_BYTE;
            
            return RawImage.PIXEL_TYPE_NOT_SUPPORTED;
        case 16:
            switch (bitsStored) {
                case 12:
                    pixelType = (isSigned ? RawImage.PIXEL_TYPE_SIGNED_12BIT : RawImage.PIXEL_TYPE_UNSIGNED_12BIT);
                    break;
                case 16:
                    pixelType = (isSigned ? RawImage.PIXEL_TYPE_SIGNED_16BIT : RawImage.PIXEL_TYPE_UNSIGNED_16BIT);
                    break;
                default:
                    return RawImage.PIXEL_TYPE_NOT_SUPPORTED;
            }
            break;
        default:
            return RawImage.PIXEL_TYPE_NOT_SUPPORTED;
    }

    return pixelType;
}
 
开发者ID:Sofd,项目名称:viskit,代码行数:42,代码来源:ViskitDicomImageBase.java

示例9: isBufferedImageSigned

import org.dcm4che2.data.DicomObject; //导入方法依赖的package包/类
@Override
public boolean isBufferedImageSigned() {
    DicomObject metadata = getDicomImageMetaData();
    return (1 == metadata.getInt(Tag.PixelRepresentation));
}
 
开发者ID:Sofd,项目名称:viskit,代码行数:6,代码来源:ViskitDicomImageBase.java

示例10: paintGrayscaleInto

import org.dcm4che2.data.DicomObject; //导入方法依赖的package包/类
public void paintGrayscaleInto(DicomObject image, int scaleHeight) {
    int bitsAllocated = image.getInt(Tag.BitsAllocated);
    if (bitsAllocated <= 0) {
        throw new IllegalStateException("unsupported image");
    }
    int bitsStored = image.getInt(Tag.BitsStored);
    if (bitsStored <= 0) {
        throw new IllegalStateException("unsupported image");
    }
    boolean isSigned = (1 == image.getInt(Tag.PixelRepresentation));
    if (isSigned) {
        throw new IllegalStateException("unsupported image");
    }
    // TODO: return null if compressed
    // TODO: support for RGB (at least don't misinterpret it as luminance)
    // TODO: account for endianness (Tag.HighBit)
    // TODO: maybe use static multidimensional tables instead of nested switch statements
    switch (bitsAllocated) {
        case 8:
            throw new IllegalStateException("unsupported image");
        case 16:
            switch (bitsStored) {
                case 12:
                    //=> 12-bit unsigned
                    break;
                case 16:
                    throw new IllegalStateException("unsupported image");
                    //pixelType = (isSigned ? RawImage.PIXEL_TYPE_SIGNED_16BIT : RawImage.PIXEL_TYPE_UNSIGNED_16BIT);
                    //break;
                default:
                    throw new IllegalStateException("unsupported image");
            }
            break;
        default:
            throw new IllegalStateException("unsupported image");
    }
    int width = image.getInt(Tag.Columns);
    int height = image.getInt(Tag.Rows);

    short[] pixels = image.getShorts(Tag.PixelData);
    for (short gray=0; gray<4096; gray++) {
        int x = gray % width;
        int row = gray / width;
        int ystart = row * 3 * scaleHeight;
        short gray8 = (short)(gray / 16 * 16);
        for (int dy=0; dy<scaleHeight; dy++) {
            int grayy = ystart + dy;
            int gray8y = ystart + scaleHeight + dy;
            pixels[grayy*width + x] = gray;
            pixels[gray8y*width + x] = gray8;
        }
    }
    image.putShorts(Tag.PixelData, image.vrOf(Tag.PixelData), pixels);
}
 
开发者ID:Sofd,项目名称:viskit,代码行数:55,代码来源:PaintGrayscaleIntoDcmImageApp.java

示例11: paintGraysInto

import org.dcm4che2.data.DicomObject; //导入方法依赖的package包/类
public void paintGraysInto(DicomObject image, int grayNW, int grayNE, int graySE, int graySW) {
    int bitsAllocated = image.getInt(Tag.BitsAllocated);
    if (bitsAllocated <= 0) {
        throw new IllegalStateException("unsupported image");
    }
    int bitsStored = image.getInt(Tag.BitsStored);
    if (bitsStored <= 0) {
        throw new IllegalStateException("unsupported image");
    }
    boolean isSigned = (1 == image.getInt(Tag.PixelRepresentation));
    if (isSigned) {
        throw new IllegalStateException("unsupported image");
    }
    // TODO: return null if compressed
    // TODO: support for RGB (at least don't misinterpret it as luminance)
    // TODO: account for endianness (Tag.HighBit)
    // TODO: maybe use static multidimensional tables instead of nested switch statements
    switch (bitsAllocated) {
        case 8:
            throw new IllegalStateException("unsupported image");
        case 16:
            switch (bitsStored) {
                case 12:
                    //=> 12-bit unsigned
                    break;
                case 16:
                    throw new IllegalStateException("unsupported image");
                    //pixelType = (isSigned ? RawImage.PIXEL_TYPE_SIGNED_16BIT : RawImage.PIXEL_TYPE_UNSIGNED_16BIT);
                    //break;
                default:
                    throw new IllegalStateException("unsupported image");
            }
            break;
        default:
            throw new IllegalStateException("unsupported image");
    }
    int width = image.getInt(Tag.Columns);
    int height = image.getInt(Tag.Rows);

    short[] pixels = image.getShorts(Tag.PixelData);
    for (int y=0; y<height; y++) {
        for (int x=0; x<width; x++) {
            float grayTop = (float) grayNW * (1.0f - (float) x/width) + (float) grayNE * x/width;
            float grayBottom = (float) graySW * (1.0f - (float) x/width) + (float) graySE * x/width;
            float gray = (float) grayTop * (1.0f - (float) y/height) + (float) grayBottom * y/height;
            pixels[y*width + x] = (short)gray;
        }
    }
    image.putShorts(Tag.PixelData, image.vrOf(Tag.PixelData), pixels);
}
 
开发者ID:Sofd,项目名称:viskit,代码行数:51,代码来源:PaintGrayDcmImageApp.java

示例12: getPixelFormat

import org.dcm4che2.data.DicomObject; //导入方法依赖的package包/类
public static int getPixelFormat(DicomObject dicomObject) {
    int bitsAllocated = dicomObject.getInt(Tag.BitsAllocated);

    int pixelFormat = (bitsAllocated == 16 ? RawImage.PIXEL_FORMAT_LUMINANCE : RawImage.PIXEL_FORMAT_NOT_SUPPORTED);

    return pixelFormat;
}
 
开发者ID:Sofd,项目名称:viskit,代码行数:8,代码来源:ViskitDicomImageBase.java


注:本文中的org.dcm4che2.data.DicomObject.getInt方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。