本文整理汇总了Java中ij.gui.NewImage.CHECK_AVAILABLE_MEMORY属性的典型用法代码示例。如果您正苦于以下问题:Java NewImage.CHECK_AVAILABLE_MEMORY属性的具体用法?Java NewImage.CHECK_AVAILABLE_MEMORY怎么用?Java NewImage.CHECK_AVAILABLE_MEMORY使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类ij.gui.NewImage
的用法示例。
在下文中一共展示了NewImage.CHECK_AVAILABLE_MEMORY属性的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createImage
/** Creates a new imagePlus. <code>Type</code> should contain "8-bit", "16-bit", "32-bit" or "RGB".
In addition, it can contain "white", "black" or "ramp" (the default is "white"). <code>Width</code>
and <code>height</code> specify the width and height of the image in pixels.
<code>Depth</code> specifies the number of stack slices. */
public static ImagePlus createImage(String title, String type, int width, int height, int depth) {
type = type.toLowerCase(Locale.US);
int bitDepth = 8;
if (type.indexOf("16")!=-1) bitDepth = 16;
if (type.indexOf("24")!=-1||type.indexOf("rgb")!=-1) bitDepth = 24;
if (type.indexOf("32")!=-1) bitDepth = 32;
int options = NewImage.FILL_WHITE;
if (bitDepth==16 || bitDepth==32)
options = NewImage.FILL_BLACK;
if (type.indexOf("white")!=-1)
options = NewImage.FILL_WHITE;
else if (type.indexOf("black")!=-1)
options = NewImage.FILL_BLACK;
else if (type.indexOf("ramp")!=-1)
options = NewImage.FILL_RAMP;
options += NewImage.CHECK_AVAILABLE_MEMORY;
return NewImage.createImage(title, width, height, depth, bitDepth, options);
}
示例2: produceNoiseImage
/**
* Creates a noisy image that is created by repeatedly adding points
* with random intensity to the canvas. That way it tries to mimic the
* way a microscope produces images.
*
* @param <T> The wanted output type.
* @param width The image width.
* @param height The image height.
* @param dotSize The size of the dots.
* @param numDots The number of dots.
* @param smoothingSigma The two dimensional sigma for smoothing.
* @return The noise image.
*/
public static <T extends RealType<T> & NativeType<T>> RandomAccessibleInterval<T> produceNoiseImage(int width,
int height, float dotSize, int numDots) {
/* For now (probably until ImageJ2 is out) we use an
* ImageJ image to draw circles.
*/
int options = NewImage.FILL_BLACK + NewImage.CHECK_AVAILABLE_MEMORY;
ImagePlus img = NewImage.createByteImage("Noise", width, height, 1, options);
ImageProcessor imp = img.getProcessor();
float dotRadius = dotSize * 0.5f;
int dotIntSize = (int) dotSize;
for (int i=0; i < numDots; i++) {
int x = (int) (Math.random() * width - dotRadius);
int y = (int) (Math.random() * height - dotRadius);
imp.setColor(Color.WHITE);
imp.fillOval(x, y, dotIntSize, dotIntSize);
}
// we changed the data, so update it
img.updateImage();
// create the new image
RandomAccessibleInterval<T> noiseImage = ImagePlusAdapter.wrap(img);
return noiseImage;
}
示例3: createRectengularMaskImage
/**
* Creates a mask image with a black background and a white
* rectangular foreground.
*
* @param width The width of the result image.
* @param height The height of the result image.
* @param offset The offset of the rectangular mask.
* @param size The size of the rectangular mask.
* @return A black image with a white rectangle on it.
*/
public static <T extends RealType<T> & NativeType<T>> RandomAccessibleInterval<T> createRectengularMaskImage(
long width, long height, long[] offset, long[] size) {
/* For now (probably until ImageJ2 is out) we use an
* ImageJ image to draw lines.
*/
int options = NewImage.FILL_BLACK + NewImage.CHECK_AVAILABLE_MEMORY;
ImagePlus img = NewImage.createByteImage("Noise", (int)width, (int)height, 1, options);
ImageProcessor imp = img.getProcessor();
imp.setColor(Color.WHITE);
Roi rect = new Roi(offset[0], offset[1], size[0], size[1]);
imp.fill(rect);
// we changed the data, so update it
img.updateImage();
return ImagePlusAdapter.wrap(img);
}
示例4: produceSticksNoiseImage
/**
* This method creates a noise image that is made of many little
* sticks oriented in a random direction. How many of them and
* what the length of them are can be specified.
*
* @return a new noise image that is not smoothed
*/
public static <T extends RealType<T> & NativeType<T>> RandomAccessibleInterval<T> produceSticksNoiseImage(int width,
int height, int numSticks, int lineWidth, double maxLength) {
/* For now (probably until ImageJ2 is out) we use an
* ImageJ image to draw lines.
*/
int options = NewImage.FILL_BLACK + NewImage.CHECK_AVAILABLE_MEMORY;
ImagePlus img = NewImage.createByteImage("Noise", width, height, 1, options);
ImageProcessor imp = img.getProcessor();
imp.setColor(Color.WHITE);
imp.setLineWidth(lineWidth);
for (int i=0; i < numSticks; i++) {
// find random starting point
int x = (int) (Math.random() * width);
int y = (int) (Math.random() * height);
// create random stick length and direction
double length = Math.random() * maxLength;
double angle = Math.random() * 2 * Math.PI;
// calculate random point on circle, for the direction
int destX = x + (int) (length * Math.cos(angle));
int destY = y + (int) (length * Math.sin(angle));
// now draw the line
imp.drawLine(x, y, destX, destY);
}
// we changed the data, so update it
img.updateImage();
return ImagePlusAdapter.wrap(img);
}