本文整理汇总了Java中net.imglib2.img.ImagePlusAdapter.wrap方法的典型用法代码示例。如果您正苦于以下问题:Java ImagePlusAdapter.wrap方法的具体用法?Java ImagePlusAdapter.wrap怎么用?Java ImagePlusAdapter.wrap使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类net.imglib2.img.ImagePlusAdapter
的用法示例。
在下文中一共展示了ImagePlusAdapter.wrap方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: main
import net.imglib2.img.ImagePlusAdapter; //导入方法依赖的package包/类
public static < T extends RealType< T > & NativeType< T >> void main( final String[] args )
{
ImageJ.main( args );
final File file = new File( "DrosophilaWing.tif" );
final ImagePlus imp = IJ.openImage( file.getAbsolutePath() );
final Img< T > img = ImagePlusAdapter.wrap( imp );
final long start = System.currentTimeMillis();
final Shape shape = new DiamondTipsShape( 10 );
final Img< T > target = Dilation.dilate( img, shape, 1 );
final long end = System.currentTimeMillis();
System.out.println( "Processing done in " + ( end - start ) + " ms." );
ImageJFunctions.show( img );
ImageJFunctions.show( target );
}
示例2: produceNoiseImage
import net.imglib2.img.ImagePlusAdapter; //导入方法依赖的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;
}
示例3: createRectengularMaskImage
import net.imglib2.img.ImagePlusAdapter; //导入方法依赖的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);
}
示例4: main
import net.imglib2.img.ImagePlusAdapter; //导入方法依赖的package包/类
public static < T extends RealType< T > & NativeType< T >> void main( final String[] args )
{
ImageJ.main( args );
final File file = new File( "DrosophilaWing.tif" );
// final File file = new File(
// "/Users/JeanYves/Desktop/Data/brightblobs.tif" );
final ImagePlus imp = IJ.openImage( file.getAbsolutePath() );
final Img< T > img = ImagePlusAdapter.wrap( imp );
final long start = System.currentTimeMillis();
final Shape shape = new PairOfPointsShape( new long[] { -10, 20 } );
final Img< T > target = Dilation.dilate( img, shape, 1 );
final long end = System.currentTimeMillis();
System.out.println( "Processing done in " + ( end - start ) + " ms." );
ImageJFunctions.show( img );
ImageJFunctions.show( target );
final Shape shape2 = new PairOfPointsShape( new long[] { 10, -20 } );
final Img< T > target2 = Dilation.dilate( img, shape2, 1 );
ImageJFunctions.show( target2 );
final Shape shape3 = new PairOfPointsShape( new long[] { 10, 20 } );
final Img< T > target3 = Dilation.dilate( img, shape3, 1 );
ImageJFunctions.show( target3 );
}
示例5: run
import net.imglib2.img.ImagePlusAdapter; //导入方法依赖的package包/类
@Override
public void run(String arg) {
ImagePlus imp1 = IJ.openImage("/Users/dan/Documents/Dresden/ipf/colocPluginDesign/red.tif");
img1 = ImagePlusAdapter.wrap(imp1);
ImagePlus imp2 = IJ.openImage("/Users/dan/Documents/Dresden/ipf/colocPluginDesign/green.tif");
img2 = ImagePlusAdapter.wrap(imp2);
double pearson = calculatePearson();
Img<T> ranImg = generateRandomImageStack(img1, new int[] {2,2,1});
}
示例6: createMasksAndRois
import net.imglib2.img.ImagePlusAdapter; //导入方法依赖的package包/类
/**
* Creates appropriate data structures from the ROI information
* passed. If an irregular ROI is found, it will be put into a
* frame of its bounding box size and put into an {@code Image<T>}.
*
* In the end the members ROIs, masks and maskBBs will be
* filled if ROIs or masks were found. They will be null
* otherwise.
*/
protected void createMasksAndRois(final Roi[] rois, final int width,
final int height)
{
// create empty list
masks.clear();
for (final Roi r : rois) {
final MaskInfo mi = new MaskInfo();
// add it to the list of masks/ROIs
masks.add(mi);
// get the ROIs/masks bounding box
final Rectangle rect = r.getBounds();
mi.roi = new BoundingBox(new long[] { rect.x, rect.y }, new long[] {
rect.width, rect.height });
final ImageProcessor ipMask = r.getMask();
// check if we got a regular ROI and return if so
if (ipMask == null) {
continue;
}
// create a mask processor of the same size as a slice
final ImageProcessor ipSlice = ipMask.createProcessor(width, height);
// fill the new slice with black
ipSlice.setValue(0.0);
ipSlice.fill();
// position the mask on the new mask processor
ipSlice.copyBits(ipMask, (int) mi.roi.offset[0], (int) mi.roi.offset[1],
Blitter.COPY);
// create an Image<T> out of it
final ImagePlus maskImp = new ImagePlus("Mask", ipSlice);
// and remember it and the masks bounding box
mi.mask = ImagePlusAdapter.<T> wrap(maskImp);
}
}
示例7: produceSticksNoiseImage
import net.imglib2.img.ImagePlusAdapter; //导入方法依赖的package包/类
/**
* 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);
}
示例8: wrap
import net.imglib2.img.ImagePlusAdapter; //导入方法依赖的package包/类
/** Wrap an ImageJ's {@link ImagePlus} as an Imglib {@link Img} of the appropriate type.
* The data is not copied, but merely accessed with a PlanarArrayContainer.
* @see ImagePlusAdapter */
public static<T extends RealType<T> & NativeType<T>> Img<T> wrap(final ImagePlus imp) {
return ImagePlusAdapter.<T>wrap(imp);
}
示例9: main
import net.imglib2.img.ImagePlusAdapter; //导入方法依赖的package包/类
public static <T extends RealType<T> & NativeType<T>> void main(final String[] args) {
ImageJ.main(args);
final File file = new File( "DrosophilaWing.tif" );
final ImagePlus imp = IJ.openImage(file.getAbsolutePath());
final Img<T> img = ImagePlusAdapter.wrap(imp);
final long start = System.currentTimeMillis();
final Shape shape = new PeriodicLineShape(2, new int[] { 20, -15 });
final Img< T > target = Erosion.erode( img, shape, 1 );
final long end = System.currentTimeMillis();
System.out.println( "Processing done in " + ( end - start ) + " ms." );
ImageJFunctions.show(img);
ImageJFunctions.show(target);
}
示例10: getDirectionImage
import net.imglib2.img.ImagePlusAdapter; //导入方法依赖的package包/类
public Img<UnsignedByteType> getDirectionImage(ImagePlus img)
{
float[][] kirsch = new float[][] { {-3,-3,5,-3,0,5,-3,-3,5},
{-3,5,5,-3,0,5,-3,-3,-3},
{5,5,5,-3,0,-3,-3,-3,-3},
{5,5,-3,5,0,-3,-3,-3,-3},
{5,-3,-3,5,0,-3,5,-3,-3},
{-3,-3,-3,5,0,-3,5,5,-3},
{-3,-3,-3,-3,0,-3,5,5,5},
{-3,-3,-3,-3,0,5,-3,5,5}};
Img<UnsignedByteType>[] responseImages = new Img[8];
for(int i = 0; i < 8; i++)
{
ImagePlus tmp = img.duplicate();
tmp.getChannelProcessor().convolve(kirsch[i],3,3);
responseImages[i] = ImagePlusAdapter.wrap(tmp);
}
Cursor c1 = responseImages[0].cursor();
Cursor c2 = responseImages[1].cursor();
Cursor c3 = responseImages[2].cursor();
Cursor c4 = responseImages[3].cursor();
Cursor c5 = responseImages[4].cursor();
Cursor c6 = responseImages[5].cursor();
Cursor c7 = responseImages[6].cursor();
Cursor c8 = responseImages[7].cursor();
long[] dim = new long[2];
responseImages[0].dimensions(dim);
//final Img< T > directionImage = imgFactory.create( responseImages[0], responseImages[0].firstElement() );
ImgFactory< UnsignedByteType > imgFactory = new ArrayImgFactory< UnsignedByteType >();
final Img<UnsignedByteType> directionImage = imgFactory.create(dim,new UnsignedByteType());
//final Img< T > directionImage = imgFactory.create(dim,new RealType());
Cursor<UnsignedByteType> cDirection = directionImage.cursor();
while (c1.hasNext())
{
RealType[] t = new RealType[8];
t[0] = (RealType)c1.next();
t[1] = (RealType)c2.next();
t[2] = (RealType)c3.next();
t[3] = (RealType)c4.next();
t[4] = (RealType)c5.next();
t[5] = (RealType)c6.next();
t[6] = (RealType)c7.next();
t[7] = (RealType)c8.next();
RealType tDirection = cDirection.next();
float max = 0f;
int kernelId = 0;
for(int i = 0; i < 8; i++)
{
float currentValue = t[i].getRealFloat();
if(i==0)
{
max = currentValue;
kernelId = 0;
}
else if(currentValue>max)
{
max = currentValue;
kernelId = i;
}
}
tDirection.setReal(kernelId);
}
return directionImage;
}
示例11: loadTiffFromJar
import net.imglib2.img.ImagePlusAdapter; //导入方法依赖的package包/类
/**
* Loads a Tiff file from within the jar. The given path is treated
* as relative to this tests-package (i.e. "Data/test.tiff" refers
* to the test.tiff in sub-folder Data).
*
* @param <T> The wanted output type.
* @param relPath The relative path to the Tiff file.
* @return The file as ImgLib image.
*/
public static <T extends RealType<T> & NativeType<T>> RandomAccessibleInterval<T> loadTiffFromJar(String relPath) {
InputStream is = TestImageAccessor.class.getResourceAsStream(relPath);
BufferedInputStream bis = new BufferedInputStream(is);
ImagePlus imp = opener.openTiff(bis, "The Test Image");
assumeNotNull(imp);
return ImagePlusAdapter.wrap(imp);
}
示例12: loadTiffFromJarAsImg
import net.imglib2.img.ImagePlusAdapter; //导入方法依赖的package包/类
/**
* Loads a Tiff file from within the jar to use as a mask Cursor.
* So we use Img<T> which has a cursor() method.
* The given path is treated
* as relative to this tests-package (i.e. "Data/test.tiff" refers
* to the test.tiff in sub-folder Data).
*
* @param <T> The wanted output type.
* @param relPath The relative path to the Tiff file.
* @return The file as ImgLib image.
*/
public static <T extends RealType<T> & NativeType<T>> Img<T> loadTiffFromJarAsImg(String relPath) {
InputStream is = TestImageAccessor.class.getResourceAsStream(relPath);
BufferedInputStream bis = new BufferedInputStream(is);
ImagePlus imp = opener.openTiff(bis, "The Test Image");
assumeNotNull(imp);
return ImagePlusAdapter.wrap(imp);
}