(String title, int width, int height, int slices, int options)
| 318 | } |
| 319 | |
| 320 | public static ImagePlus createFloatImage(String title, int width, int height, int slices, int options) { |
| 321 | int fill = getFill(options); |
| 322 | int size = getSize(width, height); |
| 323 | if (size<0) return null; |
| 324 | float[] pixels = new float[size]; |
| 325 | ImageProcessor ip = new FloatProcessor(width, height, pixels, null); |
| 326 | switch (fill) { |
| 327 | case FILL_WHITE: case FILL_BLACK: |
| 328 | break; |
| 329 | case FILL_RAMP: |
| 330 | float[] ramp = new float[width]; |
| 331 | for (int i=0; i<width; i++) |
| 332 | ramp[i] = (float)((i*1.0)/width); |
| 333 | int offset; |
| 334 | for (int y=0; y<height; y++) { |
| 335 | offset = y*width; |
| 336 | for (int x=0; x<width; x++) |
| 337 | pixels[offset++] = ramp[x]; |
| 338 | } |
| 339 | break; |
| 340 | case FILL_NOISE: |
| 341 | fillNoiseFloat(ip); |
| 342 | break; |
| 343 | } |
| 344 | if (fill==FILL_WHITE) |
| 345 | ip.invertLut(); |
| 346 | ImagePlus imp = new ImagePlus(title, ip); |
| 347 | if (slices>1) { |
| 348 | boolean ok = createStack(imp, ip, slices, GRAY32, options); |
| 349 | if (!ok) imp = null; |
| 350 | } |
| 351 | if (fill!=FILL_NOISE) |
| 352 | imp.getProcessor().setMinAndMax(0.0, 1.0); // default display range |
| 353 | return imp; |
| 354 | } |
| 355 | |
| 356 | private static void fillNoiseFloat(ImageProcessor ip) { |
| 357 | ip.noise(1); |
no test coverage detected