Beispiel #1
0
public class OverlayOperation extends AbstractOperation {
  private static final Logger LOGGER = LoggerFactory.getLogger(OverlayOperation.class);

  public static final String name = Messages.getString("OverlayOperation.title"); // $NON-NLS-1$

  public String getOperationName() {
    return name;
  }

  public RenderedImage getRenderedImage(RenderedImage source, ImageOperation imageOperation) {
    Boolean overlay = (Boolean) imageOperation.getActionValue(ActionW.IMAGE_OVERLAY.cmd());
    if (overlay == null) {
      result = source;
      LOGGER.warn("Cannot apply \"{}\" because a parameter is null", name); // $NON-NLS-1$
    } else if (overlay) {
      RenderedImage imgOverlay = null;
      ImageElement image = imageOperation.getImage();
      Integer row = (Integer) image.getTagValue(TagW.OverlayRows);
      if (row != null && row != 0 && image.getMediaReader() instanceof DicomMediaIO) {
        DicomMediaIO reader = (DicomMediaIO) image.getMediaReader();
        try {
          if (image.getKey() instanceof Integer) {
            int frame = (Integer) image.getKey();
            Integer height = (Integer) reader.getTagValue(TagW.Rows);
            Integer width = (Integer) reader.getTagValue(TagW.Columns);
            if (height != null && width != null) {
              imgOverlay =
                  PlanarImage.wrapRenderedImage(
                      OverlayUtils.getOverlays(
                          imageOperation.getImage(), reader, frame, width, height));
            }
          }
        } catch (IOException e) {
          e.printStackTrace();
        }
      }
      result =
          imgOverlay == null
              ? source
              : combineTwoImagesOperation.combineTwoImages(source, imgOverlay, 255);
    } else {
      result = source;
    }
    return result;
  }
}
Beispiel #2
0
  static {
    // Format associated to DICOM field:
    // $V => the value
    // $V:l$25$ => the value is limited to 25 characters followed by "..."
    // $V:f$#,##0.##$ => java pattern to display decimal number

    /*
     * See IHE BIR RAD TF-­‐2: 4.16.4.2.2.5.8
     */
    // Default profile of tag formats
    TagView[] disElements = DEFAULT_MODALITY_VIEW.getCornerInfo(CornerDisplay.TOP_LEFT).getInfos();
    disElements[0] = new TagView(TagD.get(Tag.PatientName));
    disElements[1] = new TagView(TagD.get(Tag.PatientBirthDate));
    disElements[2] =
        new TagView(Messages.getString("ModalityView.id"), TagD.get(Tag.PatientID)); // $NON-NLS-1$
    disElements[3] =
        new TagView(
            Messages.getString("ModalityView.sex"), TagD.get(Tag.PatientSex)); // $NON-NLS-1$
    disElements[4] = new TagView(TagD.get(Tag.PatientAge));

    disElements = DEFAULT_MODALITY_VIEW.getCornerInfo(CornerDisplay.TOP_RIGHT).getInfos();
    disElements[0] = new TagView(TagD.get(Tag.InstitutionName));
    disElements[1] =
        new TagView(
            Messages.getString("ModalityView.desc25"),
            TagD.get(Tag.StudyDescription)); // $NON-NLS-1$
    disElements[2] =
        new TagView(Messages.getString("ModalityView.study"), TagD.get(Tag.StudyID)); // $NON-NLS-1$
    disElements[3] =
        new TagView(
            Messages.getString("ModalityView.ac_nb"), TagD.get(Tag.AccessionNumber)); // $NON-NLS-1$
    // else content date, else Series date, else Study date
    disElements[4] =
        new TagView(
            Messages.getString("ModalityView.acq"), // $NON-NLS-1$
            TagD.getTagFromIDs(
                Tag.AcquisitionDate,
                Tag.ContentDate,
                Tag.DateOfSecondaryCapture,
                Tag.SeriesDate,
                Tag.StudyDate));
    // else content time, else Series time, else Study time
    disElements[5] =
        new TagView(
            Messages.getString("ModalityView.acq"), // $NON-NLS-1$
            TagD.getTagFromIDs(
                Tag.AcquisitionTime,
                Tag.ContentTime,
                Tag.TimeOfSecondaryCapture,
                Tag.SeriesTime,
                Tag.StudyTime));

    disElements = DEFAULT_MODALITY_VIEW.getCornerInfo(CornerDisplay.BOTTOM_RIGHT).getInfos();
    disElements[1] =
        new TagView(
            Messages.getString("ModalityView.series_nb"),
            TagD.get(Tag.SeriesNumber)); // $NON-NLS-1$
    disElements[2] =
        new TagView(
            Messages.getString("ModalityView.laterality"),
            TagD.getTagFromIDs(
                Tag.FrameLaterality, // $NON-NLS-1$
                Tag.ImageLaterality,
                Tag.Laterality));

    // TODO add sequence
    // derived from Contrast/Bolus Agent Sequence (0018,0012), if
    // present, else Contrast/Bolus Agent (0018,0010)
    // http://dicom.nema.org/medical/dicom/current/output/chtml/part03/sect_C.7.6.4b.html
    disElements[3] =
        new TagView(
            Messages.getString("ModalityView.desc25"),
            TagD.get(Tag.ContrastBolusAgent)); // $NON-NLS-1$
    disElements[4] =
        new TagView(
            Messages.getString("ModalityView.desc25"),
            TagD.get(Tag.SeriesDescription)); // $NON-NLS-1$
    disElements[5] =
        new TagView(
            Messages.getString("ModalityView.thick"), TagD.get(Tag.SliceThickness)); // $NON-NLS-1$
    disElements[6] =
        new TagView(
            Messages.getString("ModalityView.location"),
            TagD.get(Tag.SliceLocation)); // $NON-NLS-1$
    /*
     * Spacing Between Slices (0018,0088), if present, else a value derived from successive values of Image Position
     * (Patient) (0020,0032) perpendicular to the Image Orientation (Patient) (0020,0037)
     */
    MODALITY_VIEW_MAP.put(Modality.DEFAULT, DEFAULT_MODALITY_VIEW);
    readTagDisplayByModality();
  }