Changeset 7848 for trunk/projects


Ignore:
Timestamp:
12/21/11 23:32:51 (8 years ago)
Author:
aivar
Message:

SLIMPlugin: shows colorized range of values using 254 color palette.

Location:
trunk/projects/slim-plugin/src/main/java/imagej/slim
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/projects/slim-plugin/src/main/java/imagej/slim/fitting/AbstractBaseFittedImage.java

    r7845 r7848  
    1616import imagej.slim.histogram.HistogramDataChannel; 
    1717import imagej.slim.histogram.HistogramTool; 
     18import imagej.slim.histogram.PaletteFix; 
    1819 
    1920/** 
     
    3738        HistogramDataChannel histogramDataChannel = new HistogramDataChannel(_values); 
    3839        HistogramDataChannel[] histogramDataChannels = new HistogramDataChannel[] { histogramDataChannel }; 
    39         _histogramData = new HistogramData(title, histogramDataChannels); 
     40        _histogramData = new HistogramData(this, title, histogramDataChannels); 
    4041        _image = new FloatProcessor(x, y); 
    4142        _image.setColorModel(imagej.slim.histogram.HistogramTool.getIndexColorModel()); 
     
    103104    /** 
    104105     * Recalculates the image histogram and resets the palette.  Called 
    105      * periodically during the fit. 
     106     * periodically during the fit.  Redisplays the image. 
    106107     */ 
    107108    public void recalcHistogram() { 
     
    109110 
    110111        if (null != minMaxLUT) { 
    111             // update palette bounds 
    112             _image.setMinAndMax(minMaxLUT[0], minMaxLUT[1]); 
    113             System.out.println("min max " + minMaxLUT[0] + " " +  minMaxLUT[1]); 
     112            System.out.println("Internal redisplay " + minMaxLUT[0] + " " + minMaxLUT[1]); 
     113            //TODO horrible kludge here!!!  But why on earth would these be zero? 
     114            //TODO #2 wound up enabling this again, otherwise you don't get any images except current image 
     115            if (true) { // 0 != minMaxLUT[0] && 0 != minMaxLUT[1]) { 
     116                redisplay(minMaxLUT); 
     117            } 
    114118        } 
    115119        else System.out.println("min max null"); 
    116 //        System.out.println("min max " + minMax[0] + " " + minMax[1]); 
    117         // etc. 
    118         _imagePlus.setProcessor(_image.duplicate()); 
    119          
    120120         
    121121        System.out.println("RECALC " + numInvalid(_values)); 
    122122    } 
    123      
     123 
     124    /** 
     125     * Called from the histogram tool.  Redisplays the image after LUT ranges 
     126     * have changed. 
     127     */ 
     128    public void redisplay() { 
     129        System.out.println("public redisplay"); 
     130        double[] minMaxLUT = _histogramData.getMinMaxLUT(); 
     131        redisplay(minMaxLUT); 
     132    } 
     133 
     134    /* 
     135     * Redisplay the image with new LUT range. 
     136     */ 
     137    private void redisplay(double[] minMaxLUT) { 
     138        minMaxLUT = PaletteFix.adjustMinMax(minMaxLUT[0], minMaxLUT[1]); 
     139        _image.setMinAndMax(minMaxLUT[0], minMaxLUT[1]); 
     140        System.out.println("SETTING MIN AND MAX LUT TO " + minMaxLUT[0] + " " + minMaxLUT[1]); 
     141        _imagePlus.setProcessor(_image.duplicate()); 
     142    } 
    124143     
    125144    private int numInvalid(double[][] values) { 
  • trunk/projects/slim-plugin/src/main/java/imagej/slim/fitting/IFittedImage.java

    r7842 r7848  
    1212/** 
    1313 * 
    14  * @author Sivar Grislis 
     14 * @author Aivar Grislis 
    1515 */ 
    1616public interface IFittedImage { 
     
    7777 
    7878    /** 
     79     * Redisplays the image. 
     80     */ 
     81    public void redisplay(); 
     82 
     83    /** 
    7984     * Given the array of fitted parameters, get the value for this image. 
    8085     *  
  • trunk/projects/slim-plugin/src/main/java/imagej/slim/histogram/HistogramData.java

    r7847 r7848  
    44 */ 
    55package imagej.slim.histogram; 
     6 
     7import imagej.slim.fitting.IFittedImage; 
    68 
    79/** 
     
    1214 */ 
    1315public class HistogramData { 
     16    private IFittedImage _image; 
    1417    private String _title; 
    1518    private HistogramDataChannel[] _channel; 
     
    2932     * @param channel  
    3033     */ 
    31     public HistogramData(String title, HistogramDataChannel[] channel) { 
     34    public HistogramData(IFittedImage image, String title, 
     35            HistogramDataChannel[] channel) { 
     36        _image = image; 
    3237        _title = title; 
    3338        _channel = channel; 
     
    244249        return new double[] { minLUT, maxLUT }; 
    245250    } 
     251 
     252    public void redisplay() { 
     253        _image.redisplay(); 
     254    } 
    246255     
    247256    public int[] binValues(int bins) { 
  • trunk/projects/slim-plugin/src/main/java/imagej/slim/histogram/HistogramTool.java

    r7847 r7848  
    193193            _histogramPanel.setBins(bins); 
    194194            _colorBarPanel.setMinMax(minView, maxView, minLUT, maxLUT); 
     195            //TODO changed is currently called from two places: 
     196            // i) the HistogramData listener will call it periodically during the 
     197            // fit. 
     198            // ii) if the user types in a new LUT range this gets called. 
     199            // iii) in the future more UI interactions will wind up here 
     200            // 
     201            _histogramData.redisplay(); 
    195202        } 
    196203    } 
     
    204211        public void minMaxChanged(double minView, double maxView, 
    205212                double minLUT, double maxLUT) { 
     213            System.out.println("CHANGED " + minView + " " + maxView + ", " + minLUT + " " + maxLUT); 
    206214            changed(minView, maxView, minLUT, maxLUT); 
    207215        } 
     
    336344                 _histogramData.setAutoRange(autoRange); 
    337345            } 
    338              // turn on/off the cursors 
    339             // they are usually at -1 & 255 
    340             // but if you are autoranging & showing all channels 
    341             // they need to be calculated 
    342             // autorange off, stuff shouldn't change right away 
    343             // autorange on, should calculate new bounds 
     346 
     347            if (autoRange) { 
     348                _histogramPanel.setCursors(null, null); 
     349                //TODO calculate new bounds 
     350            } 
     351            else { 
     352                //TODO if you are autoranging, not combining channels, but showing 
     353                // all channels, these cursors would need to be calculated 
     354                _histogramPanel.setCursors(INSET, INSET + WIDTH - 1); //TODO I was expecting INSET-1 here?? 
     355            } 
    344356        } 
    345357         
Note: See TracChangeset for help on using the changeset viewer.