Changeset 7963


Ignore:
Timestamp:
04/12/12 17:30:38 (7 years ago)
Author:
aivar
Message:

SLIM Plugin: Refactor to allow different flavors of fitted images besides a FloatProcessor. For #702.

Location:
trunk/projects/slim-plugin/src/main/java/loci/slim/fitting/images
Files:
3 added
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/projects/slim-plugin/src/main/java/loci/slim/fitting/images/AbstractBaseColorizedImage.java

    r7956 r7963  
    4040    private MyStackWindow _stackWindow; 
    4141    private double _values[][]; 
    42     private HistogramDataChannel[] _histogramDataChannels; 
     42    private IColorizedFittedImage[] _fittedImages; 
     43    private HistogramDataChannel[] _dataChannels; 
    4344    private HistogramData _histogramData; 
    44     private FloatProcessor _imageProcessor; 
     45    private IColorizedFittedImage _fittedImage; 
    4546     
    4647    public AbstractBaseColorizedImage(String title, int[] dimension, 
     
    5556        _imageStack = new ImageStack(_width, _height); 
    5657         
     58        // building a list of displayed images 
     59        List<IColorizedFittedImage> fittedImageList 
     60                = new ArrayList<IColorizedFittedImage>(); 
     61         
    5762        // building a list of HistogramDataChannels 
    58         List<HistogramDataChannel> list = new ArrayList<HistogramDataChannel>(); 
     63        List<HistogramDataChannel> dataChannelList 
     64                = new ArrayList<HistogramDataChannel>(); 
    5965         
    6066        for (int c = 0; c < _channels; ++c) { 
    6167            // build the actual displayed image 
    62             FloatProcessor imageProcessor = new FloatProcessor(_width, _height); 
    63             imageProcessor.setColorModel(indexColorModel); 
    64              
    65             // fill the image with a value that will be out of LUT range and 
    66             // paint black 
    67             imageProcessor.setValue(Float.NaN); 
    68             imageProcessor.fill(); 
    69              
    70             _imageStack.addSlice("" + c, imageProcessor); 
     68            IColorizedFittedImage fittedImage = null; 
     69            if (true) { 
     70                fittedImage = new FloatFittedImage(); 
     71            } 
     72            else { 
     73                fittedImage = new ColorFittedImage(); 
     74            } 
     75             
     76            fittedImage.init(_width, _height, indexColorModel); 
     77 
     78            // add to stack 
     79            _imageStack.addSlice("" + c, fittedImage.getImageProcessor()); 
    7180             
    7281            // build the histogram data 
     
    7483            clear(_values); 
    7584            HistogramDataChannel histogramDataChannel = new HistogramDataChannel(_values); 
    76             list.add(histogramDataChannel);            
     85             
     86            fittedImageList.add(fittedImage); 
     87            dataChannelList.add(histogramDataChannel);            
    7788        } 
    7889         
     
    97108        }); 
    98109         
    99         _histogramDataChannels 
    100                 = list.toArray(new HistogramDataChannel[0]); 
    101         _histogramData = new HistogramData(this, title, _histogramDataChannels);  
     110        _fittedImages 
     111                = fittedImageList.toArray(new IColorizedFittedImage[0]); 
     112        _dataChannels 
     113                = dataChannelList.toArray(new HistogramDataChannel[0]); 
     114         
     115        _histogramData = new HistogramData(this, title, _dataChannels);  
    102116    } 
    103117 
     
    111125    } 
    112126     
    113      /** 
    114      * Sets the color model used to display float values. 
     127    /** 
     128     * Sets the color model used to display values. 
    115129     *  
    116130     * @param colorModel  
    117      */    
     131     */ 
    118132    public void setColorModel(IndexColorModel colorModel) { 
    119         _imageProcessor.setColorModel(colorModel); 
     133        for (IColorizedFittedImage fittedImage : _fittedImages) { 
     134            fittedImage.setColorModel(colorModel); 
     135        } 
    120136    }     
    121137     
     
    174190    private void redisplay(double[] minMaxLUT) { 
    175191        minMaxLUT = PaletteFix.adjustMinMax(minMaxLUT[0], minMaxLUT[1]); 
    176         if (null != _imageProcessor) { 
    177             _imageProcessor.setMinAndMax(minMaxLUT[0], minMaxLUT[1]); 
    178             _imagePlus.setProcessor(_imageProcessor.duplicate()); //TODO ARG OUCH!  This ImagePlus holds an ImageStack - maybe update(ImageProcessor ip) Updates this stack so its attributes such as min max calibration table and color model, are the same as 'ip' 
    179         } 
    180     } 
    181  
     192        if (null != _fittedImage) { 
     193            _fittedImage.setMinAndMax(minMaxLUT[0], minMaxLUT[1]); 
     194             
     195            //TODO ARG KLUDGE 
     196            //  This is a workaround to redisplay after the LUT range changes. 
     197            //  Hopefully it will go away in IJ2. 
     198            //  Maybe update(ImageProcessor ip) 
     199            //  "Updates this stack so its attributes such as min max calibration table and color model, are the same as 'ip'" 
     200            if (_fittedImage instanceof FloatFittedImage) { 
     201                _imagePlus.setProcessor(_fittedImage.getImageProcessor().duplicate()); 
     202            }      
     203        } 
     204    } 
    182205     
    183206    /** 
     
    194217        int y       = location[1]; 
    195218        int channel = location[2]; 
    196          
     219 
     220        // check for channel change 
    197221        if (_channel != channel) { 
    198222            _channel = channel; 
    199223            _stackWindow.showSlice(channel + 1); 
    200             _values = _histogramDataChannels[channel].getValues();             
    201             _imageProcessor = (FloatProcessor) _imageStack.getProcessor(channel + 1); 
    202         } 
    203          
     224            _values = _dataChannels[channel].getValues(); 
     225            _fittedImage = _fittedImages[channel]; 
     226        } 
     227  
     228        // save our local copy 
    204229        _values[x][y] = value; 
    205         _imageProcessor.setValue(value); 
    206         _imageProcessor.drawPixel(x, y); 
     230         
     231        // draw pixel in fitted image 
     232        _fittedImage.draw(x, y, value); 
    207233    } 
    208234 
  • trunk/projects/slim-plugin/src/main/java/loci/slim/fitting/images/ColorizedImageFitter.java

    r7889 r7963  
    1515 * @author Aivar Grislis 
    1616 */ 
     17//TODO ARG FIX this class handles the process of building up a fit.  However it 
     18//  needs to work with post-fit pixel masking 
     19//TODO ARG FIX this class needs to work with colorized images also 
    1720public class ColorizedImageFitter { 
    1821    public enum ColorizedImageType { A1, T1, A2, T2, A3, T3, Z, H, CHISQ, F1, F2, F3, f1, f2, f3 }; 
Note: See TracChangeset for help on using the changeset viewer.