本文整理汇总了Java中ij.gui.NewImage类的典型用法代码示例。如果您正苦于以下问题:Java NewImage类的具体用法?Java NewImage怎么用?Java NewImage使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
NewImage类属于ij.gui包,在下文中一共展示了NewImage类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testNoImageWhenNoSkeletonisation
import ij.gui.NewImage; //导入依赖的package包/类
/**
* Test that no skeleton image pops open, when the input is already a skeleton
* (or skeletonisation didn't change it)
*/
@Test
public void testNoImageWhenNoSkeletonisation() throws Exception {
// SETUP
final UserInterface mockUI = mock(UserInterface.class);
IMAGE_J.ui().setDefaultUI(mockUI);
final ImagePlus pixel = NewImage.createByteImage("Test", 3, 3, 1,
FILL_BLACK);
pixel.getStack().getProcessor(1).set(1, 1, (byte) 0xFF);
// EXECUTE
final CommandModule module = IMAGE_J.command().run(
AnalyseSkeletonWrapper.class, true, "inputImage", pixel,
"pruneCycleMethod", "None").get();
// VERIFY
assertFalse(
"Sanity check failed: plugin cancelled before image could have been shown",
module.isCanceled());
verify(mockUI, after(250).never()).show(any(ImagePlus.class));
}
示例2: testSkeletonImageWhenSkeletonised
import ij.gui.NewImage; //导入依赖的package包/类
/**
* Test that the skeleton is displayed, when the input image gets skeletonised
*/
@Test
public void testSkeletonImageWhenSkeletonised() throws Exception {
final UserInterface mockUI = mock(UserInterface.class);
IMAGE_J.ui().setDefaultUI(mockUI);
final ImagePlus square = NewImage.createByteImage("Test", 4, 4, 1,
FILL_BLACK);
square.getStack().getProcessor(1).set(1, 1, (byte) 0xFF);
square.getStack().getProcessor(1).set(1, 2, (byte) 0xFF);
square.getStack().getProcessor(1).set(2, 1, (byte) 0xFF);
square.getStack().getProcessor(1).set(2, 2, (byte) 0xFF);
// EXECUTE
CommandModule module = IMAGE_J.command().run(AnalyseSkeletonWrapper.class,
true, "inputImage", square, "pruneCycleMethod", "None").get();
// VERIFY
assertFalse(
"Sanity check failed: plugin cancelled before image could have been shown",
module.isCanceled());
verify(mockUI, timeout(1000)).show(any(ImagePlus.class));
}
示例3: testResultsTableShortestPathFalse
import ij.gui.NewImage; //导入依赖的package包/类
/**
* Results table should have different number of columns when option
* "calculateShortestPath" is false see {@link #testResultsTable()}
*/
@Test
public void testResultsTableShortestPathFalse() throws Exception {
// SETUP
final ImagePlus pixel = NewImage.createByteImage("Test", 4, 4, 1,
FILL_BLACK);
pixel.getStack().getProcessor(1).set(1, 1, (byte) 0xFF);
// EXECUTE
final CommandModule module = IMAGE_J.command().run(
AnalyseSkeletonWrapper.class, true, "inputImage", pixel,
"pruneCycleMethod", "None", "calculateShortestPath", false).get();
// VERIFY
@SuppressWarnings("unchecked")
final Table<DefaultColumn<String>, String> table =
(Table<DefaultColumn<String>, String>) module.getOutput("resultsTable");
assertNotNull(table);
assertEquals("Results table has wrong number of columns", 11, table.size());
}
示例4: testAdditionalResultsTableNullWhenVerboseFalse
import ij.gui.NewImage; //导入依赖的package包/类
@Test
public void testAdditionalResultsTableNullWhenVerboseFalse()
throws Exception
{
// SETUP
final ImagePlus pixel = NewImage.createByteImage("Test", 4, 4, 1,
FILL_BLACK);
pixel.getStack().getProcessor(1).set(1, 1, (byte) 0xFF);
// EXECUTE
final CommandModule module = IMAGE_J.command().run(
AnalyseSkeletonWrapper.class, true, "inputImage", pixel,
"pruneCycleMethod", "None", "verbose", false).get();
// VERIFY
assertNull(module.getOutput("verboseTable"));
}
示例5: testNullROIManagerCancelsPlugin
import ij.gui.NewImage; //导入依赖的package包/类
@Test
public void testNullROIManagerCancelsPlugin() throws Exception {
// SETUP
final UserInterface mockUI = CommonWrapperTests.mockUIService(IMAGE_J);
final ImagePlus imagePlus = NewImage.createByteImage("", 5, 5, 5, 1);
// EXECUTE
final CommandModule module = IMAGE_J.command().run(ThicknessWrapper.class,
true, "inputImage", imagePlus, "cropToRois", true).get();
// VERIFY
assertTrue("No ROI Manager should have cancelled the plugin", module
.isCanceled());
assertEquals("Cancel reason is incorrect",
"Can't crop without valid ROIs in the ROIManager", module
.getCancelReason());
verify(mockUI, timeout(1000)).dialogPrompt(anyString(), anyString(), any(),
any());
}
示例6: testNullROIManagerCancelsPlugin
import ij.gui.NewImage; //导入依赖的package包/类
@Test
public void testNullROIManagerCancelsPlugin() throws Exception {
// SETUP
final UserInterface mockUI = CommonWrapperTests.mockUIService(IMAGE_J);
final ImagePlus imagePlus = NewImage.createImage("", 5, 5, 5, 8, 1);
// EXECUTE
final CommandModule module = IMAGE_J.command().run(
FitEllipsoidWrapper.class, true, "inputImage", imagePlus).get();
// VERIFY
assertTrue("No ROI Manager should have cancelled the plugin", module
.isCanceled());
assertTrue("Cancel reason is incorrect", module.getCancelReason()
.startsWith("Please populate ROI Manager with at least " +
QUADRIC_TERMS));
verify(mockUI, timeout(1000)).dialogPrompt(anyString(), anyString(), any(),
any());
}
示例7: testRun
import ij.gui.NewImage; //导入依赖的package包/类
@Test
public void testRun() throws Exception {
// SETUP
final String expectedTitle = "Skeleton of Test";
final ImagePlus imagePlus = NewImage.createImage("Test", 5, 5, 5, 8, 1);
final Calibration calibration = new Calibration();
calibration.setUnit("my unit");
imagePlus.setCalibration(calibration);
// EXECUTE
final CommandModule module = IMAGE_J.command().run(SkeletoniseWrapper.class,
true, "inputImage", imagePlus).get();
// VERIFY
final ImagePlus skeleton = (ImagePlus) module.getOutput("skeleton");
assertNotNull("Skeleton image should not be null", skeleton);
assertEquals("Skeleton has wrong title", expectedTitle, skeleton
.getTitle());
assertEquals("Skeleton should have same calibration", "my unit", skeleton
.getCalibration().getUnit());
assertNotSame("Original image should not have been overwritten",
imagePlus, skeleton);
}
示例8: testNoImageWhenNoSkeletonisation
import ij.gui.NewImage; //导入依赖的package包/类
/**
* Test that no skeleton image pops open, when the input is already a skeleton
* (or skeletonisation didn't change it)
*/
@Test
public void testNoImageWhenNoSkeletonisation() throws Exception {
// SETUP
final UserInterface mockUI = mock(UserInterface.class);
doNothing().when(mockUI).show(any(ImagePlus.class));
IMAGE_J.ui().setDefaultUI(mockUI);
final ImagePlus pixel = NewImage.createByteImage("Test", 3, 3, 1,
FILL_BLACK);
pixel.getStack().getProcessor(1).set(1, 1, (byte) 0xFF);
// EXECUTE
final CommandModule module = IMAGE_J.command().run(
IntertrabecularAngleWrapper.class, true, "inputImage", pixel).get();
// VERIFY
assertEquals(
"Sanity check failed: plugin cancelled before image could have been shown",
NO_RESULTS_MSG, module.getCancelReason());
verify(mockUI, after(250).never()).show(any(ImagePlus.class));
}
示例9: testSkeletonImageWhenSkeletonised
import ij.gui.NewImage; //导入依赖的package包/类
/**
* Test that the skeleton is displayed, when the input image gets skeletonised
*/
@Test
public void testSkeletonImageWhenSkeletonised() throws Exception {
// SETUP
final UserInterface mockUI = mock(UserInterface.class);
doNothing().when(mockUI).show(any(ImagePlus.class));
IMAGE_J.ui().setDefaultUI(mockUI);
final ImagePlus square = NewImage.createByteImage("Test", 4, 4, 1,
FILL_BLACK);
square.getStack().getProcessor(1).set(1, 1, (byte) 0xFF);
square.getStack().getProcessor(1).set(1, 2, (byte) 0xFF);
square.getStack().getProcessor(1).set(2, 1, (byte) 0xFF);
square.getStack().getProcessor(1).set(2, 2, (byte) 0xFF);
// EXECUTE
IMAGE_J.command().run(IntertrabecularAngleWrapper.class, true, "inputImage",
square).get();
// VERIFY
verify(mockUI, timeout(1000)).show(any(ImagePlus.class));
}
示例10: testNoResultsCancelsPlugin
import ij.gui.NewImage; //导入依赖的package包/类
@Test
public void testNoResultsCancelsPlugin() throws Exception {
// SETUP
final UserInterface mockUI = CommonWrapperTests.mockUIService(IMAGE_J);
final ImagePlus pixel = NewImage.createByteImage("Test", 3, 3, 1,
FILL_BLACK);
pixel.getStack().getProcessor(1).set(1, 1, (byte) 0xFF);
// EXECUTE
final CommandModule module = IMAGE_J.command().run(
IntertrabecularAngleWrapper.class, true, "inputImage", pixel).get();
// VERIFY
assertTrue("Plugin should have cancelled", module.isCanceled());
assertEquals("Cancel reason is incorrect", NO_RESULTS_MSG, module
.getCancelReason());
verify(mockUI, timeout(1000)).dialogPrompt(anyString(), anyString(), any(),
any());
}
示例11: testMultipleGraphsShowsWarningDialog
import ij.gui.NewImage; //导入依赖的package包/类
@Test
public void testMultipleGraphsShowsWarningDialog() throws Exception {
// SETUP
final UserInterface mockUI = mock(UserInterface.class);
final SwingDialogPrompt mockPrompt = mock(SwingDialogPrompt.class);
when(mockUI.dialogPrompt(startsWith("Image has multiple skeletons"),
anyString(), eq(WARNING_MESSAGE), any())).thenReturn(mockPrompt);
IMAGE_J.ui().setDefaultUI(mockUI);
final ImagePlus pixels = NewImage.createByteImage("Test", 4, 4, 1,
FILL_BLACK);
pixels.getStack().getProcessor(1).set(1, 1, (byte) 0xFF);
pixels.getStack().getProcessor(1).set(3, 3, (byte) 0xFF);
// EXECUTE
IMAGE_J.command().run(IntertrabecularAngleWrapper.class, true, "inputImage",
pixels).get();
// VERIFY
verify(mockUI, timeout(1000)).dialogPrompt(startsWith(
"Image has multiple skeletons"), anyString(), eq(WARNING_MESSAGE), any());
}
示例12: createImage
import ij.gui.NewImage; //导入依赖的package包/类
/** 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);
}
示例13: createTestImage
import ij.gui.NewImage; //导入依赖的package包/类
private ImagePlus createTestImage()
{
final ImagePlus imp = NewImage.createByteImage( "Test image", 100, 100, 1, NewImage.FILL_BLACK );
final ImageProcessor ip = imp.getProcessor();
ip.setRoi( new Rectangle( 10, 10, 10, 10 ) );
ip.setColor( 1 );
ip.fill();
ip.setRoi( new Rectangle( 20, 20, 10, 20 ) );
ip.setColor( 2 );
ip.fill();
ip.setRoi( new Rectangle( 40, 40, 10, 30 ) );
ip.setColor( 3 );
ip.fill();
return imp;
}
示例14: produceNoiseImage
import ij.gui.NewImage; //导入依赖的package包/类
/**
* 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;
}
示例15: createRectengularMaskImage
import ij.gui.NewImage; //导入依赖的package包/类
/**
* 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);
}