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

Method createIntImage

ij/src/main/java/ij/gui/NewImage.java:214–244  ·  view source on GitHub ↗
(String title, int width, int height, int slices, int options)

Source from the content-addressed store, hash-verified

212 }
213
214 public static ImagePlus createIntImage(String title, int width, int height, int slices, int options) {
215 int fill = getFill(options);
216 int size = getSize(width, height);
217 if (size<0) return null;
218 int[] pixels = new int[size];
219 IntProcessor ip = new IntProcessor(width, height, pixels);
220 switch (fill) {
221 case FILL_RAMP:
222 int[] ramp = new int[width];
223 double inc = ((double)Integer.MAX_VALUE - (double)Integer.MIN_VALUE)/width;
224 for (int i=0; i<width; i++) {
225 ramp[i] = (int)((double)Integer.MIN_VALUE + i*inc);
226 }
227 for (int y=0; y<height; y++) {
228 int offset = y*width;
229 for (int x=0; x<width; x++)
230 pixels[offset++] = ramp[x];
231 }
232 break;
233
234 case FILL_NOISE:
235 fillNoiseInt(new IntProcessor(width,height,(int[])pixels));
236 break;
237 }
238 ImagePlus imp = new ImagePlus(title, ip);
239 if (slices>1) {
240 boolean ok = createStack(imp, ip, slices, RGB, options);
241 if (!ok) imp = null;
242 }
243 return imp;
244 }
245
246 private static void fillNoiseRGB(ColorProcessor ip, boolean sp) {
247 int width = ip.getWidth();

Callers 1

createImageMethod · 0.95

Calls 4

getFillMethod · 0.95
getSizeMethod · 0.95
fillNoiseIntMethod · 0.95
createStackMethod · 0.95

Tested by

no test coverage detected