Changeset 7866 for trunk/projects/slim-plugin/src
- Timestamp:
- 01/13/12 15:33:03 (8 years ago)
- Location:
- trunk/projects/slim-plugin/src/main/java
- Files:
-
- 7 edited
- 2 moved
Legend:
- Unmodified
- Added
- Removed
-
trunk/projects/slim-plugin/src/main/java/imagej/charts/cursors/Cursor.java
r7858 r7866 6 6 package imagej.charts.cursors; 7 7 8 import java.awt.Rectangle; 8 9 import java.util.ArrayList; 10 import java.util.HashSet; 9 11 import java.util.List; 12 import java.util.Set; 10 13 11 14 /** … … 23 26 int _ids; 24 27 Orientation _orientation; 25 List<ICursorMoveListener> _moveListeners = new ArrayList<ICursorMoveListener>(); 26 List<ICursorDragListener> _dragListeners = new ArrayList<ICursorDragListener>(); 27 List<ICursorStretchListener> _stretchListeners = new ArrayList<ICursorStretchListener>(); 28 private volatile boolean _dragListening; 29 private volatile boolean _moveListening; 30 private volatile boolean _stretchListening; 31 private Set<ICursorDragListener> _dragListener; 32 private Set<ICursorMoveListener> _moveListener; 33 private Set<ICursorStretchListener> _stretchListener; 34 private Rectangle _rectangle; 28 35 29 36 public Cursor() { … … 41 48 private void init(int ids, Orientation orientation) { 42 49 _ids = ids; 50 _dragListening = _moveListening = _stretchListening = false; 51 _dragListener = new HashSet<ICursorDragListener>(); 52 _moveListener = new HashSet<ICursorMoveListener>(); 53 _stretchListener = new HashSet<ICursorStretchListener>(); 54 _rectangle = null; 43 55 } 44 56 45 public void addMoveListener(ICursorMoveListener listener) { 46 synchronized (_moveListeners) { 47 _moveListeners.add(listener); 48 } 57 public void addCursorDragListener(ICursorDragListener dragListener) { 58 _dragListener.add(dragListener); 59 _dragListening = true; 49 60 } 50 61 51 public void addDragListener(ICursorDragListener listener) { 52 synchronized (_dragListeners) { 53 _dragListeners.add(listener); 54 } 62 public void removeCursorDragListener(ICursorDragListener dragListener) { 63 _dragListener.remove(dragListener); 64 _dragListening = _dragListener.size() > 0; 55 65 } 56 66 57 public void addStretchListener(ICursorStretchListener listener) { 58 synchronized (_stretchListeners) { 59 _stretchListeners.add(listener); 60 } 67 public void addCursorMoveListener(ICursorMoveListener moveListener) { 68 _moveListener.add(moveListener); 69 _moveListening = true; 61 70 } 62 71 63 public void removeMoveListener(ICursorMoveListener listener) { 64 synchronized (_moveListeners) { 65 _moveListeners.remove(listener); 66 } 72 public void removeCursorMoveListener(ICursorMoveListener moveListener) { 73 _moveListener.remove(moveListener); 74 _moveListening = _moveListener.size() > 0; 67 75 } 68 76 69 public void removeDragListener(ICursorDragListener listener) { 70 synchronized (_dragListeners) { 71 _dragListeners.remove(listener); 72 } 77 public void addCursorStretchListener(ICursorStretchListener stretchListener) { 78 _stretchListener.add(stretchListener); 79 _stretchListening = true; 73 80 } 74 81 75 public void removeStretchListener(ICursorMoveListener listener) { 76 synchronized (_stretchListeners) { 77 _stretchListeners.remove(listener); 78 } 82 public void removeCursorStretchListener(ICursorStretchListener stretchListener) { 83 _stretchListener.remove(stretchListener); 84 _stretchListening = _stretchListener.size() > 0; 79 85 } 86 87 public void setRectangle(Rectangle rectangle) { 88 _rectangle = rectangle; 89 } 90 91 public boolean mouseDragged(int x, int y) { 92 return false; 93 } 94 95 public boolean mouseMoved(int x, int y) { 96 return false; 97 } 98 80 99 } -
trunk/projects/slim-plugin/src/main/java/imagej/charts/cursors/CursorLayer.java
r7858 r7866 8 8 import java.awt.Rectangle; 9 9 import java.util.ArrayList; 10 import java.util.HashSet; 10 11 import java.util.List; 12 import java.util.Set; 11 13 import javax.swing.JPanel; 12 14 … … 20 22 private volatile Rectangle _rectangle = null; 21 23 private JPanel _panel; 22 private List<Cursor> _cursorList;24 private Set<Cursor> _cursorSet; 23 25 24 26 public CursorLayer(JPanel panel) { 25 27 _panel = panel; 26 _cursor List = new ArrayList<Cursor>();28 _cursorSet = new HashSet<Cursor>(); 27 29 } 28 30 29 31 public void addCursor(Cursor cursor) { 30 _cursorList.add(cursor); 32 _cursorSet.add(cursor); 33 } 34 35 public void removeCursor(Cursor cursor) { 36 _cursorSet.remove(cursor); 31 37 } 32 38 … … 35 41 public void setRectangle(Rectangle rectangle) { 36 42 _rectangle = rectangle; 43 for (Cursor cursor : _cursorSet) { 44 cursor.setRectangle(rectangle); 45 } 37 46 repaint(); 38 47 } -
trunk/projects/slim-plugin/src/main/java/imagej/slim/fitting/FitInfo.java
r7865 r7866 54 54 private double[] _sig; //TODO sig s/b specified for each pixel!! 55 55 56 private I InputImage _inputImage; // takes care of width/height/threshold/ROI57 private I OutputImage _outputImage;56 private IDecayImage _inputImage; // takes care of width/height/threshold/ROI 57 private IFittedImage _outputImage; 58 58 59 59 //TODO private IBob _cursorMunger; -
trunk/projects/slim-plugin/src/main/java/imagej/slim/fitting/IDecayImage.java
r7865 r7866 12 12 * @author Aivar Grislis 13 13 */ 14 public interface I InputImage {14 public interface IDecayImage { 15 15 16 16 /** … … 39 39 * @return 40 40 */ 41 public int get Parameters();41 public int getBins(); 42 42 43 43 /** -
trunk/projects/slim-plugin/src/main/java/imagej/slim/fitting/IFittedImage.java
r7865 r7866 11 11 * @author Aivar Grislis 12 12 */ 13 public interface I OutputImage {13 public interface IFittedImage { 14 14 15 15 /** … … 42 42 43 43 /** 44 * Puts output pixel value. 44 * Gets dimensions. 45 * 46 * @return 47 */ 48 public int[] getDimension(); 49 50 /** 51 * Gets pixel values at location. 52 * 53 * @param location 54 * @return 55 */ 56 public double[] getPixel(int[] location); 57 58 /** 59 * Sets pixel value at location. 60 * 61 * @param location 62 * @param value 63 */ 64 public void setPixel(int[] location, double[] value); 65 66 /** 67 * Gets fitted pixel value. 68 * 69 * @param x 70 * @param y 71 * @param channel 72 * @return 73 */ 74 public double[] getPixel(int x, int y, int channel); 75 76 /** 77 * Puts fitted pixel value. 45 78 * 46 79 * @param x 47 80 * @param y 48 81 * @param channel 49 * @param pixel82 * @param value 50 83 */ 51 public void putPixel(int x, int y, int channel, double[] pixel);84 public void setPixel(int x, int y, int channel, double[] value); 52 85 53 86 -
trunk/projects/slim-plugin/src/main/java/loci/slim/ChunkyPixel.java
r7668 r7866 45 45 */ 46 46 public class ChunkyPixel { 47 final int m_x; 48 final int m_y; 49 final int m_width; 50 final int m_height; 47 final int _x; 48 final int _y; 49 final int _width; 50 final int _height; 51 final int[] _location; 51 52 53 @Deprecated 52 54 public ChunkyPixel(int x, int y, int width, int height) { 53 m_x = x; 54 m_y = y; 55 m_width = width; 56 m_height = height; 55 _x = x; 56 _y = y; 57 _width = width; 58 _height = height; 59 _location = null; 60 } 61 62 public ChunkyPixel(int[] location, int width, int height) { 63 _location = location; 64 _width = width; 65 _height = height; 66 _x = _location[0]; 67 _y = _location[1]; //TODO just transitioning from x,y to location[] 57 68 } 58 69 59 70 public int getX() { 60 return m_x;71 return _x; 61 72 } 62 73 63 74 public int getY() { 64 return m_y;75 return _y; 65 76 } 66 77 67 78 public int getWidth() { 68 return m_width;79 return _width; 69 80 } 70 81 71 82 public int getHeight() { 72 return m_height; 83 return _height; 84 } 85 86 public int[] getLocation() { 87 if (null == _location) { 88 return new int[] { _x, _y }; 89 } 90 return _location; 73 91 } 74 92 } -
trunk/projects/slim-plugin/src/main/java/loci/slim/InputImageWrapper.java
r7865 r7866 5 5 package loci.slim; 6 6 7 import imagej.slim.fitting.I InputImage;7 import imagej.slim.fitting.IDecayImage; 8 8 9 9 import mpicbg.imglib.container.planar.PlanarContainerFactory; … … 17 17 18 18 /** 19 * This class wraps an image that is being used as input for a cumulative fit.19 * This class wraps an image that has a decay curve for each pixel. 20 20 * 21 21 * @author Aivar Grislis 22 22 */ 23 public class InputImageWrapper implements I InputImage {23 public class InputImageWrapper implements IDecayImage { 24 24 private Image<DoubleType> _image; 25 25 private int _width; 26 26 private int _height; 27 27 private int _channels; 28 private int _ parameters;28 private int _bins; 29 29 private LocalizableByDimCursor<DoubleType> _cursor; 30 30 … … 36 36 _height = dimensions[1]; 37 37 _channels = dimensions[2]; 38 _ parameters = dimensions[3];38 _bins = dimensions[3]; 39 39 _cursor = _image.createLocalizableByDimCursor(); 40 40 } … … 71 71 72 72 /** 73 * Gets number of parametersof image.73 * Gets number of bins in decay curve of image. 74 74 * 75 75 * @return 76 76 */ 77 77 @Override 78 public int get Parameters() {79 return _ parameters;78 public int getBins() { 79 return _bins; 80 80 } 81 81 82 82 /** 83 * Gets input pixel value.83 * Gets input pixel decay curve. 84 84 * 85 85 * @param x … … 90 90 @Override 91 91 public double[] getPixel(int x, int y, int channel) { 92 double[] parameters = new double[_parameters];92 double[] decay = new double[_bins]; 93 93 int[] location = new int[] { x, y, channel, 0 }; 94 for (int i = 0; i < _ parameters; ++i) {94 for (int i = 0; i < _bins; ++i) { 95 95 location[3] = i; 96 96 _cursor.moveTo(location); 97 parameters[i] = _cursor.getType().getRealFloat();97 decay[i] = _cursor.getType().getRealFloat(); 98 98 } 99 return parameters;99 return decay; 100 100 } 101 101 -
trunk/projects/slim-plugin/src/main/java/loci/slim/OutputImageWrapper.java
r7865 r7866 5 5 package loci.slim; 6 6 7 import imagej.slim.fitting.I OutputImage;7 import imagej.slim.fitting.IFittedImage; 8 8 9 9 import mpicbg.imglib.container.planar.PlanarContainerFactory; … … 19 19 * @author Aivar Grislis 20 20 */ 21 public class OutputImageWrapper implements I OutputImage {21 public class OutputImageWrapper implements IFittedImage { 22 22 private Image<DoubleType> _image; 23 23 private int _width; … … 106 106 } 107 107 108 @Override 109 public int[] getDimension() { 110 int[] dimension = null; 111 if (_channels > 1) { 112 dimension = new int[] { _width, _height, _channels, _parameters }; 113 } 114 else { 115 dimension = new int[] { _width, _height, _parameters }; 116 } 117 return dimension; 118 } 119 120 public double[] getPixel(int[] location) { 121 double[] parameters = new double[_parameters]; 122 int parameterIndex = location.length - 1; 123 for (int i = 0; i < _parameters; ++i) { 124 location[parameterIndex] = i; 125 _cursor.moveTo(location); 126 parameters[i] = _cursor.getType().getRealFloat(); 127 } 128 return parameters; 129 } 130 131 public void setPixel(int[] location, double[] value) { 132 int parameterIndex = location.length - 1; 133 for (int i = 0; i < _parameters; ++i) { 134 location[parameterIndex] = i; 135 _cursor.moveTo(location); 136 _cursor.getType().set(value[i]); 137 } 138 } 139 108 140 /** 109 * Puts output pixel value. 141 * Gets fitted pixel value. 142 * 143 * @param x 144 * @param y 145 * @param channel 146 * @return 147 */ 148 @Override 149 public double[] getPixel(int x, int y, int channel) { 150 double[] parameters = new double[_parameters]; 151 int[] location = new int[] { x, y, channel, 0 }; 152 for (int i = 0; i < _parameters; ++i) { 153 location[3] = i; 154 _cursor.moveTo(location); 155 parameters[i] = _cursor.getType().getRealFloat(); 156 } 157 return parameters; 158 } 159 160 /** 161 * Puts fitted pixel value. 110 162 * 111 163 * @param x … … 115 167 */ 116 168 @Override 117 public void putPixel(int x, int y, int channel, double[] pixel) {169 public void setPixel(int x, int y, int channel, double[] parameters) { 118 170 int[] location = new int[] { x, y, channel, 0 }; 119 171 for (int i = 0; i < _parameters; ++i) { 120 172 location[3] = i; 121 173 _cursor.moveTo(location); 122 _cursor.getType().set(p ixel[i]);174 _cursor.getType().set(parameters[i]); 123 175 } 124 176 } -
trunk/projects/slim-plugin/src/main/java/loci/slim/SLIMProcessor.java
r7865 r7866 83 83 // Kludge in the new stuff: 84 84 import imagej.slim.fitting.FitInfo; 85 import imagej.slim.fitting.I InputImage;86 import imagej.slim.fitting.I OutputImage;85 import imagej.slim.fitting.IDecayImage; 86 import imagej.slim.fitting.IFittedImage; 87 87 import imagej.slim.fitting.images.ColorizedImageParser; 88 88 import imagej.slim.fitting.params.IGlobalFitParams; … … 699 699 } 700 700 701 private I InputImage wrapInputImage() {702 I InputImage returnValue = null;701 private IDecayImage wrapInputImage() { 702 IDecayImage returnValue = null; 703 703 return returnValue; 704 704 } 705 705 706 private I OutputImage wrapOutputImage() {707 I OutputImage returnValue = null;706 private IFittedImage wrapOutputImage() { 707 IFittedImage returnValue = null; 708 708 return returnValue; 709 709 } 710 710 711 private Image<DoubleType> fitImage(IUserInterfacePanel uiPanel) { 712 FitInfo fitInfo = getFitInfo(m_grayScaleImage, uiPanel); 713 IDecayImage decayImage = wrapInputImage(); 714 IFittedImage previousImage = wrapOutputImage(); 715 IFittedImage newImage = wrapOutputImage(); 716 return fitImage(fitInfo, decayImage, previousImage, newImage); 717 718 } 719 720 private Image<DoubleType> fitImage(FitInfo fitInfo, IDecayImage decayImage, 721 IFittedImage previousImage, IFittedImage newImage) { 722 return null; 723 } 724 725 /** 726 * Helper function that processes an array of pixels. When creating 727 * colorized images from fit parameters, the histogram and images are 728 * updated at the end of this function. 729 * 730 * @param fittingEngine 731 * @param pixels 732 * @param globalFitParams 733 * @param localFitParams 734 * @param imageColorizer 735 * @param fittedImage 736 */ 737 private void processPixels( 738 IFittingEngine fittingEngine, 739 ChunkyPixel[] pixels, 740 IGlobalFitParams globalFitParams, 741 List<ILocalFitParams> localFitParamsList, 742 ColorizedImageFitter imageColorizer, 743 IFittedImage fittedImage) { 744 745 List<IFitResults> resultsList = 746 fittingEngine.fit(globalFitParams, localFitParamsList); 747 748 for (int i = 0; i < resultsList.size(); ++i) { 749 IFitResults result = resultsList.get(i); 750 ChunkyPixel p = pixels[i]; 751 if (null != imageColorizer) { 752 imageColorizer.updatePixel(p.getLocation(), result.getParams()); 753 } 754 fittedImage.setPixel(p.getLocation(), result.getParams()); 755 } 756 757 if (null != imageColorizer) { 758 imageColorizer.recalcHistogram(); 759 } 760 } 711 761 712 762 /* … … 1366 1416 1367 1417 1368 /** 1369 * Helper function that processes an array of pixels. Histogram and imagess 1370 * are updated at the end of this function. 1371 * 1372 * @param fittingEngine 1373 * @param pixels 1374 * @param globalFitParams 1375 * @param localFitParams 1376 * @param imageFitter 1377 */ 1378 private void processPixels(IFittingEngine fittingEngine, ChunkyPixel[] pixels, IGlobalFitParams globalFitParams, List<ILocalFitParams> localFitParams, ColorizedImageFitter imageFitter) { 1379 List<IFitResults> results = fittingEngine.fit(globalFitParams, localFitParams); 1380 1381 for (int i = 0; i < results.size(); ++i) { 1382 IFitResults result = results.get(i); 1383 ChunkyPixel p = pixels[i]; 1384 int[] location = { p.getX(), p.getY() }; 1385 imageFitter.updatePixel(location, result.getParams()); 1386 } 1387 1388 imageFitter.recalcHistogram(); 1389 } 1418 1390 1419 1391 1420 // copied 1/12 to modify into "processPixels" above:
Note: See TracChangeset
for help on using the changeset viewer.