private static void buildAffineTransform(AffineTransform transform, OpManager dispOp, Rectangle2D modelArea, Point offset) { boolean flip = LangUtil.getNULLtoFalse((Boolean) dispOp.getParamValue(FlipOp.OP_NAME, FlipOp.P_FLIP)); Integer rotationAngle = (Integer) dispOp.getParamValue(RotationOp.OP_NAME, RotationOp.P_ROTATE); if (rotationAngle != null && rotationAngle > 0) { rotationAngle = (rotationAngle + 720) % 360; if (flip) { rotationAngle = 360 - rotationAngle; } transform.rotate(Math.toRadians(rotationAngle), modelArea.getWidth() / 2.0, modelArea.getHeight() / 2.0); } if (flip) { transform.scale(-1.0, 1.0); transform.translate(-modelArea.getWidth(), 0.0); } if (offset != null) { // TODO not consistent with image coordinates after crop transform.translate(-offset.getX(), -offset.getY()); } }
default boolean needProcessing() { for (ImageOpNode op : getOperations()) { if (op.getParam(Param.INPUT_IMG) == null || op.getParam(Param.OUTPUT_IMG) == null) { return true; } } return false; } }
@Override public void changeZoomInterpolation(Integer interpolation) { Integer val = (Integer) getDisplayOpManager().getParamValue(AffineTransformOp.OP_NAME, AffineTransformOp.P_INTERPOLATION); boolean update = !Objects.equals(val, interpolation); if (update) { getDisplayOpManager().setParamValue(AffineTransformOp.OP_NAME, AffineTransformOp.P_INTERPOLATION, interpolation); if (lens != null) { lens.getDisplayOpManager().setParamValue(AffineTransformOp.OP_NAME, AffineTransformOp.P_INTERPOLATION, interpolation); lens.updateZoom(); } imageLayer.updateDisplayOperations(); } }
private PlanarImage getCacheImage(PlanarImage cacheImage, OpManager manager, boolean findMinMax) { if (findMinMax) { try { findMinMaxValues(cacheImage, true); } catch (Exception e) { mCache.remove(this); readable = false; LOGGER.error("Cannot read image: {}", this, e); //$NON-NLS-1$ } } if (manager != null && cacheImage != null) { PlanarImage img = manager.getLastNodeOutputImage(); if (manager.getFirstNodeInputImage() != cacheImage || manager.needProcessing()) { manager.setFirstNode(cacheImage); img = manager.process(); } if (img != null) { return img; } } return cacheImage; }
public void drawLUT(Graphics2D g2, Rectangle bound, float midfontHeight) { OpManager disOp = view2DPane.getDisplayOpManager(); ImageOpNode pseudoColorOp = disOp.getNode(PseudoColorOp.OP_NAME); ByteLut lut = null; if (pseudoColorOp != null) { g2.draw(line); Double ww = (Double) disOp.getParamValue(WindowOp.OP_NAME, ActionW.WINDOW.cmd()); Double wl = (Double) disOp.getParamValue(WindowOp.OP_NAME, ActionW.LEVEL.cmd()); if (ww != null && wl != null) { int stepWindow = (int) (ww / separation);
@Override protected void initActionWState() { super.initActionWState(); actionsInView.put(ActionW.SORTSTACK.cmd(), SortSeriesStack.instanceNumber); // Preprocessing actionsInView.put(ActionW.CROP.cmd(), null); OpManager disOp = getDisplayOpManager(); disOp.setParamValue(ShutterOp.OP_NAME, ShutterOp.P_SHOW, true); disOp.setParamValue(OverlayOp.OP_NAME, OverlayOp.P_SHOW, true); disOp.setParamValue(WindowOp.OP_NAME, ActionW.IMAGE_PIX_PADDING.cmd(), true); disOp.setParamValue(WindowOp.OP_NAME, ActionW.DEFAULT_PRESET.cmd(), true); disOp.setParamValue(WindowOp.OP_NAME, ActionW.PRESET.cmd(), null); initKOActionWState(); }
PresetWindowLevel preset = (PresetWindowLevel) val; DicomImageElement img = getImage(); ImageOpNode node = disOp.getNode(WindowOp.OP_NAME); disOp.setParamValue(WindowOp.OP_NAME, ActionW.DEFAULT_PRESET.cmd(), val); } else if (command.equals(ActionW.LUT_SHAPE.cmd())) { ImageOpNode node = disOp.getNode(WindowOp.OP_NAME); if (node != null) { node.setParam(ActionW.LUT_SHAPE.cmd(), val); if (disOp.setParamValue(ShutterOp.OP_NAME, ShutterOp.P_SHOW, evt.getNewValue())) { imageLayer.updateDisplayOperations(); if (disOp.setParamValue(OverlayOp.OP_NAME, OverlayOp.P_SHOW, evt.getNewValue())) { imageLayer.updateDisplayOperations();
ImageOpNode node = dispOp.getNode(AffineTransformOp.OP_NAME); if (node != null) { Rectangle2D imgBounds = affineTransform.createTransformedShape(modelArea).getBounds2D();
ImageOpNode node = dispOp.getNode(WindowOp.OP_NAME); if (node != null) { Optional<SliderChangeListener> windowAction = getAction(ActionW.WINDOW, SliderChangeListener.class); .setSelectedItemWithoutTriggerAction(dispOp.getParamValue(PseudoColorOp.OP_NAME, PseudoColorOp.P_LUT))); getAction(ActionW.INVERT_LUT, ToggleButtonListener.class).ifPresent(a -> a.setSelectedWithoutTriggerAction( (Boolean) dispOp.getParamValue(PseudoColorOp.OP_NAME, PseudoColorOp.P_LUT_INVERSE))); getAction(ActionW.FILTER, ComboItemListener.class).ifPresent( a -> a.setSelectedItemWithoutTriggerAction(dispOp.getParamValue(FilterOp.OP_NAME, FilterOp.P_KERNEL_DATA))); getAction(ActionW.ROTATION, SliderChangeListener.class) .ifPresent(a -> a.setSliderValue((Integer) view2d.getActionValue(ActionW.ROTATION.cmd()), false));
@Override protected void initActionWState() { super.initActionWState(); actionsInView.put(ViewCanvas.ZOOM_TYPE_CMD, ZoomType.BEST_FIT); actionsInView.put(MIP_THICKNESS.cmd(), 2); actionsInView.put(MipView.MIP.cmd(), MipView.Type.MAX); actionsInView.put("no.ko", true); //$NON-NLS-1$ // Propagate the preset OpManager disOp = getDisplayOpManager(); disOp.setParamValue(WindowOp.OP_NAME, ActionW.DEFAULT_PRESET.cmd(), false); }
ImageOpNode node = dispOp.getNode(AffineTransformOp.OP_NAME); if (node != null) { Rectangle2D imgBounds = affineTransform.createTransformedShape(getViewModel().getModelArea()).getBounds2D();
PresetWindowLevel newPreset = null; boolean pixelPadding = LangUtil.getNULLtoTrue((Boolean) view2d.getDisplayOpManager() .getParamValue(WindowOp.OP_NAME, ActionW.IMAGE_PIX_PADDING.cmd())); (Double) view2d.getDisplayOpManager().getParamValue(WindowOp.OP_NAME, ActionW.LEVEL_MIN.cmd()); Double levelMax = (Double) view2d.getDisplayOpManager().getParamValue(WindowOp.OP_NAME, ActionW.LEVEL_MAX.cmd()); ImageOpNode node = view2d.getDisplayOpManager().getNode(WindowOp.OP_NAME); if (node != null) { node.setParam(ActionW.PRESET.cmd(), newPreset);
private void iniDicomView(OpManager disOp, String op, String param, int index) { TreeNode treeNode = imageNode.getChildAt(index); if (treeNode != null) { Boolean val = (Boolean) disOp.getParamValue(op, param); initPathSelection(getTreePath(treeNode), val == null ? false : val); } }
Object filter = actionsInView.get(ActionW.FILTERED_SERIES.cmd()); OpManager disOp = getDisplayOpManager(); Object preset = disOp.getParamValue(WindowOp.OP_NAME, ActionW.PRESET.cmd()); initActionWState(); setActionsInView(ActionW.KO_SELECTION.cmd(), ko); setActionsInView(ActionW.SPATIAL_UNIT.cmd(), m.getPixelSpacingUnit()); disOp.setParamValue(WindowOp.OP_NAME, ActionW.PRESET.cmd(), preset); resetZoom(); resetPan();
protected void initActionWState() { E img = getImage(); actionsInView.put(ActionW.SPATIAL_UNIT.cmd(), img == null ? Unit.PIXEL : img.getPixelSpacingUnit()); actionsInView.put(ZOOM_TYPE_CMD, ZoomType.BEST_FIT); actionsInView.put(ActionW.ZOOM.cmd(), 0.0); actionsInView.put(ActionW.DRAWINGS.cmd(), true); actionsInView.put(LayerType.CROSSLINES.name(), true); actionsInView.put(ActionW.INVERSESTACK.cmd(), false); actionsInView.put(ActionW.FILTERED_SERIES.cmd(), null); actionsInView.put(ActionW.FLIP.cmd(), false); actionsInView.put(ActionW.ROTATION.cmd(), 0); OpManager disOp = getDisplayOpManager(); disOp.setParamValue(WindowOp.OP_NAME, WindowOp.P_APPLY_WL_COLOR, eventManager.getOptions().getBooleanProperty(WindowOp.P_APPLY_WL_COLOR, true)); disOp.setParamValue(AffineTransformOp.OP_NAME, AffineTransformOp.P_INTERPOLATION, eventManager.getZoomSetting().getInterpolation()); disOp.setParamValue(AffineTransformOp.OP_NAME, AffineTransformOp.P_AFFINE_MATRIX, null); disOp.setParamValue(FilterOp.OP_NAME, FilterOp.P_KERNEL_DATA, KernelData.NONE); disOp.setParamValue(PseudoColorOp.OP_NAME, PseudoColorOp.P_LUT, ByteLut.defaultLUT); disOp.setParamValue(PseudoColorOp.OP_NAME, PseudoColorOp.P_LUT_INVERSE, false); }
private void updateWindowLevelComponentsListener(DicomImageElement image, ViewCanvas<DicomImageElement> view2d) { ImageOpNode node = view2d.getDisplayOpManager().getNode(WindowOp.OP_NAME); if (node != null) { int imageDataType = ImageConversion.convertToDataType(image.getImage().type());
private static void changePixelSize(DicomImageElement img, Map<String, Object> actionsInView, double[] prPixSize) { img.setPixelSize(prPixSize[1], prPixSize[0]); actionsInView.put(PRManager.TAG_CHANGE_PIX_CONFIG, true); ZoomOp node = img.getRectifyAspectRatioZoomOp(); if (node != null) { SimpleOpManager process = new SimpleOpManager(); process.addImageOperationAction(node); OpManager preprocessing = (OpManager) actionsInView.get(ActionW.PREPROCESSING.cmd()); if (preprocessing != null) { for (ImageOpNode op : preprocessing.getOperations()) { if (!node.getName().equals(op.getName())) { process.addImageOperationAction(op); } } } actionsInView.put(ActionW.PREPROCESSING.cmd(), process); } }
@Override protected void fillPixelInfo(final PixelInfo pixelInfo, final DicomImageElement imageElement, final double[] c) { if (c != null && c.length >= 1) { boolean pixelPadding = LangUtil.getNULLtoTrue( (Boolean) getDisplayOpManager().getParamValue(WindowOp.OP_NAME, ActionW.IMAGE_PIX_PADDING.cmd())); PresentationStateReader prReader = (PresentationStateReader) getActionValue(PresentationStateReader.TAG_PR_READER); for (int i = 0; i < c.length; i++) { c[i] = imageElement.pixel2mLUT(c[i], prReader, pixelPadding); } pixelInfo.setValues(c); } }
@Override protected void initActionWState() { super.initActionWState(); actionsInView.put(ViewCanvas.ZOOM_TYPE_CMD, ZoomType.CURRENT); /* * Get the radiologist way to see stack (means in axial, the first image is from feet and last image is in the * head direction) This option may not be changed. Sorting stack must be disabled from menu in UI. */ actionsInView.put(ActionW.SORTSTACK.cmd(), SortSeriesStack.slicePosition); // Propagate the preset OpManager disOp = getDisplayOpManager(); disOp.setParamValue(WindowOp.OP_NAME, ActionW.DEFAULT_PRESET.cmd(), false); // disOp.setParamValue(WindowOp.OP_NAME, ActionW.PRESET.cmd(), null); }
reader.applySpatialTransformationModule(actionsInView); List<PresetWindowLevel> presets = reader.getPresetCollection(img); ImageOpNode node = view.getDisplayOpManager().getNode(WindowOp.OP_NAME); if (node != null) { List<PresetWindowLevel> presetList =