Beispiel #1
0
 private void applyOverlay(
     int gg0000,
     WritableRaster raster,
     int frameIndex,
     ImageReadParam param,
     int outBits,
     byte[] ovlyData) {
   Attributes ovlyAttrs = metadata.getAttributes();
   int grayscaleValue = 0xffff;
   if (param instanceof DicomImageReadParam) {
     DicomImageReadParam dParam = (DicomImageReadParam) param;
     Attributes psAttrs = dParam.getPresentationState();
     if (psAttrs != null) {
       if (psAttrs.containsValue(Tag.OverlayData | gg0000)) ovlyAttrs = psAttrs;
       grayscaleValue = Overlays.getRecommendedDisplayGrayscaleValue(psAttrs, gg0000);
     } else grayscaleValue = dParam.getOverlayGrayscaleValue();
   }
   Overlays.applyOverlay(
       ovlyData != null ? 0 : frameIndex,
       raster,
       ovlyAttrs,
       gg0000,
       grayscaleValue >>> (16 - outBits),
       ovlyData);
 }
Beispiel #2
0
 private int[] getActiveOverlayGroupOffsets(ImageReadParam param) {
   if (param instanceof DicomImageReadParam) {
     DicomImageReadParam dParam = (DicomImageReadParam) param;
     Attributes psAttrs = dParam.getPresentationState();
     if (psAttrs != null) return Overlays.getActiveOverlayGroupOffsets(psAttrs);
     else
       return Overlays.getActiveOverlayGroupOffsets(
           metadata.getAttributes(), dParam.getOverlayActivationMask());
   }
   return Overlays.getActiveOverlayGroupOffsets(metadata.getAttributes(), 0xffff);
 }
Beispiel #3
0
  private byte[] extractOverlay(int gg0000, WritableRaster raster) {
    Attributes attrs = metadata.getAttributes();

    if (attrs.getInt(Tag.OverlayBitsAllocated | gg0000, 1) == 1) return null;

    int ovlyRows = attrs.getInt(Tag.OverlayRows | gg0000, 0);
    int ovlyColumns = attrs.getInt(Tag.OverlayColumns | gg0000, 0);
    int bitPosition = attrs.getInt(Tag.OverlayBitPosition | gg0000, 0);

    int mask = 1 << bitPosition;
    int length = ovlyRows * ovlyColumns;

    byte[] ovlyData = new byte[(((length + 7) >>> 3) + 1) & (~1)];
    Overlays.extractFromPixeldata(raster, mask, ovlyData, 0, length);
    return ovlyData;
  }