/* * Converts histogram onscreen horizontal pixel amounts to image values. */ private double pixelToValue(final int pixel) { synchronized (_synchObject) { final double[] minMaxView = _histogramDataGroup.getMinMaxView(); final double min = minMaxView[0]; return min + pixelToValueRelative(pixel); } }
/* * Converts image value to histogram onscreen horizontal pixel. */ private int valueToPixel(final double value) { synchronized (_synchObject) { final double[] minMaxView = _histogramDataGroup.getMinMaxView(); final double min = minMaxView[0]; final double max = minMaxView[1]; final int pixel = (int) (PaletteFix.getSize() * (value - min) / (max - min)); return pixel; } }
private double pixelToValueRelative(final int pixel) { synchronized (_synchObject) { final double[] minMaxView = _histogramDataGroup.getMinMaxView(); final double min = minMaxView[0]; final double max = minMaxView[1]; final double valuePerPixel = (max - min) / PaletteFix.getSize(); return pixel * valuePerPixel; } }
/** * This method should be called whenever a new set of histogram values is to be displayed (i.e. * when a different image gets focus). * * @param histogramData */ public void setHistogramData(final HistogramDataGroup histogramData) { double[] minMaxView; double[] minMaxLUT; synchronized (_synchObject) { _histogramDataGroup = histogramData; _histogramDataGroup.setListener(new HistogramDataListener()); minMaxView = _histogramDataGroup.getMinMaxView(); minMaxLUT = _histogramDataGroup.getMinMaxLUT(); } // IJ.log("----"); // IJ.log("setHistogramData"); // IJ.log("view " + minMaxView[0] + " " + minMaxView[1] + " lut " + minMaxLUT[0] + " " + // minMaxLUT[1]); // IJ.log("----"); if (null != _frame) { if (_frame.isVisible()) { _frame.setVisible(true); } _frame.setTitle(histogramData.getTitle()); _histogramPanel.setStatistics(histogramData.getStatistics(WIDTH)); final boolean autoRange = histogramData.getAutoRange(); if (autoRange) { // turn cursors off _histogramPanel.setCursors(null, null); } else { // set cursors to edges _histogramPanel.setCursors(INSET, INSET + WIDTH - 1); } _uiPanel.setAutoRange(autoRange); _uiPanel.setExcludePixels(histogramData.getExcludePixels()); _uiPanel.setCombineChannels(histogramData.getCombineChannels()); _uiPanel.setDisplayChannels(histogramData.getDisplayChannels()); _uiPanel.enableChannels(histogramData.hasChannels()); _uiPanel.setMinMaxLUT(minMaxLUT[0], minMaxLUT[1]); _colorBarPanel.setMinMax(minMaxView[0], minMaxView[1], minMaxLUT[0], minMaxLUT[1]); } }