protected int getImageSize(E img, TagW tag1, TagW tag2) { Integer size = (Integer) img.getTagValue(tag1); if (size == null) { size = (Integer) img.getTagValue(tag2); } return (size == null) ? ImageFiler.TILESIZE : size; }
@Override public Object getSourceTagValue(TagW tagW) { E imageElement = getSourceImage(); if (imageElement != null) { return imageElement.getTagValue(tagW); } return null; }
public static void writePresentation(ImageElement img, Writer writer) { GraphicModel model = (GraphicModel) img.getTagValue(TagW.PresentationModel); writePresentation(model, writer); }
private void updateTags(ImageElement image) { this.image.setTag(TagW.ImageWidth, image.getTagValue(TagW.ImageWidth)); this.image.setTag(TagW.ImageHeight, image.getTagValue(TagW.ImageHeight)); }
public static void writePresentation(ImageElement img, File destinationFile) { GraphicModel model = (GraphicModel) img.getTagValue(TagW.PresentationModel); if (model != null && !model.getModels().isEmpty()) { File gpxFile = new File(destinationFile.getParent(), destinationFile.getName() + ".xml"); //$NON-NLS-1$ try { JAXBContext jaxbContext = JAXBContext.newInstance(model.getClass()); Marshaller jaxbMarshaller = jaxbContext.createMarshaller(); // output pretty printed jaxbMarshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true); // jaxbMarshaller.marshal(model, System.out); jaxbMarshaller.marshal(model, gpxFile); } catch (Exception e) { LOGGER.error("Cannot save xml: ", e); //$NON-NLS-1$ } } }
static double getThickness(ImageElement firstDcm, ImageElement lastDcm) { double[] p1 = (double[]) firstDcm.getTagValue(TagW.SlicePosition); double[] p2 = (double[]) lastDcm.getTagValue(TagW.SlicePosition); if (p1 != null && p2 != null) { double diff = Math.abs((p2[0] + p2[1] + p2[2]) - (p1[0] + p1[1] + p1[2])); Double t1 = TagD.getTagValue(firstDcm, Tag.SliceThickness, Double.class); if (t1 != null) { diff += t1 / 2; } t1 = TagD.getTagValue(lastDcm, Tag.SliceThickness, Double.class); if (t1 != null) { diff += t1 / 2; } return diff; } return 1.0; }
/** * Calculate the ratio between the image and the given resolution * * @param imgInfo * @param resolution * @return */ public static Double calculateRatio(AcquireImageInfo imgInfo, Resolution resolution) { try { Objects.requireNonNull(imgInfo); Objects.requireNonNull(resolution); double expectedImageSize = resolution.getMaxSize(); ImageElement imgElt = imgInfo.getImage(); Integer width = (Integer) imgElt.getTagValue(TagW.ImageWidth); Integer height = (Integer) imgElt.getTagValue(TagW.ImageHeight); double currentImageSize = Math.max(width, height); return BigDecimal.valueOf(expectedImageSize / currentImageSize).setScale(5, RoundingMode.HALF_UP) .doubleValue(); } catch (NullPointerException e) { LOGGER.warn("An error occurs when calculate ratio for : " + imgInfo + ", resolution=> " + resolution, e); //$NON-NLS-1$ //$NON-NLS-2$ return null; } } }
private static void addImageToDataMapping(AcquireImageInfo imageInfo) { Objects.requireNonNull(imageInfo); imagesInfoByURI.put(imageInfo.getImage().getMediaURI(), imageInfo); imagesInfoByUID.put((String) imageInfo.getImage().getTagValue(TagD.getUID(Level.INSTANCE)), imageInfo); }
private static void removeImageFromDataMapping(AcquireImageInfo imageInfo) { imagesInfoByURI.remove(imageInfo.getImage().getMediaURI()); imagesInfoByUID.remove(imageInfo.getImage().getTagValue(TagD.getUID(Level.INSTANCE))); }
private static List<ReferencedSeries> buildReferences(ImageElement img) { String seriesUUID = (String) img.getTagValue(TagW.get("SeriesInstanceUID")); //$NON-NLS-1$ if (seriesUUID == null) { seriesUUID = java.util.UUID.randomUUID().toString(); img.setTag(TagW.get("SeriesInstanceUID"), seriesUUID); //$NON-NLS-1$ } String uid = (String) img.getTagValue(TagW.get("SOPInstanceUID")); //$NON-NLS-1$ if (uid == null) { uid = java.util.UUID.randomUUID().toString(); img.setTag(TagW.get("SOPInstanceUID"), uid); //$NON-NLS-1$ } List<Integer> frameList = new ArrayList<>(1); int frames = img.getMediaReader().getMediaElementNumber(); if (frames > 1 && img.getKey() instanceof Integer) { frameList.add((Integer) img.getKey()); } return Arrays.asList(new ReferencedSeries(seriesUUID, Arrays.asList(new ReferencedImage(uid, frameList)))); } }
boolean overlays = LangUtil.getNULLtoFalse((Boolean) image.getTagValue(TagW.HasOverlay));
String filePath = (String) image.getTagValue(TagW.OverlayBurninDataPath); if (filePath != null) { FileInputStream fileIn = null;
setParam(P_SHAPE, noMedia ? null : img.getTagValue(TagW.ShutterFinalShape)); setParam(P_PS_VALUE, noMedia ? null : img.getTagValue(TagW.ShutterPSValue)); setParam(P_RGB_COLOR, noMedia ? null : img.getTagValue(TagW.ShutterRGBColor)); setParam(P_PR_ELEMENT, null); setParam(P_IMAGE_ELEMENT, noMedia ? null : img);
private Object getTagValue(TagW tag, MediaSeriesGroup patient, MediaSeriesGroup study, Series series, ImageElement image) { if (image.containTagKey(tag)) { return image.getTagValue(tag); } if (series.containTagKey(tag)) { return series.getTagValue(tag); } if (study != null && study.containTagKey(tag)) { return study.getTagValue(tag); } if (patient != null && patient.containTagKey(tag)) { return patient.getTagValue(tag); } return null; }
String sopInstanceUID = Objects.requireNonNull((String) imageElement.getTagValue(TagD.getUID(Level.INSTANCE))); GraphicModel grModel = (GraphicModel) imageElement.getTagValue(TagW.PresentationModel); if (grModel != null && grModel.hasSerializableGraphics()) { Point2D offset = null;
String uuid = (String) imageElement.getTagValue(tagUid); if (uuid == null) { uuid = UIDUtils.createUID();
GraphicModel modelList = (GraphicModel) img.getTagValue(TagW.PresentationModel);
GraphicModel modelList = (GraphicModel) dicom.getTagValue(TagW.PresentationModel);