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


Java DicomObject.getShorts方法代码示例

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


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

示例1: getRangeFromDicomObjects

import org.dcm4che2.data.DicomObject; //导入方法依赖的package包/类
public static ShortRange getRangeFromDicomObjects(ArrayList<DicomObject> dicomList) {
    short min = Short.MAX_VALUE;
    short max = Short.MIN_VALUE;

    for (DicomObject dicomObject : dicomList) {
        short[] buffer = dicomObject.getShorts(Tag.PixelData);
        
        for (short value : buffer) {
            
            if (value < min)
                min = value;

            if (value > max)
                max = value;
        }
    }

    return new ShortRange(min, max);
}
 
开发者ID:Sofd,项目名称:viskit,代码行数:20,代码来源:ImageUtil.java

示例2: 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

示例3: 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

示例4: 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


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