Changeset 7994


Ignore:
Timestamp:
04/27/12 19:17:15 (7 years ago)
Author:
aivar
Message:

SLIM Plugin: Clean up code, comments. Worked on masking.

Location:
trunk/projects/slim-plugin/src/main/java/loci/slim
Files:
13 edited
9 moved

Legend:

Unmodified
Added
Removed
  • trunk/projects/slim-plugin/src/main/java/loci/slim/IGrayScalePixelValue.java

    r7993 r7994  
    3636 
    3737/** 
    38  * Interface for a grayscale pixel value. 
     38 * Interface for a grayscale pixel value getter. 
    3939 *  
    4040 * @author Aivar Grislis grislis at wisc dot edu 
  • trunk/projects/slim-plugin/src/main/java/loci/slim/SLIMProcessor.java

    r7993 r7994  
    8989import loci.slim.fitting.cursor.IFittingCursorListener; 
    9090import loci.slim.fitting.engine.IFittingEngine; 
    91 import loci.slim.fitting.images.ColorizedImageParser; 
     91import loci.slim.fitting.images.FittedImageParser; 
    9292import loci.slim.fitting.params.IGlobalFitParams; 
    9393import loci.slim.fitting.params.LocalFitParams; 
     
    9797 
    9898import loci.slim.fitting.FitInfo; 
    99 import loci.slim.fitting.images.ColorizedImageFitter; 
    100 import loci.slim.fitting.images.ColorizedImageFitter.ColorizedImageType; 
     99import loci.slim.fitting.images.FittedImageFitter; 
     100import loci.slim.fitting.images.FittedImageFitter.FittedImageType; 
    101101import loci.slim.heuristics.Estimator; 
    102102import loci.slim.heuristics.IEstimator; 
     
    343343 
    344344                /** 
    345                  * Creates an excitation curve from currrent X, Y and saves to file. 
     345                 * Creates an excitation curve from current X, Y and saves to file. 
    346346                 * 
    347347                 * @param fileName 
     
    909909        } 
    910910        int[] dimension = new int[] { width, height, colorizedChannels }; 
    911         ColorizedImageFitter imageColorizer = null; 
     911        FittedImageFitter imageColorizer = null; 
    912912        String outputs = fitInfo.getFittedImages(); 
    913913        if (null != outputs) { 
    914914            int components = fitInfo.getComponents(); 
    915915            boolean stretched = fitInfo.getStretched(); 
    916             ColorizedImageParser parser = 
    917                     new ColorizedImageParser(outputs, components, stretched, 
     916            FittedImageParser parser = 
     917                    new FittedImageParser(outputs, components, stretched, 
    918918                            fitInfo.getFree()); 
    919             ColorizedImageType[] outputImages = parser.getColorizedImages(); 
    920             imageColorizer = new ColorizedImageFitter(); 
     919            FittedImageType[] outputImages = parser.getColorizedImages(); 
     920            imageColorizer = new FittedImageFitter(); 
    921921            imageColorizer.setUpFit( 
    922922                    outputImages, 
     
    10391039            IGlobalFitParams globalFitParams, 
    10401040            ILocalFitParams[] localFitParams, 
    1041             ColorizedImageFitter imageColorizer, 
     1041            FittedImageFitter imageColorizer, 
    10421042            IFittedImage fittedImage) { 
    10431043 
  • trunk/projects/slim-plugin/src/main/java/loci/slim/fitting/cursor/FitterEstimator.java

    r7992 r7994  
    5353    @Override 
    5454    public int getEstimateStartIndex(double[] yCount, int start, int stop) { 
    55         System.out.println("FitterEstimator.getEstimateStartIndex " + yCount.length + " " + start + " " + stop); 
     55        //System.out.println("FitterEstimator.getEstimateStartIndex " + yCount.length + " " + start + " " + stop); 
    5656        if (start < 0) { 
    5757            start = 0; 
     
    6464    @Override 
    6565    public double getEstimateAValue(double A, double[] yCount, int start, int stop) { 
    66         System.out.println("FitterEstimator.getEstimateA " + yCount.length + " " + start + " " + stop); 
     66        //System.out.println("FitterEstimator.getEstimateA " + yCount.length + " " + start + " " + stop); 
    6767        // A parameter estimate changes for RLD estimate fit 
    6868        int transEstimateStartIndex = findMax(yCount, start, stop); 
  • trunk/projects/slim-plugin/src/main/java/loci/slim/fitting/images/AbstractBaseFittedImage.java

    r7970 r7994  
     1// 
     2// AbstractBaseFittedImage.java 
     3// 
     4 
    15/* 
    2  * To change this template, choose Tools | Templates 
    3  * and open the template in the editor. 
    4  */ 
     6SLIMPlugin for combined spectral-lifetime image analysis. 
     7 
     8Copyright (c) 2010, UW-Madison LOCI 
     9All rights reserved. 
     10 
     11Redistribution and use in source and binary forms, with or without 
     12modification, are permitted provided that the following conditions are met: 
     13    * Redistributions of source code must retain the above copyright 
     14      notice, this list of conditions and the following disclaimer. 
     15    * Redistributions in binary form must reproduce the above copyright 
     16      notice, this list of conditions and the following disclaimer in the 
     17      documentation and/or other materials provided with the distribution. 
     18    * Neither the name of the UW-Madison LOCI nor the 
     19      names of its contributors may be used to endorse or promote products 
     20      derived from this software without specific prior written permission. 
     21 
     22THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 
     23AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 
     24IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 
     25ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE 
     26LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 
     27CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 
     28SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 
     29INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 
     30CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 
     31ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 
     32POSSIBILITY OF SUCH DAMAGE. 
     33*/ 
    534 
    635package loci.slim.fitting.images; 
     
    1645import ij.ImagePlus; 
    1746import ij.ImageStack; 
    18 import ij.process.FloatProcessor; 
    1947 
    2048import loci.slim.IGrayScalePixelValue; 
    21 import loci.slim.histogram.HistogramData; 
    22 import loci.slim.histogram.HistogramDataChannel; 
     49import loci.slim.histogram.HistogramDataGroup; 
     50import loci.slim.histogram.HistogramDataNode; 
    2351import loci.slim.histogram.HistogramTool; 
    2452import loci.slim.histogram.PaletteFix; 
     53import loci.slim.mask.IMaskGroup; 
     54import loci.slim.mask.Mask; 
    2555 
    2656import loci.slim.MyStackWindow; 
    2757 
    2858/** 
    29  * 
    30  * @author aivar 
     59 * Base class for the fitted images. 
     60 *  
     61 * @author Aivar Grislis grislis at wisc dot edu 
    3162 */ 
    32 abstract public class AbstractBaseColorizedImage implements IColorizedImage { 
     63abstract public class AbstractBaseFittedImage implements IFittedImage { 
    3364    private static final int UNKNOWN_CHANNEL = -1; 
    3465    private String _title; 
     
    4374    private double _values[][]; 
    4475    private IColorizedFittedImage[] _fittedImages; 
    45     private HistogramDataChannel[] _dataChannels; 
    46     private HistogramData _histogramData; 
     76    private HistogramDataNode[] _dataChannels; 
     77    private HistogramDataGroup _histogramData; 
    4778    private IColorizedFittedImage _fittedImage; 
    4879     
    49     public AbstractBaseColorizedImage( 
     80    public AbstractBaseFittedImage( 
    5081            String title, 
    5182            int[] dimension, 
    5283            IndexColorModel indexColorModel, 
    5384            boolean colorizeGrayScale, 
    54             IGrayScalePixelValue grayScalePixelValue) { 
     85            IGrayScalePixelValue grayScalePixelValue, 
     86            IMaskGroup[] maskGroup) { 
    5587        _title = title; 
    5688        _width = dimension[0]; 
     
    68100         
    69101        // building a list of HistogramDataChannels 
    70         List<HistogramDataChannel> dataChannelList 
    71                 = new ArrayList<HistogramDataChannel>(); 
     102        List<HistogramDataNode> dataChannelList 
     103                = new ArrayList<HistogramDataNode>(); 
    72104         
    73105        for (int c = 0; c < _channels; ++c) {        
     
    75107            _values = new double[_width][_height]; 
    76108            clear(_values); 
    77             HistogramDataChannel histogramDataChannel 
    78                     = new HistogramDataChannel(_values); 
     109            HistogramDataNode histogramDataChannel 
     110                    = new HistogramDataNode(_values); 
    79111            dataChannelList.add(histogramDataChannel); 
    80112             
     
    118150                = fittedImageList.toArray(new IColorizedFittedImage[0]); 
    119151        _dataChannels 
    120                 = dataChannelList.toArray(new HistogramDataChannel[0]); 
    121          
    122         _histogramData = new HistogramData(this, title, _dataChannels);  
     152                = dataChannelList.toArray(new HistogramDataNode[0]); 
     153         
     154        for (int i = 0; i < _dataChannels.length; ++i) { 
     155            _dataChannels[i].setMaskGroup(maskGroup[i]); 
     156        } 
     157         
     158        _histogramData = new HistogramDataGroup(this, title, _dataChannels);  
    123159    } 
    124160 
     
    147183     * @return 
    148184     */ 
    149     public HistogramData getHistogramData() { 
     185    public HistogramDataGroup getHistogramData() { 
    150186        return _histogramData; 
    151187    } 
     
    191227        redisplay(minMaxLUT); 
    192228    } 
     229 
     230    //TODO MASK 
     231    /** 
     232     * Redisplays the image after the mask changes. 
     233     *  
     234     * @param mask  
     235     */ 
     236    //public void redisplay(Mask mask) { 
     237    //    for (IColorizedFittedImage fittedImage : _fittedImages) { 
     238    //        fittedImage.setMask(mask); 
     239    //    } 
     240    //    if (null != _fittedImage) { 
     241    //        _fittedImage. 
     242    //    } 
     243    //} 
    193244 
    194245    /* 
  • trunk/projects/slim-plugin/src/main/java/loci/slim/fitting/images/ColorizedFittedImage.java

    r7970 r7994  
     1// 
     2// ColorizedFittedImage.java 
     3// 
     4 
    15/* 
    2  * To change this template, choose Tools | Templates 
    3  * and open the template in the editor. 
    4  */ 
     6SLIMPlugin for combined spectral-lifetime image analysis. 
     7 
     8Copyright (c) 2010, UW-Madison LOCI 
     9All rights reserved. 
     10 
     11Redistribution and use in source and binary forms, with or without 
     12modification, are permitted provided that the following conditions are met: 
     13    * Redistributions of source code must retain the above copyright 
     14      notice, this list of conditions and the following disclaimer. 
     15    * Redistributions in binary form must reproduce the above copyright 
     16      notice, this list of conditions and the following disclaimer in the 
     17      documentation and/or other materials provided with the distribution. 
     18    * Neither the name of the UW-Madison LOCI nor the 
     19      names of its contributors may be used to endorse or promote products 
     20      derived from this software without specific prior written permission. 
     21 
     22THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 
     23AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 
     24IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 
     25ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE 
     26LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 
     27CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 
     28SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 
     29INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 
     30CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 
     31ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 
     32POSSIBILITY OF SUCH DAMAGE. 
     33*/ 
     34 
    535package loci.slim.fitting.images; 
    636 
    737import java.awt.Color; 
    8 import java.awt.color.ColorSpace; 
    938import java.awt.image.IndexColorModel; 
    1039 
     
    1847 * SPCImage software. 
    1948 *  
    20  * @author Aivar Grislis 
     49 * @author Aivar Grislis grislis at wisc dot edu 
    2150 */ 
    2251public class ColorizedFittedImage implements IColorizedFittedImage { 
     
    3362     
    3463    public ColorizedFittedImage(IGrayScalePixelValue grayScalePixelValue, 
    35             double[][] values) { 
     64            double[][] values) 
     65    { 
    3666        _grayScalePixelValue = grayScalePixelValue; 
    3767        _values = values; 
     
    102132        return new Color(grayValue, grayValue, grayValue); 
    103133    } 
    104      
     134 
     135    /* 
     136     * This method does the actual colorization.  Given a gray level and 
     137     * a value to display, returns the colorized Color. 
     138     *  
     139     */ 
    105140    private Color getColorizedGrayColor(int grayValue, double value) { 
    106141        if (_max == _min) { 
  • trunk/projects/slim-plugin/src/main/java/loci/slim/fitting/images/FittedImageFactory.java

    r7970 r7994  
     1// 
     2// FittedImageFactory.java 
     3// 
     4 
    15/* 
    2  * To change this template, choose Tools | Templates 
    3  * and open the template in the editor. 
    4  */ 
     6SLIMPlugin for combined spectral-lifetime image analysis. 
     7 
     8Copyright (c) 2010, UW-Madison LOCI 
     9All rights reserved. 
     10 
     11Redistribution and use in source and binary forms, with or without 
     12modification, are permitted provided that the following conditions are met: 
     13    * Redistributions of source code must retain the above copyright 
     14      notice, this list of conditions and the following disclaimer. 
     15    * Redistributions in binary form must reproduce the above copyright 
     16      notice, this list of conditions and the following disclaimer in the 
     17      documentation and/or other materials provided with the distribution. 
     18    * Neither the name of the UW-Madison LOCI nor the 
     19      names of its contributors may be used to endorse or promote products 
     20      derived from this software without specific prior written permission. 
     21 
     22THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 
     23AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 
     24IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 
     25ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE 
     26LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 
     27CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 
     28SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 
     29INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 
     30CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 
     31ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 
     32POSSIBILITY OF SUCH DAMAGE. 
     33*/ 
     34 
    535package loci.slim.fitting.images; 
    636 
     
    838 
    939import loci.slim.IGrayScalePixelValue; 
    10 import loci.slim.fitting.images.IColorizedImage; 
    11 import loci.slim.fitting.images.ColorizedImage; 
     40import loci.slim.fitting.images.IFittedImage; 
     41import loci.slim.fitting.images.SimpleFittedImage; 
    1242import loci.slim.fitting.images.FractionalIntensityImage; 
    1343import loci.slim.fitting.images.FractionalContributionImage; 
    14 import loci.slim.fitting.images.ColorizedImageFitter.ColorizedImageType; 
     44import loci.slim.fitting.images.FittedImageFitter.FittedImageType; 
     45import loci.slim.mask.IMaskGroup; 
    1546 
    1647/** 
    17  * 
    18  * @author Aivar Grislis 
     48 * Factory creates fitted images. 
     49 *  
     50 * @author Aivar Grislis grislis at wisc dot edu 
    1951 */ 
    20 public class ColorizedImageFactory { 
    21     private static ColorizedImageFactory INSTANCE = null; 
     52public class FittedImageFactory { 
     53    private static FittedImageFactory INSTANCE = null; 
    2254     
    23     private ColorizedImageFactory() {  
     55    private FittedImageFactory() {  
    2456    } 
    2557     
    26     public static synchronized ColorizedImageFactory getInstance() { 
     58    public static synchronized FittedImageFactory getInstance() { 
    2759        if (null == INSTANCE) { 
    28             INSTANCE = new ColorizedImageFactory(); 
     60            INSTANCE = new FittedImageFactory(); 
    2961        } 
    3062        return INSTANCE; 
    3163    } 
    3264     
    33     public IColorizedImage createImage( 
    34             ColorizedImageType outputImageType, 
     65    public IFittedImage createImage( 
     66            FittedImageType outputImageType, 
    3567            int[] dimension, 
    3668            IndexColorModel indexColorModel, 
    3769            int components, 
    3870            boolean colorizeGrayScale, 
    39             IGrayScalePixelValue grayScalePixelValue) 
     71            IGrayScalePixelValue grayScalePixelValue, 
     72            IMaskGroup[] maskGroup) 
    4073    { 
    41         IColorizedImage fittedImage = null; 
     74        IFittedImage fittedImage = null; 
    4275        String title; 
    4376        switch (outputImageType) { 
    4477            case A1: 
    4578                title = (1 == components) ? "A" : "A1"; 
    46                 fittedImage = new ColorizedImage(title, dimension, 
    47                         indexColorModel, ColorizedImageFitter.A1_INDEX, 
    48                         colorizeGrayScale, 
    49                         grayScalePixelValue); 
     79                fittedImage = new SimpleFittedImage(title, dimension, 
     80                        indexColorModel, FittedImageFitter.A1_INDEX, 
     81                        colorizeGrayScale, grayScalePixelValue, maskGroup); 
    5082                break; 
    5183            case T1: 
    5284                title = (1 == components) ? "T" : "T1"; 
    53                 fittedImage = new ColorizedImage(title, dimension, 
    54                         indexColorModel, ColorizedImageFitter.T1_INDEX, 
    55                         colorizeGrayScale, 
    56                         grayScalePixelValue); 
     85                fittedImage = new SimpleFittedImage(title, dimension, 
     86                        indexColorModel, FittedImageFitter.T1_INDEX, 
     87                        colorizeGrayScale, grayScalePixelValue, maskGroup); 
    5788                break; 
    5889            case A2: 
    59                 fittedImage = new ColorizedImage("A2", dimension, 
    60                         indexColorModel, ColorizedImageFitter.A2_INDEX, 
    61                         colorizeGrayScale, 
    62                         grayScalePixelValue); 
     90                fittedImage = new SimpleFittedImage("A2", dimension, 
     91                        indexColorModel, FittedImageFitter.A2_INDEX, 
     92                        colorizeGrayScale, grayScalePixelValue, maskGroup); 
    6393                break; 
    6494            case T2: 
    65                 fittedImage = new ColorizedImage("T2", dimension, 
    66                         indexColorModel, ColorizedImageFitter.T2_INDEX, 
    67                         colorizeGrayScale, 
    68                         grayScalePixelValue); 
     95                fittedImage = new SimpleFittedImage("T2", dimension, 
     96                        indexColorModel, FittedImageFitter.T2_INDEX, 
     97                        colorizeGrayScale, grayScalePixelValue, maskGroup); 
    6998                break; 
    7099            case A3: 
    71                 fittedImage = new ColorizedImage("A3", dimension, 
    72                         indexColorModel, ColorizedImageFitter.A2_INDEX, 
    73                         colorizeGrayScale, 
    74                         grayScalePixelValue); 
     100                fittedImage = new SimpleFittedImage("A3", dimension, 
     101                        indexColorModel, FittedImageFitter.A2_INDEX, 
     102                        colorizeGrayScale, grayScalePixelValue, maskGroup); 
    75103                break; 
    76104            case T3: 
    77                 fittedImage = new ColorizedImage("T3", dimension, 
    78                         indexColorModel, ColorizedImageFitter.T2_INDEX, 
    79                         colorizeGrayScale,  
    80                         grayScalePixelValue); 
     105                fittedImage = new SimpleFittedImage("T3", dimension, 
     106                        indexColorModel, FittedImageFitter.T2_INDEX, 
     107                        colorizeGrayScale, grayScalePixelValue, maskGroup); 
    81108                break; 
    82109            case H: 
    83                 fittedImage = new ColorizedImage("H", dimension, 
    84                         indexColorModel, ColorizedImageFitter.H_INDEX, 
    85                         colorizeGrayScale, 
    86                         grayScalePixelValue); 
     110                fittedImage = new SimpleFittedImage("H", dimension, 
     111                        indexColorModel, FittedImageFitter.H_INDEX, 
     112                        colorizeGrayScale, grayScalePixelValue, maskGroup); 
    87113                break; 
    88114            case Z: 
    89                 fittedImage = new ColorizedImage("Z", dimension, 
    90                         indexColorModel, ColorizedImageFitter.Z_INDEX, 
    91                         colorizeGrayScale, 
    92                         grayScalePixelValue); 
     115                fittedImage = new SimpleFittedImage("Z", dimension, 
     116                        indexColorModel, FittedImageFitter.Z_INDEX, 
     117                        colorizeGrayScale, grayScalePixelValue, maskGroup); 
    93118                break; 
    94119            case CHISQ: 
    95                 fittedImage = new ColorizedImage("X2", dimension, 
    96                         indexColorModel, ColorizedImageFitter.CHISQ_INDEX, 
    97                         colorizeGrayScale, 
    98                         grayScalePixelValue); 
     120                fittedImage = new SimpleFittedImage("X2", dimension, 
     121                        indexColorModel, FittedImageFitter.CHISQ_INDEX, 
     122                        colorizeGrayScale, grayScalePixelValue, maskGroup); 
    99123                break; 
    100124            case F1: 
    101125                fittedImage = new FractionalIntensityImage("F1", dimension, 
    102126                        indexColorModel, 0, components, colorizeGrayScale, 
    103                         grayScalePixelValue); 
     127                        grayScalePixelValue, maskGroup); 
    104128                break; 
    105129            case F2: 
    106130                fittedImage = new FractionalIntensityImage("F2", dimension, 
    107131                        indexColorModel, 1, components, colorizeGrayScale, 
    108                         grayScalePixelValue); 
     132                        grayScalePixelValue, maskGroup); 
    109133                break; 
    110134            case F3: 
    111135                fittedImage = new FractionalIntensityImage("F3", dimension, 
    112136                        indexColorModel, 2, components, colorizeGrayScale, 
    113                         grayScalePixelValue); 
     137                        grayScalePixelValue, maskGroup); 
    114138                break; 
    115139            case f1: 
    116140                fittedImage = new FractionalContributionImage("f1", dimension, 
    117141                        indexColorModel, 0, components, colorizeGrayScale, 
    118                         grayScalePixelValue); 
     142                        grayScalePixelValue, maskGroup); 
    119143                break; 
    120144            case f2: 
    121145                fittedImage = new FractionalContributionImage("f2", dimension, 
    122146                        indexColorModel, 1, components, colorizeGrayScale, 
    123                         grayScalePixelValue); 
     147                        grayScalePixelValue, maskGroup); 
    124148                break; 
    125149            case f3: 
    126150                fittedImage = new FractionalContributionImage("f3", dimension, 
    127151                        indexColorModel, 2, components, colorizeGrayScale, 
    128                         grayScalePixelValue); 
     152                        grayScalePixelValue, maskGroup); 
    129153                break; 
    130154        } 
  • trunk/projects/slim-plugin/src/main/java/loci/slim/fitting/images/FittedImageFitter.java

    r7970 r7994  
     1// 
     2// AbstractBaseFittedImage.java 
     3// 
     4 
    15/* 
    2  * To change this template, choose Tools | Templates 
    3  * and open the template in the editor. 
    4  */ 
     6SLIMPlugin for combined spectral-lifetime image analysis. 
     7 
     8Copyright (c) 2010, UW-Madison LOCI 
     9All rights reserved. 
     10 
     11Redistribution and use in source and binary forms, with or without 
     12modification, are permitted provided that the following conditions are met: 
     13    * Redistributions of source code must retain the above copyright 
     14      notice, this list of conditions and the following disclaimer. 
     15    * Redistributions in binary form must reproduce the above copyright 
     16      notice, this list of conditions and the following disclaimer in the 
     17      documentation and/or other materials provided with the distribution. 
     18    * Neither the name of the UW-Madison LOCI nor the 
     19      names of its contributors may be used to endorse or promote products 
     20      derived from this software without specific prior written permission. 
     21 
     22THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 
     23AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 
     24IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 
     25ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE 
     26LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 
     27CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 
     28SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 
     29INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 
     30CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 
     31ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 
     32POSSIBILITY OF SUCH DAMAGE. 
     33*/ 
     34 
    535package loci.slim.fitting.images; 
    636 
     
    1141import loci.slim.IGrayScalePixelValue; 
    1242import loci.slim.histogram.HistogramTool; 
     43import loci.slim.mask.IMaskGroup; 
     44import loci.slim.mask.MaskGroup; 
    1345 
    1446/** 
    15  * This class 
     47 * This class handles the fitted image fitting process. 
     48 *  
    1649 * @author Aivar Grislis 
    1750 */ 
    18 //TODO ARG FIX this class handles the process of building up a fit.  However it 
    19 //  needs to work with post-fit pixel masking 
    20 //TODO ARG FIX this class needs to work with colorized images also 
    21 public class ColorizedImageFitter { 
    22     public enum ColorizedImageType { A1, T1, A2, T2, A3, T3, Z, H, CHISQ, F1, F2, F3, f1, f2, f3 }; 
     51public class FittedImageFitter { 
     52    public enum FittedImageType { A1, T1, A2, T2, A3, T3, Z, H, CHISQ, F1, F2, F3, f1, f2, f3 }; 
    2353    public static final int A1_INDEX    = 2; 
    2454    public static final int T1_INDEX    = 3; 
     
    3060    public static final int Z_INDEX     = 1; 
    3161    public static final int CHISQ_INDEX = 0; 
    32     private List<IColorizedImage> _fittedImages; 
     62    private List<IFittedImage> _fittedImages; 
    3363     
    34     public ColorizedImageFitter() { 
    35         _fittedImages = new ArrayList<IColorizedImage>(); 
     64    public FittedImageFitter() { 
     65        _fittedImages = new ArrayList<IFittedImage>(); 
    3666    } 
    3767     
    3868    public void setUpFit( 
    39             ColorizedImageType[] images, 
     69            FittedImageType[] imageTypes, 
    4070            int[] dimension, 
    4171            IndexColorModel indexColorModel, 
     
    4474            IGrayScalePixelValue grayScalePixelValue) 
    4575    { 
     76        // create shared MaskGroup for each channel 
     77        IMaskGroup[] maskGroup = new MaskGroup[imageTypes.length]; 
     78        for (int i = 0; i < maskGroup.length; ++i) { 
     79            maskGroup[i] = new MaskGroup(); 
     80        } 
     81         
    4682        _fittedImages.clear(); 
    47         for (ColorizedImageType image : images) { 
    48             IColorizedImage fittedImage = 
    49                     ColorizedImageFactory.getInstance().createImage 
    50                             (image, 
     83        for (FittedImageType imageType : imageTypes) { 
     84            IFittedImage fittedImage = 
     85                    FittedImageFactory.getInstance().createImage 
     86                            (imageType, 
    5187                            dimension, 
    5288                            indexColorModel, 
    5389                            components, 
    5490                            colorizeGrayScale, 
    55                             grayScalePixelValue); 
     91                            grayScalePixelValue, 
     92                            maskGroup); 
    5693            _fittedImages.add(fittedImage); 
    5794        } 
    5895         
    5996        // Show histogram tool for the last image created 
    60         int lastIndex = images.length - 1; 
     97        int lastIndex = imageTypes.length - 1; 
    6198        if (lastIndex >= 0) { 
    6299            HistogramTool.getInstance().setHistogramData 
     
    69106     */ 
    70107    public void beginFit() { 
    71         for (IColorizedImage fittedImage : _fittedImages) { 
     108        for (IFittedImage fittedImage : _fittedImages) { 
    72109            fittedImage.beginFit(); 
    73110        } 
     
    78115     */ 
    79116    public void endFit() { 
    80         for (IColorizedImage fittedImage : _fittedImages) { 
     117        for (IFittedImage fittedImage : _fittedImages) { 
    81118            fittedImage.endFit(); 
    82119        } 
     
    88125     */ 
    89126    public void cancelFit() { 
    90         for (IColorizedImage fittedImage : _fittedImages) { 
     127        for (IFittedImage fittedImage : _fittedImages) { 
    91128            fittedImage.cancelFit(); 
    92129        } 
     
    100137     */ 
    101138    public void updatePixel(int[] location, double[] parameters) { 
    102         for (IColorizedImage fittedImage : _fittedImages) { 
     139        for (IFittedImage fittedImage : _fittedImages) { 
    103140            fittedImage.updatePixel(location, parameters); 
    104141        } 
     
    114151     */ 
    115152    public void updateChunkyPixel(int[] location, int[] dimension, double[] parameters) { 
    116         for (IColorizedImage fittedImage : _fittedImages) { 
     153        for (IFittedImage fittedImage : _fittedImages) { 
    117154            fittedImage.updateChunkyPixel(location, dimension, parameters); 
    118155        } 
     
    123160     */ 
    124161    public void recalcHistogram() {     
    125         for (IColorizedImage fittedImage : _fittedImages) { 
     162        for (IFittedImage fittedImage : _fittedImages) { 
    126163            fittedImage.recalcHistogram(); 
    127164        } 
  • trunk/projects/slim-plugin/src/main/java/loci/slim/fitting/images/FittedImageParser.java

    r7889 r7994  
     1// 
     2// FittedImageParser.java 
     3// 
     4 
    15/* 
    2  * To change this template, choose Tools | Templates 
    3  * and open the template in the editor. 
    4  */ 
     6SLIMPlugin for combined spectral-lifetime image analysis. 
     7 
     8Copyright (c) 2010, UW-Madison LOCI 
     9All rights reserved. 
     10 
     11Redistribution and use in source and binary forms, with or without 
     12modification, are permitted provided that the following conditions are met: 
     13    * Redistributions of source code must retain the above copyright 
     14      notice, this list of conditions and the following disclaimer. 
     15    * Redistributions in binary form must reproduce the above copyright 
     16      notice, this list of conditions and the following disclaimer in the 
     17      documentation and/or other materials provided with the distribution. 
     18    * Neither the name of the UW-Madison LOCI nor the 
     19      names of its contributors may be used to endorse or promote products 
     20      derived from this software without specific prior written permission. 
     21 
     22THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 
     23AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 
     24IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 
     25ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE 
     26LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 
     27CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 
     28SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 
     29INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 
     30CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 
     31ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 
     32POSSIBILITY OF SUCH DAMAGE. 
     33*/ 
     34 
    535package loci.slim.fitting.images; 
    636 
    7 import loci.slim.fitting.images.ColorizedImageFitter.ColorizedImageType; 
     37import loci.slim.fitting.images.FittedImageFitter.FittedImageType; 
    838 
    939import java.util.ArrayList; 
     
    1444 * "A T Z X2" and produces an array of ColorizedImageType. 
    1545 *  
    16  * @author Aivar Grislis 
     46 * @author Aivar Grislis grislis at wisc dot edu 
    1747 */ 
    18 public class ColorizedImageParser { 
     48public class FittedImageParser { 
    1949    private static final Character CHI    = '\u03c7'; 
    2050    private static final Character SQUARE = '\u00b2'; 
     
    4474     * @param free whether each parameter is free or fixed 
    4575     */ 
    46     public ColorizedImageParser(String input, int components, boolean stretched, 
     76    public FittedImageParser(String input, int components, boolean stretched, 
    4777            boolean[] free) { 
    4878        _input = input; 
     
    6696     * @return  
    6797     */ 
    68     public ColorizedImageType[] getColorizedImages() { 
    69         List<ColorizedImageType> list = new ArrayList<ColorizedImageType>(); 
     98    public FittedImageType[] getColorizedImages() { 
     99        List<FittedImageType> list = new ArrayList<FittedImageType>(); 
    70100        String[] tokens = _input.split(" "); 
    71101        for (String token : tokens) { 
     
    75105                    case 1: 
    76106                        if (_free[A1_INDEX]) { 
    77                             list.add(ColorizedImageType.A1); 
     107                            list.add(FittedImageType.A1); 
    78108                        } 
    79109                        break; 
    80110                    case 2: 
    81111                        if (_free[A1_INDEX]) { 
    82                             list.add(ColorizedImageType.A1); 
     112                            list.add(FittedImageType.A1); 
    83113                        } 
    84114                        if (_free[A2_INDEX]) { 
    85                             list.add(ColorizedImageType.A2); 
     115                            list.add(FittedImageType.A2); 
    86116                        } 
    87117                        break; 
    88118                    case 3: 
    89119                        if (_free[A1_INDEX]) { 
    90                             list.add(ColorizedImageType.A1); 
     120                            list.add(FittedImageType.A1); 
    91121                        } 
    92122                        if (_free[A2_INDEX]) { 
    93                             list.add(ColorizedImageType.A2); 
     123                            list.add(FittedImageType.A2); 
    94124                        } 
    95125                        if (_free[A3_INDEX]) { 
    96                             list.add(ColorizedImageType.A3); 
     126                            list.add(FittedImageType.A3); 
    97127                        } 
    98128                        break; 
     
    103133                    case 1: 
    104134                        if (_free[T1_INDEX]) { 
    105                             list.add(ColorizedImageType.T1); 
     135                            list.add(FittedImageType.T1); 
    106136                        } 
    107137                        break; 
    108138                    case 2: 
    109139                        if (_free[T1_INDEX]) { 
    110                             list.add(ColorizedImageType.T1); 
     140                            list.add(FittedImageType.T1); 
    111141                        } 
    112142                        if (_free[T2_INDEX]) { 
    113                             list.add(ColorizedImageType.T2); 
     143                            list.add(FittedImageType.T2); 
    114144                        } 
    115145                        break; 
    116146                    case 3: 
    117147                        if (_free[T1_INDEX]) { 
    118                             list.add(ColorizedImageType.T1); 
     148                            list.add(FittedImageType.T1); 
    119149                        } 
    120150                        if (_free[T2_INDEX]) { 
    121                             list.add(ColorizedImageType.T2); 
     151                            list.add(FittedImageType.T2); 
    122152                        } 
    123153                        if (_free[T3_INDEX]) { 
    124                             list.add(ColorizedImageType.T3); 
     154                            list.add(FittedImageType.T3); 
    125155                        } 
    126156                        break; 
     
    129159            else if ("Z".equals(token)) { 
    130160                if (_free[Z_INDEX]) { 
    131                     list.add(ColorizedImageType.Z); 
     161                    list.add(FittedImageType.Z); 
    132162                } 
    133163            } 
    134164            else if ("X2".equals(token) || CHI_SQ_STRING.equals(token)) { 
    135                 list.add(ColorizedImageType.CHISQ); 
     165                list.add(FittedImageType.CHISQ); 
    136166            } 
    137167            else if ("H".equals(token)) { 
    138168                if (_stretched) { 
    139169                    if (_free[H_INDEX]) { 
    140                         list.add(ColorizedImageType.H); 
     170                        list.add(FittedImageType.H); 
    141171                    } 
    142172                } 
     
    145175                switch (_components) { 
    146176                    case 2: 
    147                         list.add(ColorizedImageType.F1); 
    148                         list.add(ColorizedImageType.F2); 
    149                         break; 
    150                     case 3: 
    151                         list.add(ColorizedImageType.F1); 
    152                         list.add(ColorizedImageType.F2); 
    153                         list.add(ColorizedImageType.F3); 
     177                        list.add(FittedImageType.F1); 
     178                        list.add(FittedImageType.F2); 
     179                        break; 
     180                    case 3: 
     181                        list.add(FittedImageType.F1); 
     182                        list.add(FittedImageType.F2); 
     183                        list.add(FittedImageType.F3); 
    154184                        break; 
    155185                } 
     
    158188                switch (_components) { 
    159189                    case 2: 
    160                         list.add(ColorizedImageType.f1); 
    161                         list.add(ColorizedImageType.f2); 
    162                         break; 
    163                     case 3: 
    164                         list.add(ColorizedImageType.f1); 
    165                         list.add(ColorizedImageType.f2); 
    166                         list.add(ColorizedImageType.f3); 
     190                        list.add(FittedImageType.f1); 
     191                        list.add(FittedImageType.f2); 
     192                        break; 
     193                    case 3: 
     194                        list.add(FittedImageType.f1); 
     195                        list.add(FittedImageType.f2); 
     196                        list.add(FittedImageType.f3); 
    167197                        break; 
    168198                } 
    169199            }         
    170200        } 
    171         return list.toArray(new ColorizedImageType[0]); 
     201        return list.toArray(new FittedImageType[0]); 
    172202    } 
    173203} 
  • trunk/projects/slim-plugin/src/main/java/loci/slim/fitting/images/FloatFittedImage.java

    r7970 r7994  
     1// 
     2// FloatFittedImage.java 
     3// 
     4 
    15/* 
    2  * To change this template, choose Tools | Templates 
    3  * and open the template in the editor. 
    4  */ 
     6SLIMPlugin for combined spectral-lifetime image analysis. 
     7 
     8Copyright (c) 2010, UW-Madison LOCI 
     9All rights reserved. 
     10 
     11Redistribution and use in source and binary forms, with or without 
     12modification, are permitted provided that the following conditions are met: 
     13    * Redistributions of source code must retain the above copyright 
     14      notice, this list of conditions and the following disclaimer. 
     15    * Redistributions in binary form must reproduce the above copyright 
     16      notice, this list of conditions and the following disclaimer in the 
     17      documentation and/or other materials provided with the distribution. 
     18    * Neither the name of the UW-Madison LOCI nor the 
     19      names of its contributors may be used to endorse or promote products 
     20      derived from this software without specific prior written permission. 
     21 
     22THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 
     23AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 
     24IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 
     25ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE 
     26LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 
     27CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 
     28SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 
     29INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 
     30CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 
     31ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 
     32POSSIBILITY OF SUCH DAMAGE. 
     33*/ 
     34 
    535package loci.slim.fitting.images; 
    636 
     
    1141 
    1242/** 
    13  * 
    14  * @author Aivar Grislis 
     43 *  
     44 * @author Aivar Grislis grislis at wisc dot edu 
    1545 */ 
    1646public class FloatFittedImage implements IColorizedFittedImage { 
  • trunk/projects/slim-plugin/src/main/java/loci/slim/fitting/images/FractionalContributionImage.java

    r7970 r7994  
     1// 
     2// FractionalContributionImage.java 
     3// 
     4 
    15/* 
    2  * To change this template, choose Tools | Templates 
    3  * and open the template in the editor. 
    4  */ 
     6SLIMPlugin for combined spectral-lifetime image analysis. 
     7 
     8Copyright (c) 2010, UW-Madison LOCI 
     9All rights reserved. 
     10 
     11Redistribution and use in source and binary forms, with or without 
     12modification, are permitted provided that the following conditions are met: 
     13    * Redistributions of source code must retain the above copyright 
     14      notice, this list of conditions and the following disclaimer. 
     15    * Redistributions in binary form must reproduce the above copyright 
     16      notice, this list of conditions and the following disclaimer in the 
     17      documentation and/or other materials provided with the distribution. 
     18    * Neither the name of the UW-Madison LOCI nor the 
     19      names of its contributors may be used to endorse or promote products 
     20      derived from this software without specific prior written permission. 
     21 
     22THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 
     23AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 
     24IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 
     25ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE 
     26LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 
     27CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 
     28SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 
     29INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 
     30CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 
     31ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 
     32POSSIBILITY OF SUCH DAMAGE. 
     33*/ 
     34 
    535package loci.slim.fitting.images; 
    636 
     
    838 
    939import loci.slim.IGrayScalePixelValue; 
    10 import loci.slim.fitting.images.AbstractBaseColorizedImage; 
     40import loci.slim.mask.IMaskGroup; 
    1141 
    1242/** 
     
    1545 * Fractional Contribution fi = Ai*Ti / sum of all Aj*Tj. 
    1646 * 
    17  * @author Aivar Grislis 
     47 * @author Aivar Grislis grislis at wisc dot edu 
    1848 */ 
    19 public class FractionalContributionImage extends AbstractBaseColorizedImage { 
     49public class FractionalContributionImage extends AbstractBaseFittedImage { 
    2050    private int _component; 
    2151    private int _components; 
     
    3363    public FractionalContributionImage(String title, int[] dimension, 
    3464            IndexColorModel indexColorModel, int component, int components, 
    35             boolean colorizeGrayScale, IGrayScalePixelValue grayScalePixelValue) { 
    36         super(title, dimension, indexColorModel, colorizeGrayScale, grayScalePixelValue); 
     65            boolean colorizeGrayScale, IGrayScalePixelValue grayScalePixelValue, 
     66            IMaskGroup[] maskGroup) { 
     67        super(title, dimension, indexColorModel, colorizeGrayScale, 
     68                grayScalePixelValue, maskGroup); 
    3769        _component = component; 
    3870        _components = components; 
     
    4476        switch (_components) { 
    4577            case 2: 
    46                 sum = parameters[ColorizedImageFitter.A1_INDEX] 
    47                         * parameters[ColorizedImageFitter.T1_INDEX] 
    48                         + parameters[ColorizedImageFitter.A2_INDEX] 
    49                         * parameters[ColorizedImageFitter.T2_INDEX]; 
     78                sum = parameters[FittedImageFitter.A1_INDEX] 
     79                        * parameters[FittedImageFitter.T1_INDEX] 
     80                        + parameters[FittedImageFitter.A2_INDEX] 
     81                        * parameters[FittedImageFitter.T2_INDEX]; 
    5082                switch (_component) { 
    5183                    case 0: 
    52                         value = parameters[ColorizedImageFitter.A1_INDEX] 
    53                                 * parameters[ColorizedImageFitter.T1_INDEX]; 
     84                        value = parameters[FittedImageFitter.A1_INDEX] 
     85                                * parameters[FittedImageFitter.T1_INDEX]; 
    5486                        break; 
    5587                    case 1: 
    56                         value = parameters[ColorizedImageFitter.A2_INDEX] 
    57                                 * parameters[ColorizedImageFitter.T2_INDEX]; 
     88                        value = parameters[FittedImageFitter.A2_INDEX] 
     89                                * parameters[FittedImageFitter.T2_INDEX]; 
    5890                        break; 
    5991                } 
    6092                break; 
    6193            case 3: 
    62                 sum = parameters[ColorizedImageFitter.A1_INDEX] 
    63                         * parameters[ColorizedImageFitter.T1_INDEX] 
    64                         + parameters[ColorizedImageFitter.A2_INDEX] 
    65                         * parameters[ColorizedImageFitter.T2_INDEX] 
    66                         + parameters[ColorizedImageFitter.A3_INDEX] 
    67                         * parameters[ColorizedImageFitter.T3_INDEX]; 
     94                sum = parameters[FittedImageFitter.A1_INDEX] 
     95                        * parameters[FittedImageFitter.T1_INDEX] 
     96                        + parameters[FittedImageFitter.A2_INDEX] 
     97                        * parameters[FittedImageFitter.T2_INDEX] 
     98                        + parameters[FittedImageFitter.A3_INDEX] 
     99                        * parameters[FittedImageFitter.T3_INDEX]; 
    68100                switch (_component) { 
    69101                    case 0: 
    70                         value = parameters[ColorizedImageFitter.A1_INDEX] 
    71                                 * parameters[ColorizedImageFitter.T1_INDEX]; 
     102                        value = parameters[FittedImageFitter.A1_INDEX] 
     103                                * parameters[FittedImageFitter.T1_INDEX]; 
    72104                        break; 
    73105                    case 1: 
    74                         value = parameters[ColorizedImageFitter.A2_INDEX] 
    75                                 * parameters[ColorizedImageFitter.T2_INDEX]; 
     106                        value = parameters[FittedImageFitter.A2_INDEX] 
     107                                * parameters[FittedImageFitter.T2_INDEX]; 
    76108                        break; 
    77109                    case 2: 
    78                         value = parameters[ColorizedImageFitter.A3_INDEX] 
    79                                 * parameters[ColorizedImageFitter.T3_INDEX]; 
     110                        value = parameters[FittedImageFitter.A3_INDEX] 
     111                                * parameters[FittedImageFitter.T3_INDEX]; 
    80112                        break; 
    81113                } 
  • trunk/projects/slim-plugin/src/main/java/loci/slim/fitting/images/FractionalIntensityImage.java

    r7970 r7994  
     1// 
     2// FractionalIntensityImage.java 
     3// 
     4 
    15/* 
    2  * To change this template, choose Tools | Templates 
    3  * and open the template in the editor. 
    4  */ 
     6SLIMPlugin for combined spectral-lifetime image analysis. 
     7 
     8Copyright (c) 2010, UW-Madison LOCI 
     9All rights reserved. 
     10 
     11Redistribution and use in source and binary forms, with or without 
     12modification, are permitted provided that the following conditions are met: 
     13    * Redistributions of source code must retain the above copyright 
     14      notice, this list of conditions and the following disclaimer. 
     15    * Redistributions in binary form must reproduce the above copyright 
     16      notice, this list of conditions and the following disclaimer in the 
     17      documentation and/or other materials provided with the distribution. 
     18    * Neither the name of the UW-Madison LOCI nor the 
     19      names of its contributors may be used to endorse or promote products 
     20      derived from this software without specific prior written permission. 
     21 
     22THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 
     23AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 
     24IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 
     25ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE 
     26LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 
     27CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 
     28SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 
     29INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 
     30CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 
     31ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 
     32POSSIBILITY OF SUCH DAMAGE. 
     33*/ 
     34 
    535package loci.slim.fitting.images; 
    636 
     
    838 
    939import loci.slim.IGrayScalePixelValue; 
    10 import loci.slim.fitting.images.AbstractBaseColorizedImage; 
     40import loci.slim.mask.IMaskGroup; 
    1141 
    1242/** 
     
    1747 * @author Aivar Grislis 
    1848 */ 
    19 public class FractionalIntensityImage extends AbstractBaseColorizedImage { 
     49public class FractionalIntensityImage extends AbstractBaseFittedImage { 
    2050    private int _component; 
    2151    private int _components; 
     
    3363    public FractionalIntensityImage(String title, int[] dimension, 
    3464            IndexColorModel indexColorModel, int component, int components, 
    35             boolean colorizeGrayScale, IGrayScalePixelValue grayScalePixelValue) { 
    36         super(title, dimension, indexColorModel, colorizeGrayScale, grayScalePixelValue); 
     65            boolean colorizeGrayScale, IGrayScalePixelValue grayScalePixelValue, 
     66            IMaskGroup[] maskGroup) { 
     67        super(title, dimension, indexColorModel, colorizeGrayScale, 
     68                grayScalePixelValue, maskGroup); 
    3769        _component = component; 
    3870        _components = components; 
     
    4476        switch (_components) { 
    4577            case 2: 
    46                 sum = parameters[ColorizedImageFitter.A1_INDEX] 
    47                         + parameters[ColorizedImageFitter.A2_INDEX]; 
     78                sum = parameters[FittedImageFitter.A1_INDEX] 
     79                        + parameters[FittedImageFitter.A2_INDEX]; 
    4880                switch (_component) { 
    4981                    case 0: 
    50                         value = parameters[ColorizedImageFitter.A1_INDEX]; 
     82                        value = parameters[FittedImageFitter.A1_INDEX]; 
    5183                        break; 
    5284                    case 1: 
    53                         value = parameters[ColorizedImageFitter.A2_INDEX];; 
     85                        value = parameters[FittedImageFitter.A2_INDEX];; 
    5486                        break; 
    5587                } 
    5688                break; 
    5789            case 3: 
    58                 sum = parameters[ColorizedImageFitter.A1_INDEX] 
    59                         + parameters[ColorizedImageFitter.A2_INDEX] 
    60                         + parameters[ColorizedImageFitter.A3_INDEX]; 
     90                sum = parameters[FittedImageFitter.A1_INDEX] 
     91                        + parameters[FittedImageFitter.A2_INDEX] 
     92                        + parameters[FittedImageFitter.A3_INDEX]; 
    6193                switch (_component) { 
    6294                    case 0: 
    63                         value = parameters[ColorizedImageFitter.A1_INDEX]; 
     95                        value = parameters[FittedImageFitter.A1_INDEX]; 
    6496                        break; 
    6597                    case 1: 
    66                         value = parameters[ColorizedImageFitter.A2_INDEX]; 
     98                        value = parameters[FittedImageFitter.A2_INDEX]; 
    6799                        break; 
    68100                    case 2: 
    69                         value = parameters[ColorizedImageFitter.A3_INDEX]; 
     101                        value = parameters[FittedImageFitter.A3_INDEX]; 
    70102                        break; 
    71103                } 
  • trunk/projects/slim-plugin/src/main/java/loci/slim/fitting/images/IColorizedFittedImage.java

    r7970 r7994  
     1// 
     2// IColorizedFittedImage.java 
     3// 
     4 
    15/* 
    2  * To change this template, choose Tools | Templates 
    3  * and open the template in the editor. 
    4  */ 
     6SLIMPlugin for combined spectral-lifetime image analysis. 
     7 
     8Copyright (c) 2010, UW-Madison LOCI 
     9All rights reserved. 
     10 
     11Redistribution and use in source and binary forms, with or without 
     12modification, are permitted provided that the following conditions are met: 
     13    * Redistributions of source code must retain the above copyright 
     14      notice, this list of conditions and the following disclaimer. 
     15    * Redistributions in binary form must reproduce the above copyright 
     16      notice, this list of conditions and the following disclaimer in the 
     17      documentation and/or other materials provided with the distribution. 
     18    * Neither the name of the UW-Madison LOCI nor the 
     19      names of its contributors may be used to endorse or promote products 
     20      derived from this software without specific prior written permission. 
     21 
     22THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 
     23AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 
     24IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 
     25ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE 
     26LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 
     27CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 
     28SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 
     29INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 
     30CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 
     31ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 
     32POSSIBILITY OF SUCH DAMAGE. 
     33*/ 
     34 
    535package loci.slim.fitting.images; 
    636 
     
    1141/** 
    1242 * 
    13  * @author aivar 
     43 * @author Aivar Grislis grislis at wisc dot edu 
    1444 */ 
    1545public interface IColorizedFittedImage { 
  • trunk/projects/slim-plugin/src/main/java/loci/slim/fitting/images/IFittedImage.java

    r7889 r7994  
     1// 
     2// IFittedImage.java 
     3// 
     4 
    15/* 
    2  * To change this template, choose Tools | Templates 
    3  * and open the template in the editor. 
    4  */ 
     6SLIMPlugin for combined spectral-lifetime image analysis. 
     7 
     8Copyright (c) 2010, UW-Madison LOCI 
     9All rights reserved. 
     10 
     11Redistribution and use in source and binary forms, with or without 
     12modification, are permitted provided that the following conditions are met: 
     13    * Redistributions of source code must retain the above copyright 
     14      notice, this list of conditions and the following disclaimer. 
     15    * Redistributions in binary form must reproduce the above copyright 
     16      notice, this list of conditions and the following disclaimer in the 
     17      documentation and/or other materials provided with the distribution. 
     18    * Neither the name of the UW-Madison LOCI nor the 
     19      names of its contributors may be used to endorse or promote products 
     20      derived from this software without specific prior written permission. 
     21 
     22THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 
     23AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 
     24IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 
     25ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE 
     26LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 
     27CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 
     28SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 
     29INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 
     30CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 
     31ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 
     32POSSIBILITY OF SUCH DAMAGE. 
     33*/ 
    534 
    635package loci.slim.fitting.images; 
     
    837import java.awt.image.IndexColorModel; 
    938 
    10 import loci.slim.histogram.HistogramData; 
     39import loci.slim.histogram.HistogramDataGroup; 
    1140 
    1241/** 
    1342 * 
    14  * @author Aivar Grislis 
     43 * @author Aivar Grislis grislis at wisc dot edu 
    1544 */ 
    16 public interface IColorizedImage { 
     45public interface IFittedImage { 
    1746     
    1847    /** 
     
    3564     * @return 
    3665     */ 
    37     public HistogramData getHistogramData(); 
     66    public HistogramDataGroup getHistogramData(); 
    3867 
    3968    /** 
  • trunk/projects/slim-plugin/src/main/java/loci/slim/fitting/images/SimpleFittedImage.java

    r7970 r7994  
     1// 
     2// SimpleFittedImage.java 
     3// 
     4 
    15/* 
    2  * To change this template, choose Tools | Templates 
    3  * and open the template in the editor. 
    4  */ 
     6SLIMPlugin for combined spectral-lifetime image analysis. 
     7 
     8Copyright (c) 2010, UW-Madison LOCI 
     9All rights reserved. 
     10 
     11Redistribution and use in source and binary forms, with or without 
     12modification, are permitted provided that the following conditions are met: 
     13    * Redistributions of source code must retain the above copyright 
     14      notice, this list of conditions and the following disclaimer. 
     15    * Redistributions in binary form must reproduce the above copyright 
     16      notice, this list of conditions and the following disclaimer in the 
     17      documentation and/or other materials provided with the distribution. 
     18    * Neither the name of the UW-Madison LOCI nor the 
     19      names of its contributors may be used to endorse or promote products 
     20      derived from this software without specific prior written permission. 
     21 
     22THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 
     23AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 
     24IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 
     25ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE 
     26LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 
     27CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 
     28SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 
     29INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 
     30CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 
     31ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 
     32POSSIBILITY OF SUCH DAMAGE. 
     33*/ 
     34 
    535package loci.slim.fitting.images; 
    636 
     
    838 
    939import loci.slim.IGrayScalePixelValue; 
     40import loci.slim.mask.IMaskGroup; 
    1041 
    1142/** 
    1243 * Simple image that just displays one of the input parameters. 
    1344 * 
    14  * @author Aivar Grislis 
     45 * @author Aivar Grislis grislis at wisc dot edu 
    1546 */ 
    16 public class ColorizedImage extends AbstractBaseColorizedImage { 
     47public class SimpleFittedImage extends AbstractBaseFittedImage { 
    1748    private int _parameterIndex; 
    1849 
     
    2455     * @param parameterIndex 
    2556     */ 
    26     public ColorizedImage(String title, int[] dimension, 
     57    public SimpleFittedImage(String title, int[] dimension, 
    2758            IndexColorModel indexColorModel, int parameterIndex, 
    28             boolean colorizeGrayScale, IGrayScalePixelValue grayScalePixelValue) { 
    29         super(title, dimension, indexColorModel, colorizeGrayScale, grayScalePixelValue); 
     59            boolean colorizeGrayScale, IGrayScalePixelValue grayScalePixelValue, 
     60            IMaskGroup[] maskGroup) { 
     61        super(title, dimension, indexColorModel, colorizeGrayScale, 
     62                grayScalePixelValue, maskGroup); 
    3063        _parameterIndex = parameterIndex; 
    3164    } 
  • trunk/projects/slim-plugin/src/main/java/loci/slim/histogram/HistogramDataGroup.java

    r7992 r7994  
    3535package loci.slim.histogram; 
    3636 
    37 import loci.slim.fitting.images.IColorizedImage; 
     37import loci.slim.fitting.images.IFittedImage; 
     38import loci.slim.mask.IMaskGroup; 
    3839 
    3940/** 
    40  * Keeps an array of HistogramChannels for a given image.  Builds the  
     41 * Keeps an array of HistogramDataNodes for a given image.  Builds the  
    4142 * histogram data as appropriate.  Handles updates as the fitted results are 
    42  * available.  Handles optional autoranging. 
     43 * available.  Handles optional auto-ranging. 
    4344 *  
    4445 * @author Aivar Grislis grislis at wisc dot edu 
    4546 */ 
    46 public class HistogramData { 
    47     private IColorizedImage _image; 
     47public class HistogramDataGroup { 
     48    private IFittedImage _image; 
    4849    private String _title; 
    49     private HistogramDataChannel[] _channel; 
     50    private HistogramDataNode[] _channel; 
    5051    private int _channelIndex; 
    5152    private boolean _autoRange; 
     53    private boolean _excludePixels; 
    5254    private boolean _combineChannels; 
    5355    private boolean _displayChannels; 
     
    6769     * @param channel  
    6870     */ 
    69     public HistogramData(IColorizedImage image, String title, 
    70             HistogramDataChannel[] channel) { 
     71    public HistogramDataGroup(IFittedImage image, String title, 
     72            HistogramDataNode[] channel) { 
    7173        _image = image; 
    7274        _title = title; 
    7375        _channel = channel; 
    7476        _autoRange = true; 
     77        _excludePixels = false; 
    7578        _combineChannels = hasChannels(); 
    7679        _displayChannels = hasChannels(); 
     
    9194        _listener = listener; 
    9295    } 
    93       
     96 
    9497    /** 
    9598     * Gets a descriptive title to display on histogram UI for this data. 
     
    135138    public void setAutoRange(boolean autoRange) { 
    136139        update(autoRange, _combineChannels); 
     140    } 
     141 
     142    /** 
     143     * Sets whether or not we should hide out-of-range pixels. 
     144     *  
     145     * @param excludePixels  
     146     */ 
     147    public void setExcludePixels(boolean excludePixels) { 
     148        _excludePixels = excludePixels; 
     149    } 
     150 
     151    /** 
     152     * Sets whether or not we should hide out-of-range pixels. 
     153     *  
     154     * @return  
     155     */ 
     156    public boolean getExcludePixels() { 
     157        return _excludePixels; 
    137158    } 
    138159     
     
    276297        redisplay(); 
    277298    } 
     299     
     300    //TODO 
     301    // this is setting exclude pixels on/off once you are viewing the histogram 
     302    // if you click on another image and the histogram shows data for that image 
     303    // that doesn't necessarily trigger mask propagation. 
     304    // 
     305    // Note that this is just setting up pixel masking for one channel.  Shouldn't 
     306    // this pertain to all channels?  (With different mask for each channel). 
     307    // The other UI is not channel-specific, so neither should this checkbox be. 
     308    // When/if we do have different LUTs for each channel this will get even more 
     309    // complicated. 
     310    // 
     311    // Note also that if this is to work during the fit process it gets more 
     312    // complicated.  As more and more pixels are drawn, we need to build newer 
     313    // exclusion masks and propagate them. 
     314     
     315    public void excludePixels(boolean excludePixels) { 
     316        setExcludePixels(excludePixels); 
     317        if (excludePixels) { 
     318            _channel[_channelIndex].propagateMask(_minLUT, _maxLUT); 
     319        } 
     320        else { 
     321            _channel[_channelIndex].rescindMask(); 
     322        } 
     323    } 
    278324 
    279325    /** 
  • trunk/projects/slim-plugin/src/main/java/loci/slim/histogram/HistogramDataNode.java

    r7992 r7994  
    3535package loci.slim.histogram; 
    3636 
     37import loci.slim.mask.IMaskGroup; 
     38import loci.slim.mask.IMaskNode; 
     39import loci.slim.mask.IMaskNodeListener; 
     40import loci.slim.mask.Mask; 
     41import loci.slim.mask.MaskGroup; 
     42import loci.slim.mask.MaskNode; 
     43 
    3744/** 
    3845 * This class shadows a channel in a stack for a displayed image.  If the image 
     
    4148 * @author Aivar Grislis grislis at wisc dot edu 
    4249 */ 
    43 public class HistogramDataChannel { 
     50public class HistogramDataNode { 
    4451    private double[][] _values; 
    45     private double _minLUT; 
    46     private double _maxLUT; 
     52    private IMaskNode _maskNode; 
     53    private Mask _selfMask; 
     54    private Mask _otherMask; 
     55    private Mask _totalMask; 
    4756 
    4857    /** 
     
    5867     * @param values  
    5968     */ 
    60     public HistogramDataChannel(double[][] values) { 
     69    public HistogramDataNode(double[][] values) { 
    6170        _values = values; 
     71    } 
     72     
     73    public void setMaskGroup(IMaskGroup maskGroup) { 
     74        _maskNode = new MaskNode(maskGroup, new IMaskNodeListener () { 
     75            public void updateMask(Mask mask) { 
     76                System.out.println("HistogramDataNode.setMaskGroup IMaskNodeListener.updateMask " + mask); 
     77                setOtherMask(mask); 
     78                //TODO redraw, here or in setOtherMask() 
     79            } 
     80        }); 
    6281    } 
    6382 
     
    7089        return _values; 
    7190    } 
    72  
    73     /** 
    74      * This class is also a container for minimum and maximum LUT values.  These 
    75      * only apply when the LUT is not autoranging and each channel has its own 
    76      * values. 
    77      *  
    78      * @return  
    79      */ 
    80     public double[] getMinMaxLUT() { 
    81         return new double[] { _minLUT, _maxLUT }; 
    82     } 
    83   
    84     /** 
    85      * Sets the minimum and maximum LUT values. 
    86      *  
    87      * @param min 
    88      * @param max  
    89      */ 
    90     public void setMinMaxLUT(double min, double max) { 
    91         _minLUT = min; 
    92         _maxLUT = max; 
     91     
     92    /** 
     93     * Gets the current other mask, which masks pixels hidden by others. 
     94     *  
     95     * @return mask or null 
     96     */ 
     97    public Mask getOtherMask() { 
     98        return _otherMask; 
     99    } 
     100 
     101    /** 
     102     * Sets the current other mask, which masks pixels hidden by others. 
     103     *  
     104     * @param mask or null 
     105     */ 
     106    public void setOtherMask(Mask mask) { 
     107        System.out.print("incoming other mask " + mask); 
     108        if (null != mask) System.out.print(" excludes " + countBits(mask.getBits())); 
     109        System.out.println(); 
     110         
     111        _otherMask = mask; 
     112        if (null == _selfMask) { 
     113            _totalMask = mask; 
     114        } 
     115        else { 
     116            _totalMask = _selfMask.add(mask); 
     117        } 
     118         
     119        System.out.print("I am " + this + " setOtherMask, total mask " + _totalMask); 
     120        if (null != _totalMask) System.out.print(" excludes " + countBits(_totalMask.getBits())); 
     121        System.out.println(); 
     122    } 
     123 
     124    /** 
     125     * Gets the current self mask, which masks pixels hidden by self. 
     126     *  
     127     * @return mask or null 
     128     */ 
     129    public Mask getSelfMask() { 
     130        return _selfMask; 
     131    } 
     132 
     133    /** 
     134     * Sets the current self mask, which masks pixels hidden by self. 
     135     *  
     136     * @param mask or null 
     137     */ 
     138    public void setSelfMask(Mask mask) { 
     139        _selfMask = mask; 
     140        if (null == mask) { 
     141            _totalMask = _otherMask; 
     142        } 
     143        else { 
     144            _totalMask = mask.add(_otherMask); 
     145        } 
     146 
     147        System.out.println("I am " + this + " setSelfMask, total mask excludes " + countBits(_totalMask.getBits())); 
     148    } 
     149     
     150    public int countBits(boolean[][] bits) { 
     151        int counter = 0; 
     152        if (null != bits) { 
     153            for (int y = 0; y < bits[0].length; ++y) { 
     154                for (int x = 0; x < bits.length; ++x) { 
     155                    if (!bits[x][y]) ++counter; 
     156                } 
     157            } 
     158        } 
     159        return counter; 
    93160    } 
    94161 
     
    96163     * Finds the actual minimum and maximum values. 
    97164     * Called initially and after values change. 
     165     *  
     166     * This will exclude pixels masked by self or others. 
    98167     *  
    99168     * @return array of { min, max } 
     
    104173        for (int i = 0; i < _values.length; ++i) { 
    105174            for (int j = 0; j < _values[0].length; ++j) { 
    106                 if (!Double.isNaN(_values[i][j])) { 
    107                     if (_values[i][j] < min) { 
    108                         min = _values[i][j]; 
    109                     } 
    110                     if (_values[i][j] > max) { 
    111                         max = _values[i][j]; 
    112                     } 
     175                if (null == _totalMask || _totalMask.test(i, j)) { 
     176                    if (!Double.isNaN(_values[i][j])) { 
     177                        if (_values[i][j] < min) { 
     178                            min = _values[i][j]; 
     179                        } 
     180                        if (_values[i][j] > max) { 
     181                            max = _values[i][j]; 
     182                        } 
     183                    }  
    113184                } 
    114185            } 
     
    120191     * Creates an array of histogram values based on the current nominal min/max 
    121192     * range. 
     193     *  
     194     * This histogram array should exclude pixels masked by others but not by 
     195     * self. 
    122196     *  
    123197     * @param bins number of bins 
     
    131205            results[i] = 0; 
    132206        } 
    133         //TODOdouble binWidth = bins / (nominalMax - nominalMin); I think this might be losing the last bin //TODO no, still loses the last bin, on gpl1.sdt T1 
     207        double inverseBinWidth = bins / (nominalMax - nominalMin); 
    134208        for (int i = 0; i < _values.length; ++i) { 
    135209            for (int j = 0; j < _values[0].length; ++j) { 
    136                 double value = _values[i][j]; 
    137                 if (value >= nominalMin && value <= nominalMax) { 
    138                     // assign each value to a bin 
    139                     int bin = (int)((value - nominalMin) * bins / (nominalMax - nominalMin)); //TODO binWidth); 
    140                     if (bin >= bins) { 
    141                         --bin; 
     210                if (null == _otherMask || _otherMask.test(i, j)) { 
     211                    double value = _values[i][j]; 
     212                    if (value >= nominalMin && value <= nominalMax) { 
     213                        // assign each value to a bin 
     214                        int bin = (int)((value - nominalMin) * inverseBinWidth); 
     215                        if (bin >= bins) { 
     216                            --bin; 
     217                        } 
     218                        ++results[bin]; 
     219                    }  
     220                } 
     221            } 
     222        } 
     223        return results; 
     224    } 
     225 
     226    /** 
     227     * Builds a mask based on which values are within the LUT range and sends it 
     228     * out to peer nodes. 
     229     *  
     230     * @return  
     231     */ 
     232    public void propagateMask(double minLUT, double maxLUT) { 
     233        boolean masked = false; 
     234        int width = _values.length; 
     235        int height = _values[0].length; 
     236        boolean[][] bits = new boolean[width][height]; 
     237        for (int y = 0; y < height; ++y) { 
     238            for (int x = 0; x < width; ++x) { 
     239                Double value = _values[x][y]; 
     240                bits[x][y] = false; 
     241                if (!value.isNaN()) { 
     242                    if (minLUT <= value && value <= maxLUT) { 
     243                        // in range, include this pixel 
     244                        bits[x][y] = true; 
    142245                    } 
    143                     ++results[bin]; 
    144                 } 
    145             } 
    146         } 
    147         return results; 
    148     }    
     246                    else { 
     247                        // we did just mask out a pixel 
     248                        masked = true; 
     249                    } 
     250                } 
     251            } 
     252        } 
     253        Mask selfMask = null; 
     254        if (masked) { 
     255            selfMask = new Mask(bits); 
     256        } 
     257 
     258        System.out.println("HistogramDataNode.propagateMask " + selfMask); 
     259        setSelfMask(selfMask); 
     260        _maskNode.updateSelfMask(selfMask); 
     261    } 
     262 
     263    /** 
     264     * Deletes our mask. 
     265     *  
     266     */ 
     267    public void rescindMask() { 
     268        Mask selfMask = null; 
     269         
     270        System.out.println("HistogramDataNode.rescindMask"); 
     271        setSelfMask(selfMask); 
     272        _maskNode.updateSelfMask(selfMask); 
     273    } 
    149274} 
  • trunk/projects/slim-plugin/src/main/java/loci/slim/histogram/HistogramPanel.java

    r7992 r7994  
    246246     */ 
    247247    public void setCursors(Integer minCursor, Integer maxCursor) { 
    248         System.out.println("setCursors(" + minCursor + "," + maxCursor); 
    249248        synchronized (_synchObject) { 
    250249            if (null == minCursor) { 
  • trunk/projects/slim-plugin/src/main/java/loci/slim/histogram/HistogramTool.java

    r7992 r7994  
    6767    private final Object _synchObject = new Object(); 
    6868    private JFrame _frame; 
    69     private HistogramData _histogramData; 
     69    private HistogramDataGroup _histogramDataGroup; 
    7070    private HistogramPanel _histogramPanel; 
    7171    private ColorBarPanel _colorBarPanel; 
    72     private UIPanel _uiPanel; 
     72    private HistogramUIPanel _uiPanel; 
    7373  
    7474    /** 
     
    8484        _colorBarPanel.setLUT(getLUT()); 
    8585        boolean hasChannels = false; 
    86         _uiPanel = new UIPanel(hasChannels); 
     86        _uiPanel = new HistogramUIPanel(hasChannels); 
    8787        _uiPanel.setListener(new UIPanelListener()); 
    8888 
     
    168168     * @param histogramData  
    169169     */ 
    170     public void setHistogramData(HistogramData histogramData) { 
     170    public void setHistogramData(HistogramDataGroup histogramData) { 
    171171        double[] minMaxView; 
    172172        double[] minMaxLUT; 
    173173        synchronized (_synchObject) { 
    174             _histogramData = histogramData; 
    175             _histogramData.setListener(new HistogramDataListener()); 
    176             minMaxView = _histogramData.getMinMaxView(); 
    177             minMaxLUT  = _histogramData.getMinMaxLUT(); 
     174            _histogramDataGroup = histogramData; 
     175            _histogramDataGroup.setListener(new HistogramDataListener()); 
     176            minMaxView = _histogramDataGroup.getMinMaxView(); 
     177            minMaxLUT  = _histogramDataGroup.getMinMaxLUT(); 
    178178        } 
    179179         
     
    184184         
    185185        _histogramPanel.setBins(histogramData.binValues(WIDTH)); 
    186         _histogramPanel.setCursors(cursorPixelFromValue(false, minMaxLUT[0]), cursorPixelFromValue(false, minMaxLUT[1])); //TODO ARG true, maxLUT)); in this case adding 1 to max is too much! 
    187186  
    188         _uiPanel.setAutoRange(histogramData.getAutoRange()); 
     187        boolean autoRange = histogramData.getAutoRange(); 
     188        _uiPanel.setAutoRange(autoRange); 
     189        if (!autoRange) { 
     190            _histogramPanel.setCursors(cursorPixelFromValue 
     191                    (false, minMaxLUT[0]), cursorPixelFromValue(false, minMaxLUT[1])); //TODO ARG true, maxLUT)); in this case adding 1 to max is too much! 
     192        }         
     193        _uiPanel.setExcludePixels(histogramData.getExcludePixels()); 
    189194        _uiPanel.setCombineChannels(histogramData.getCombineChannels()); 
    190195        _uiPanel.setDisplayChannels(histogramData.getDisplayChannels()); 
     
    201206    private double pixelToValue(int pixel) { 
    202207        synchronized (_synchObject) { 
    203             double[] minMaxView = _histogramData.getMinMaxView(); 
     208            double[] minMaxView = _histogramDataGroup.getMinMaxView(); 
    204209            double min = minMaxView[0]; 
    205210            return min + pixelToValueRelative(pixel); 
     
    209214    private double pixelToValueRelative(int pixel) { 
    210215        synchronized (_synchObject) { 
    211             double[] minMaxView = _histogramData.getMinMaxView(); 
     216            double[] minMaxView = _histogramDataGroup.getMinMaxView(); 
    212217            double min = minMaxView[0]; 
    213218            double max = minMaxView[1]; 
     
    222227    private int valueToPixel(double value) { 
    223228        synchronized (_synchObject) { 
    224             double[] minMaxView = _histogramData.getMinMaxView(); 
     229            double[] minMaxView = _histogramDataGroup.getMinMaxView(); 
    225230            double min = minMaxView[0]; 
    226231            double max = minMaxView[1]; 
     
    236241                double minLUT, double maxLUT) { 
    237242        synchronized (_synchObject) { 
    238             int[] bins = _histogramData.binValues(WIDTH); 
     243            int[] bins = _histogramDataGroup.binValues(WIDTH); 
    239244            _histogramPanel.setBins(bins); 
    240245            _colorBarPanel.setMinMax(minView, maxView, minLUT, maxLUT); 
     
    245250            // iii) in the future more UI interactions will wind up here 
    246251            // 
    247             _histogramData.redisplay(); 
     252            _histogramDataGroup.redisplay(); 
    248253        } 
    249254    } 
     
    307312            // save and redraw image 
    308313            synchronized (_synchObject) { 
    309                 _histogramData.setMinMaxLUT(minLUT, maxLUT); 
     314                _histogramDataGroup.setMinMaxLUT(minLUT, maxLUT); 
    310315            } 
    311316        } 
     
    369374                synchronized (_synchObject) { 
    370375                    // get current LUT bounds 
    371                     double[] minMaxLUT = _histogramData.getMinMaxLUT(); 
     376                    double[] minMaxLUT = _histogramDataGroup.getMinMaxLUT(); 
    372377                    double minLUT = minMaxLUT[0]; 
    373378                    double maxLUT = minMaxLUT[1]; 
    374379 
    375380                    // adjust the appropriate left or right side of the view 
    376                     double[] minMaxView = _histogramData.getMinMaxView(); 
     381                    double[] minMaxView = _histogramDataGroup.getMinMaxView(); 
    377382                    double minView = minMaxView[0]; 
    378383                    double maxView = minMaxView[1]; 
     
    387392 
    388393                    // update histogram data min and max view 
    389                     _histogramData.setMinMaxView(minView, maxView); 
     394                    _histogramDataGroup.setMinMaxView(minView, maxView); 
    390395                     
    391396                    // keep other cursor fixed 
     
    412417                     
    413418                    // get updated histogram data and show it                  
    414                     int[] bins = _histogramData.binValues(PaletteFix.ADJUSTED_SIZE); 
     419                    int[] bins = _histogramDataGroup.binValues(WIDTH); 
    415420                    _histogramPanel.setBins(bins); 
    416421                    _colorBarPanel.setMinMax(minView, maxView, minLUT, maxLUT); 
     
    427432        public void setAutoRange(boolean autoRange) { 
    428433            synchronized (_synchObject) { 
    429                  _histogramData.setAutoRange(autoRange); 
     434                 _histogramDataGroup.setAutoRange(autoRange); 
    430435                  
    431436                 if (autoRange) { 
    432437                     //TODO ARG: 
    433438                    // It is not always true that the cursors will be (null, null) 
    434                     // [same as (0, 254)], th3 exception happens if you are showing 
     439                    // [same as (0, 254)], the exception happens if you are showing 
    435440                    // all channels but only autoranging your channel. 
    436441                    _histogramPanel.setCursors(null, null); 
     
    451456            //TODO ARG Mask selfMask = null; 
    452457            synchronized (_synchObject) { 
    453                 if (excludePixels) { 
    454  
    455                 } 
    456                 else { 
    457  
    458                 } 
     458                _histogramDataGroup.excludePixels(excludePixels); 
    459459                //TODO ARG 
    460460                System.out.println("set exclude pixels " + excludePixels); 
     
    465465        public void setCombineChannels(boolean combineChannels) { 
    466466            synchronized (_synchObject) { 
    467                 _histogramData.setCombineChannels(combineChannels); 
     467                _histogramDataGroup.setCombineChannels(combineChannels); 
    468468            } 
    469469            //TODO 
     
    474474        public void setDisplayChannels(boolean displayChannels) { 
    475475            synchronized (_synchObject) { 
    476                 _histogramData.setDisplayChannels(displayChannels); 
     476                _histogramDataGroup.setDisplayChannels(displayChannels); 
    477477                 
    478478                // get updated histogram data and show it                  
    479                 int[] bins = _histogramData.binValues(PaletteFix.ADJUSTED_SIZE); 
     479                int[] bins = _histogramDataGroup.binValues(WIDTH); 
    480480                _histogramPanel.setBins(bins); 
    481481            } 
     
    497497                synchronized (_synchObject) { 
    498498                    // if necessary, expand the view to fit the LUT 
    499                     double[] minMaxView = _histogramData.getMinMaxView(); 
     499                    double[] minMaxView = _histogramDataGroup.getMinMaxView(); 
    500500                    minView = Math.min(minLUT, minMaxView[0]); 
    501501                    maxView = Math.max(maxLUT, minMaxView[1]); 
    502                     _histogramData.setMinMaxView(minView, maxView); 
    503                     _histogramData.setMinMaxLUT(minLUT, maxLUT); 
     502                    _histogramDataGroup.setMinMaxView(minView, maxView); 
     503                    _histogramDataGroup.setMinMaxLUT(minLUT, maxLUT); 
    504504 
    505505                    //TODO ARG this is quite a bit off: 
  • trunk/projects/slim-plugin/src/main/java/loci/slim/histogram/HistogramUIPanel.java

    r7992 r7994  
    5656 * @author Aivar Grislis grislis at wisc dot edu 
    5757 */ 
    58 public class UIPanel extends JPanel { 
     58public class HistogramUIPanel extends JPanel { 
    5959    private static final String AUTO_RANGING = "Adjust range to min/max values"; 
    6060    private static final String EXCLUDE_PIXELS = "Hide pixels outside range"; 
     
    8282     * @param hasChannels 
    8383     */ 
    84     public UIPanel(boolean hasChannels) { 
     84    public HistogramUIPanel(boolean hasChannels) { 
    8585        super(); 
    8686 
     
    267267 
    268268    /** 
     269     * Sets whether to hide out of range pixels. 
     270     *  
     271     * @param excludePixels  
     272     */ 
     273    public void setExcludePixels(boolean excludePixels) { 
     274        _excludePixels = excludePixels; 
     275        _excludePixelsCheckBox.setSelected(excludePixels); 
     276    } 
     277 
     278    /** 
    269279     * Sets whether to combine all channels. 
    270280     *  
  • trunk/projects/slim-plugin/src/main/java/loci/slim/mask/Mask.java

    r7992 r7994  
    108108     */ 
    109109    public Mask add(Mask mask) { 
     110        if (null == mask) { 
     111            return this; 
     112        } 
     113         
    110114        boolean[][] bits = mask.getBits(); 
    111115        int width = bits[0].length; 
     
    124128     * specified to be excluded. 
    125129     *  
     130     * Having this be part of the Mask class hides implementation details. 
     131     *  
    126132     * @param excludedMask 
    127133     * @param masks 
    128      * @return  
     134     * @return mask or null 
    129135     */ 
    130136    public static Mask addOtherMasks(Mask excludedMask, Collection<Mask> masks) { 
    131         boolean[][] result = null; 
    132         int width = 0; 
    133         int height = 0; 
    134         for (Mask mask : masks) { 
    135             if (mask != excludedMask) { 
    136                 boolean[][] addition = mask.getBits(); 
    137                 if (null != addition) { 
    138                     if (null == result) { 
    139                         result = mask.getBits().clone(); 
    140                         width = result[0].length; 
    141                         height = result.length; 
    142                     } 
    143                     else { 
    144                         for (int x = 0; x < width; ++x) { 
    145                             for (int y = 0; y < height; ++y) { 
    146                                 result[x][y] = result[x][y] && addition[x][y]; 
     137        Mask returnValue = null; 
     138        if (!masks.isEmpty()) { 
     139            boolean[][] result = null; 
     140            int width = 0; 
     141            int height = 0; 
     142            for (Mask mask : masks) { 
     143                if (null != mask) { 
     144                    if (mask != excludedMask) { 
     145                        boolean[][] addition = mask.getBits(); 
     146                        if (null != addition) { 
     147                            // lazy initialization of results 
     148                            if (null == result) { 
     149                                result = mask.getBits().clone(); 
     150                                width  = result[0].length; 
     151                                height = result.length; 
     152                            } 
     153                            for (int x = 0; x < width; ++x) { 
     154                                for (int y = 0; y < height; ++y) { 
     155                                    result[x][y] = result[x][y] && addition[x][y]; 
     156                                } 
    147157                            } 
    148158                        } 
     
    150160                } 
    151161            } 
     162            if (null != result) { 
     163                returnValue = new Mask(result); 
     164            } 
    152165        } 
    153         return new Mask(result); 
     166        else { 
     167            System.out.println("masks is empty"); 
     168        } 
     169        return returnValue; 
    154170    } 
    155171} 
  • trunk/projects/slim-plugin/src/main/java/loci/slim/mask/MaskGroup.java

    r7992 r7994  
    7373        // combine maska and notify other nodes 
    7474        for (IMaskNode otherNode : _nodeList) { 
     75            System.out.println("MaskGroup.updateMask, consider " + otherNode); 
    7576            // don't notify the caller 
    7677            if (otherNode != node) { 
    7778                // don't combine the recipients mask 
    7879                Mask combinedMask = Mask.addOtherMasks(mask, _maskMap.values()); 
     80                System.out.println("MaskGroup.updateMask, notify " + combinedMask); 
    7981                otherNode.updateOtherMask(combinedMask); 
    8082            } 
  • trunk/projects/slim-plugin/src/main/java/loci/slim/mask/MaskNode.java

    r7992 r7994  
    4949        _maskGroup = maskGroup; 
    5050        _listener = listener; 
     51        maskGroup.addNode(this); 
    5152    } 
    5253 
     
    5657     * @param mask  
    5758     */ 
     59    @Override 
    5860    public void updateSelfMask(Mask mask) { 
     61        System.out.println("MaskNode.updateSelfMask " + mask); 
    5962        _maskGroup.updateMask(this, mask); 
    6063    } 
     
    6568     * @return  
    6669     */ 
     70    @Override 
    6771    public Mask getSelfMask() { 
    6872        return _selfMask; 
     
    7478     * @param mask  
    7579     */ 
     80    @Override 
    7681    public void updateOtherMask(Mask mask) { 
    7782        _otherMask = mask; 
     
    8489     * @return  
    8590     */ 
     91    @Override 
    8692    public Mask getOtherMask() { 
    8793        return _otherMask; 
     
    9399     * @return  
    94100     */ 
     101    @Override 
    95102    public Mask getTotalMask() { 
    96103        return _selfMask.add(_otherMask); 
Note: See TracChangeset for help on using the changeset viewer.