本文整理汇总了Java中net.imglib2.type.numeric.RealType.setReal方法的典型用法代码示例。如果您正苦于以下问题:Java RealType.setReal方法的具体用法?Java RealType.setReal怎么用?Java RealType.setReal使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类net.imglib2.type.numeric.RealType
的用法示例。
在下文中一共展示了RealType.setReal方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getImageWithOverlay
import net.imglib2.type.numeric.RealType; //导入方法依赖的package包/类
Img<T> getImageWithOverlay(Img<T> img, ArrayList<int[]> maskPixels, double outlineValue)
{
Img<T> tmpImage = img.copy();
final RandomAccess< T > r = tmpImage.randomAccess();
int[] currentPosition = new int[2];
for(int i=0;i<maskPixels.size();i++)
{
// Get current position index
currentPosition = maskPixels.get(i);
r.setPosition( (int)currentPosition[0], 0 );
r.setPosition( (int)currentPosition[1], 1 );
final RealType<T> t = r.get();
t.setReal(outlineValue);
}
return tmpImage;
}
示例2: scaleImage
import net.imglib2.type.numeric.RealType; //导入方法依赖的package包/类
public < T extends RealType< T > & NativeType< T > > void scaleImage(Img<T> img)
{
// create two empty variables
T min = img.firstElement().createVariable();
T max = img.firstElement().createVariable();
// compute min and max of the Image
computeMinMax( img, min, max );
//IJ.log( "minimum Value (img): " + min );
//IJ.log( "maximum Value (img): " + max );
//write("lol");
// Create a cursor for both images
Cursor<T> c1 = img.cursor();
// do for all pixels
while ( c1.hasNext() )
{
// get value of both imgs
RealType t1 = c1.next();
// overwrite img1 with the result
t1.setReal( t1.getRealFloat() / max.getRealFloat() );
}
}
示例3: identityRealTypeConverter
import net.imglib2.type.numeric.RealType; //导入方法依赖的package包/类
static private final Converter<RealType<?>, RealType<?>> identityRealTypeConverter() {
return new Converter<RealType<?>, RealType<?>>() {
@Override
public final void convert(final RealType<?> input, final RealType<?> output) {
output.setReal(input.getRealDouble());
}
};
}
示例4: thresholdImage
import net.imglib2.type.numeric.RealType; //导入方法依赖的package包/类
public Img<UnsignedByteType> thresholdImage(Img<T> img, double thresholdValue)
{
// Create an instance of an image factory
ImgFactory< UnsignedByteType > imgFactory = new ArrayImgFactory< UnsignedByteType >();
long[] dim = new long[2];
img.dimensions(dim);
// Create an Img with the same dimension as the input image
final Img< UnsignedByteType > tmpImage = imgFactory.create( dim, new UnsignedByteType() );
// Create a cursor for both images
Cursor<T> c1 = img.cursor();
Cursor<UnsignedByteType> c2 = tmpImage.cursor();
// do for all pixels
while ( c1.hasNext() )
{
// get value of both imgs
RealType t1 = c1.next();
RealType t2 = c2.next();
// overwrite img1 with the result
if(t1.getRealFloat() > thresholdValue)
{
t2.setReal(255);
}
else
{
t2.setReal(0);
}
}
return tmpImage;
}
示例5: multiplyImages
import net.imglib2.type.numeric.RealType; //导入方法依赖的package包/类
public static< T extends RealType< T > & NativeType< T > > Img<T> multiplyImages(Img<T> img1,Img<T> img2)
{
// Create an instance of an image factory
ImgFactory< T > imgFactory = new ArrayImgFactory< T >();
// Create an Img with the same dimension as the input image
final Img< T > tmpImage = imgFactory.create( img1, img1.firstElement() );
// Create a cursor for both images
Cursor<T> c1 = img1.cursor();
Cursor<T> c2 = img2.cursor();
Cursor<T> c3 = tmpImage.cursor();
// do for all pixels
while ( c1.hasNext() )
{
// get value of both imgs
RealType t1 = c1.next();
RealType t2 = c2.next();
RealType t3 = c3.next();
// overwrite img1 with the result
t3.setReal( t1.getRealFloat() * t2.getRealFloat() );
}
return tmpImage;
}
示例6: divideImages
import net.imglib2.type.numeric.RealType; //导入方法依赖的package包/类
public static< T extends RealType< T > & NativeType< T > > Img<T> divideImages(Img<T> img1,Img<T> img2)
{
// Create an instance of an image factory
ImgFactory< T > imgFactory = new ArrayImgFactory< T >();
// Create an Img with the same dimension as the input image
final Img< T > tmpImage = imgFactory.create( img1, img1.firstElement() );
// Create a cblurGaussianblurGaussianursor for both images
Cursor<T> c1 = img1.cursor();
Cursor<T> c2 = img2.cursor();
Cursor<T> c3 = tmpImage.cursor();
// do for all pixels
while ( c1.hasNext() )
{
// get value of both imgs
RealType t1 = c1.next();
RealType t2 = c2.next();
RealType t3 = c3.next();
if(t2.getRealFloat()>0)
{
// overwrite img1 with the result
t3.setReal( t1.getRealFloat() / t2.getRealFloat() );
} else {
t3.setReal(0);
}
}
return tmpImage;
}
示例7: subtractImages
import net.imglib2.type.numeric.RealType; //导入方法依赖的package包/类
public static< T extends RealType< T > & NativeType< T > > Img<T> subtractImages(Img<T> img1,Img<T> img2)
{
// Create an instance of an image factory
ImgFactory< T > imgFactory = new ArrayImgFactory< T >();
// Create an Img with the same dimension as the input image
final Img< T > tmpImage = imgFactory.create( img1, img1.firstElement() );
// Create a cursor for both images
Cursor<T> c1 = img1.cursor();
Cursor<T> c2 = img2.cursor();
Cursor<T> c3 = tmpImage.cursor();
// do for all pixels
while ( c1.hasNext() )
{
// get value of both imgs
RealType t1 = c1.next();
RealType t2 = c2.next();
RealType t3 = c3.next();
if(t2.getRealFloat()>0)
{
// overwrite img1 with the result
t3.setReal( t1.getRealFloat() - t2.getRealFloat() );
} else {
t3.setReal(0);
}
}
return tmpImage;
}
示例8: squareRootImage
import net.imglib2.type.numeric.RealType; //导入方法依赖的package包/类
public static< T extends RealType< T > & NativeType< T > > Img<T> squareRootImage(Img<T> img)
{
// Create an instance of an image factory
ImgFactory< T > imgFactory = new ArrayImgFactory< T >();
// Create an Img with the same dimension as the input image
final Img< T > tmpImage = imgFactory.create( img, img.firstElement() );
// Create a cursor for both images
Cursor<T> c1 = img.cursor();
Cursor<T> c2 = tmpImage.cursor();
// do for all pixels
while ( c1.hasNext() )
{
// get value of both imgs
RealType t1 = c1.next();
RealType t2 = c2.next();
// overwrite img1 with the result
//t2.setReal( Math.sqrt(t1.getRealFloat()));
t2.setReal( Math.sqrt(t1.getRealFloat()));
//t2.setReal( t1.getRealFloat());
}
return tmpImage;
}
示例9: getDirectionImage
import net.imglib2.type.numeric.RealType; //导入方法依赖的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;
}