@Override public float[] fromRGB(float[] rgbvalue) { float[] xyz = CIEXYZ.fromRGB(rgbvalue); return fromCIEXYZ(xyz); }
float[] colorLab = CIELab.convertToFloatLab(DicomMediaUtils.getIntAyrrayFromDicomElement(glm, Tag.GraphicLayerRecommendedDisplayCIELabValue, null)); int[] colorRgb = DicomMediaUtils.getIntAyrrayFromDicomElement(glm, Float thickness = DicomMediaUtils.getFloatFromDicomElement(style, Tag.LineThickness, 1.0f); if (style != null) { float[] lab = CIELab.convertToFloatLab(style.getInts(Tag.PatternOnColorCIELabValue)); if (lab != null) { rgb = PresentationStateReader.getRGBColor(255, lab, (int[]) null);
private static Attributes bluildLabelAndAnchor(AnnotationGraphic g) { Rectangle2D bound = g.getLabelBounds(); Point2D anchor = g.getAnchorPoint(); String text = Arrays.stream(g.getLabels()).collect(Collectors.joining("\r\n")); //$NON-NLS-1$ Attributes attributes = new Attributes(7); attributes.setString(Tag.BoundingBoxAnnotationUnits, VR.CS, PIXEL); attributes.setFloat(Tag.AnchorPoint, VR.FL, (float) anchor.getX(), (float) anchor.getY()); attributes.setString(Tag.AnchorPointVisibility, VR.CS, "Y"); //$NON-NLS-1$ Sequence style = attributes.newSequence(Tag.LineStyleSequence, 1); Attributes styles = new Attributes(); styles.setFloat(Tag.LineThickness, VR.FL, g.getLineThickness()); if (g.getColorPaint() instanceof Color) { Color color = (Color) g.getColorPaint(); float[] rgb = PresentationStateReader.colorToLAB(color); if (rgb != null) { styles.setInt(Tag.PatternOnColorCIELabValue, VR.US, CIELab.convertToDicomLab(rgb)); } } style.add(styles); attributes.setDouble(Tag.BoundingBoxTopLeftHandCorner, VR.FL, new double[] { bound.getMinX(), bound.getMinY() }); attributes.setDouble(Tag.BoundingBoxBottomRightHandCorner, VR.FL, new double[] { bound.getMaxX(), bound.getMaxY() }); // In text strings (value representation ST, LT, or UT) a new line shall be represented as CR LF. // see http://dicom.nema.org/medical/dicom/current/output/chtml/part05/chapter_6.html attributes.setString(Tag.UnformattedTextValue, VR.ST, text); return attributes; }
@Override public float[] toRGB(float[] colorvalue) { float[] xyz = toCIEXYZ(colorvalue); return CIEXYZ.toRGB(xyz); }
public static void setShutterColor(Tagable tagable, Attributes attributes) { Integer psVal = (Integer) TagD.get(Tag.ShutterPresentationValue).getValue(attributes); tagable.setTagNoNull(TagW.ShutterPSValue, TagD.get(Tag.ShutterPresentationValue).getValue(attributes)); float[] rgb = CIELab.convertToFloatLab((int[]) TagD.get(Tag.ShutterPresentationColorCIELabValue).getValue(attributes)); Color color = rgb == null ? null : PresentationStateReader.getRGBColor(psVal == null ? 0 : psVal, rgb, (int[]) null); tagable.setTagNoNull(TagW.ShutterRGBColor, color); }
private static void writeGraphics(GraphicModel model, Attributes attributes) { List<GraphicLayer> layers = model.getLayers(); Sequence annotationSeq = attributes.newSequence(Tag.GraphicAnnotationSequence, layers.size()); Sequence layerSeq = attributes.newSequence(Tag.GraphicLayerSequence, layers.size()); for (int i = 0; i < layers.size(); i++) { GraphicLayer layer = layers.get(i); if (layer.getSerializable()) { String layerName = layer.getType().name(); List<Graphic> graphics = getGraphicsByLayer(model, layer.getUuid()); Attributes l = new Attributes(2); l.setString(Tag.GraphicLayer, VR.CS, layerName); l.setInt(Tag.GraphicLayerOrder, VR.IS, i); float[] lab = PresentationStateReader .colorToLAB(Optional.ofNullable(MeasureTool.viewSetting.getLineColor()).orElse(Color.YELLOW)); if (lab != null) { l.setInt(Tag.GraphicLayerRecommendedDisplayCIELabValue, VR.US, CIELab.convertToDicomLab(lab)); } l.setString(Tag.GraphicLayerDescription, VR.LO, layer.toString()); layerSeq.add(l); Attributes a = new Attributes(2); a.setString(Tag.GraphicLayer, VR.CS, layerName); Sequence graphicSeq = a.newSequence(Tag.GraphicObjectSequence, graphics.size()); Sequence textSeq = a.newSequence(Tag.TextObjectSequence, graphics.size()); for (Graphic graphic : graphics) { buildDicomGraphic(graphic, graphicSeq, textSeq); } annotationSeq.add(a); } } }
Boolean dashed = style == null ? Boolean.FALSE : "DASHED".equalsIgnoreCase(style.getString(Tag.LinePattern)); //$NON-NLS-1$ if (style != null) { float[] rgb = CIELab.convertToFloatLab(style.getInts(Tag.PatternOnColorCIELabValue)); if (rgb != null) { color = PresentationStateReader.getRGBColor(255, rgb, (int[]) null);
private static Attributes getBasicGraphic(Graphic graphic) { Attributes dcm = new Attributes(5); dcm.setString(Tag.GraphicAnnotationUnits, VR.CS, PIXEL); dcm.setInt(Tag.GraphicDimensions, VR.US, 2); dcm.setString(Tag.GraphicFilled, VR.CS, graphic.getFilled() ? "Y" : "N"); //$NON-NLS-1$ //$NON-NLS-2$ Sequence style = dcm.newSequence(Tag.LineStyleSequence, 1); Attributes styles = new Attributes(); styles.setFloat(Tag.LineThickness, VR.FL, graphic.getLineThickness()); if (graphic.getColorPaint() instanceof Color) { Color color = (Color) graphic.getColorPaint(); float[] rgb = PresentationStateReader.colorToLAB(color); if (rgb != null) { styles.setInt(Tag.PatternOnColorCIELabValue, VR.US, CIELab.convertToDicomLab(rgb)); } } style.add(styles); return dcm; }
Boolean dashed = style == null ? Boolean.FALSE : "DASHED".equalsIgnoreCase(style.getString(Tag.LinePattern)); //$NON-NLS-1$ if (style != null) { float[] rgb = CIELab.convertToFloatLab(style.getInts(Tag.PatternOnColorCIELabValue)); if (rgb != null) { color = PresentationStateReader.getRGBColor(255, rgb, (int[]) null);