MCPcopy Create free account
hub / github.com/AstroImageJ/astroimagej / applyFunction

Method applyFunction

ij/src/main/java/ij/plugin/frame/Fitter.java:174–203  ·  view source on GitHub ↗

create a duplicate of an image where the fit function is applied to the pixel values

()

Source from the content-addressed store, hash-verified

172
173 /** create a duplicate of an image where the fit function is applied to the pixel values */
174 void applyFunction() {
175 if (cf==null || fitType < 0) {
176 IJ.error("No function available");
177 return;
178 }
179 ImagePlus img = WindowManager.getCurrentImage();
180 if (img==null) {
181 IJ.noImage();
182 return;
183 }
184 if (img.getTitle().matches("y\\s=.*")) { //title looks like a fit function
185 IJ.error("First select the image to be transformed");
186 return;
187 }
188 double[] p = cf.getParams();
189 int width = img.getWidth();
190 int height = img.getHeight();
191 int size = width*height;
192 float[] data = new float[size];
193 ImageProcessor ip = img.getProcessor();
194 float value;
195 for (int y=0; y<height; y++) {
196 for (int x=0; x<width; x++) {
197 value = ip.getPixelValue(x,y);
198 data[y*width+x] = (float)cf.f(p, value);
199 }
200 }
201 ImageProcessor ip2 = new FloatProcessor(width, height, data, ip.getColorModel());
202 new ImagePlus(img.getTitle()+"-transformed", ip2).show();
203 }
204
205 void open() {
206 OpenDialog od = new OpenDialog("Open Text File...", "");

Callers 1

actionPerformedMethod · 0.95

Calls 13

errorMethod · 0.95
getCurrentImageMethod · 0.95
noImageMethod · 0.95
getTitleMethod · 0.95
getWidthMethod · 0.95
getHeightMethod · 0.95
getProcessorMethod · 0.95
getPixelValueMethod · 0.95
getColorModelMethod · 0.95
fMethod · 0.80
matchesMethod · 0.65
getParamsMethod · 0.45

Tested by

no test coverage detected