本文整理汇总了Java中ij.process.StackConverter类的典型用法代码示例。如果您正苦于以下问题:Java StackConverter类的具体用法?Java StackConverter怎么用?Java StackConverter使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
StackConverter类属于ij.process包,在下文中一共展示了StackConverter类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: run
import ij.process.StackConverter; //导入依赖的package包/类
@Override
public void run(String arg) {
ImagePlus image = IJ.getImage();
// compute min
double min = ImageUtil.minOfImagePlusValues(image);
if (min < -32000) min = -32000;
// set minimum to 0;
ImageUtil.addToImagePlusValues(image, -min);
// store conversion setting
boolean scaling = ImageConverter.getDoScaling();
// turn conversion off
ImageConverter.setDoScaling(false);
// convert to 16 bit
StackConverter convert = new StackConverter(image);
convert.convertToGray16();
// set scaling to previous value
ImageConverter.setDoScaling(scaling);
// set calibration
double [] coeff = {min, 1.0};
image.getCalibration().setFunction(Calibration.STRAIGHT_LINE, coeff, "Grey Value");
}
开发者ID:akmaier,项目名称:CONRAD,代码行数:22,代码来源:Convert_to_16_bit.java
示例2: loadSurfaceColorsFromImage
import ij.process.StackConverter; //导入依赖的package包/类
@Override
public void loadSurfaceColorsFromImage(ImagePlus imp) {
if (imp.getType() != ImagePlus.COLOR_RGB) {
imp = new Duplicator().run(imp);
new StackConverter(imp).convertToRGB();
}
final InterpolatedImage ii = new InterpolatedImage(imp);
final Calibration cal = imp.getCalibration();
final double pw = cal.pixelWidth;
final double ph = cal.pixelHeight;
final double pd = cal.pixelDepth;
for (int i = 0; i < nVertices; i++) {
final Point3f coord = vertices[i];
final int v =
(int) Math.round(ii.interpol.get(coord.x / pw, coord.y / ph, coord.z /
pd));
colors[i] =
new Color3f(((v & 0xff0000) >> 16) / 255f, ((v & 0xff00) >> 8) / 255f,
(v & 0xff) / 255f);
}
final GeometryArray ga = (GeometryArray) getGeometry();
if (ga == null) return;
ga.setColors(0, colors);
changed = true;
}
开发者ID:fiji,项目名称:3D_Viewer,代码行数:27,代码来源:CustomIndexedTriangleMesh.java
示例3: loadSurfaceColorsFromImage
import ij.process.StackConverter; //导入依赖的package包/类
public void loadSurfaceColorsFromImage(ImagePlus imp) {
final GeometryArray ga = (GeometryArray) getGeometry();
if (ga == null) return;
if (imp.getType() != ImagePlus.COLOR_RGB) {
imp = new Duplicator().run(imp);
new StackConverter(imp).convertToRGB();
}
final InterpolatedImage ii = new InterpolatedImage(imp);
final int N = ga.getValidVertexCount();
final Color3f[] colors = new Color3f[N];
final Calibration cal = imp.getCalibration();
final double pw = cal.pixelWidth;
final double ph = cal.pixelHeight;
final double pd = cal.pixelDepth;
final Point3f coord = new Point3f();
for (int i = 0; i < N; i++) {
ga.getCoordinate(i, coord);
final int v =
(int) Math.round(ii.interpol.get(coord.x / pw, coord.y / ph, coord.z /
pd));
colors[i] =
new Color3f(((v & 0xff0000) >> 16) / 255f, ((v & 0xff00) >> 8) / 255f,
(v & 0xff) / 255f);
}
ga.setColors(0, colors);
changed = true;
}
开发者ID:fiji,项目名称:3D_Viewer,代码行数:30,代码来源:CustomMesh.java
示例4: convert
import ij.process.StackConverter; //导入依赖的package包/类
public static void convert(final ImagePlus image) {
final int imaget = image.getType();
if (imaget == ImagePlus.GRAY8 || imaget == ImagePlus.COLOR_256) return;
final int s = image.getStackSize();
switch (imaget) {
case ImagePlus.GRAY16:
case ImagePlus.GRAY32:
if (s == 1) new ImageConverter(image).convertToGray8();
else new StackConverter(image).convertToGray8();
break;
}
}
开发者ID:fiji,项目名称:3D_Viewer,代码行数:13,代码来源:ContentCreator.java
示例5: run
import ij.process.StackConverter; //导入依赖的package包/类
/**
* Compute of the 2D parameters of the nucleus
*
* @param imagePlusSegmented image of segmented nucleus
*/
public void run (ImagePlus imagePlusSegmented)
{
StackConverter stackConverter = new StackConverter( imagePlusSegmented );
if (imagePlusSegmented.getType() != ImagePlus.GRAY8) stackConverter.convertToGray8();
_resultsTable = computePrameters(imagePlusSegmented,searchSliceWithMaxArea(imagePlusSegmented));
}
开发者ID:PouletAxel,项目名称:NucleusJ_,代码行数:12,代码来源:Measure2D.java
示例6: createCentroidImage
import ij.process.StackConverter; //导入依赖的package包/类
static ImagePlus createCentroidImage(final int originalImageType, final ImageStack centroidValueStack) {
final boolean doScaling = ImageConverter.getDoScaling();
try {
ImageConverter.setDoScaling(false);
final ImagePlus cvImp = new ImagePlus("Cluster centroid values", centroidValueStack);
if (centroidValueStack.getSize() > 1) {
final StackConverter stackConverter = new StackConverter(cvImp);
switch (originalImageType) {
case ImagePlus.COLOR_RGB:
stackConverter.convertToGray8();
final ImageConverter imageConverter = new ImageConverter(cvImp);
imageConverter.convertRGBStackToRGB();
break;
case ImagePlus.GRAY8:
stackConverter.convertToGray8();
break;
case ImagePlus.GRAY16:
stackConverter.convertToGray16();
break;
case ImagePlus.GRAY32:
// No action needed
break;
default:
throw new IllegalArgumentException("Unsupported input image type: " + originalImageType);
}
} else {
final ImageConverter converter = new ImageConverter(cvImp);
// Convert image back to original type
switch (originalImageType) {
case ImagePlus.COLOR_RGB:
throw new IllegalArgumentException("Internal error: RGB image cannot have a single band.");
case ImagePlus.GRAY8:
converter.convertToGray8();
break;
case ImagePlus.GRAY16:
converter.convertToGray16();
break;
case ImagePlus.GRAY32:
// No action needed
break;
default:
throw new IllegalArgumentException("Unsupported input image type: " + originalImageType);
}
}
return cvImp;
} finally {
ImageConverter.setDoScaling(doScaling);
}
}
开发者ID:ij-plugins,项目名称:ijp-toolkit,代码行数:52,代码来源:KMeansUtils.java
示例7: test01
import ij.process.StackConverter; //导入依赖的package包/类
@Test
public void test01() throws Exception {
final float tolerance = 0.001f;
final float[][] expectedCenters = {
{26.0207f, 50.91606f, 101.7027f},
{227.0155f, 30.7971f, 30.7971f},
{126.8642f, 0.0000f, 230.3005f},
};
// Read test image
final File imageFile = new File("test/data/Flamingo.png");
assertTrue("Input file should exist", imageFile.exists());
final ImagePlus imp = IOUtils.openImage(imageFile);
assertTrue("Expecting color image.", imp.getType() == ImagePlus.COLOR_RGB);
// Convert input color image to a floating point stack
new ImageConverter(imp).convertToRGBStack();
new StackConverter(imp).convertToGray32();
final ImageStack stack = imp.getStack();
// Setup m-means
final KMeansConfig config = new KMeansConfig();
config.setNumberOfClusters(expectedCenters.length);
config.setRandomizationSeedEnabled(true);
config.setRandomizationSeed(48);
final KMeans2D kmeans = new KMeans2D(config);
// Run k-means to produce cluster image
final ByteProcessor clusterImage = kmeans.run(stack);
assertNotNull(clusterImage);
assertEquals("Output width must match input width", imp.getWidth(), clusterImage.getWidth());
assertEquals("Output height must match input height", imp.getHeight(), clusterImage.getHeight());
final float[][] clusterCenters = kmeans.getClusterCenters();
assertNotNull(clusterCenters);
assertEquals(expectedCenters.length, clusterCenters.length);
// Since we are using a fixed randomization seed, the cluster centers should be predictable
for (int c = 0; c < expectedCenters.length; c++) {
assertArrayEquals(expectedCenters[c], clusterCenters[c], tolerance);
}
// Check cluster codes at some locations on the output clusterImage
assertEquals(0, clusterImage.getPixel(31, 160));
assertEquals(0, clusterImage.getPixel(252, 44));
assertEquals(0, clusterImage.getPixel(241, 238));
assertEquals(1, clusterImage.getPixel(95, 32));
assertEquals(1, clusterImage.getPixel(104, 129));
assertEquals(1, clusterImage.getPixel(241, 124));
assertEquals(2, clusterImage.getPixel(57, 81));
assertEquals(2, clusterImage.getPixel(176, 106));
assertEquals(2, clusterImage.getPixel(143, 277));
}
开发者ID:ij-plugins,项目名称:ijp-toolkit,代码行数:53,代码来源:KMeans2DTest.java
示例8: benchmark01
import ij.process.StackConverter; //导入依赖的package包/类
@Test
@Ignore("Only for benchmarking.")
public void benchmark01() throws IOException {
final File imageFile = new File("test/data/clown24.png");
final double tolerance = 0.01;
final double[][] expectedCenters = {
{182.389, 108.690, 45.733},
{115.623, 51.116, 20.329},
{30.557, 10.600, 5.617},
{224.589, 187.087, 151.137},
};
assertTrue("File exists", imageFile.exists());
// Read test image
final ImagePlus imp = IOUtils.openImage(imageFile);
assertTrue("Expecting color image.", imp.getType() == ImagePlus.COLOR_RGB);
// Convert RGB to a stack
new ImageConverter(imp).convertToRGBStack();
new StackConverter(imp).convertToGray32();
final KMeansConfig config = new KMeansConfig();
config.setNumberOfClusters(4);
config.setRandomizationSeedEnabled(true);
config.setRandomizationSeed(48);
long totalTime = 0;
long minTime = Long.MAX_VALUE;
final int iterations = 10;
for (int l = 0; l < iterations; l++) {
final KMeans2D kmeans = new KMeans2D(config);
final long start = System.currentTimeMillis();
final ImageProcessor ip = kmeans.run(imp.getStack());
final long stop = System.currentTimeMillis();
final long time = stop - start;
System.out.println("time: " + time + "ms.");
totalTime += time;
minTime = Math.min(time, minTime);
assertNotNull(ip);
float[][] centers = kmeans.getClusterCenters();
for (int i = 0; i < centers.length; i++) {
for (int j = 0; j < centers[i].length; j++) {
System.out.println("center[" + i + "][" + j + "]: " + centers[i][j]);
}
}
for (int i = 0; i < centers.length; i++) {
for (int j = 0; j < centers[i].length; j++) {
assertEquals("center[" + i + "][" + j + "]",
expectedCenters[i][j], centers[i][j], tolerance);
}
}
System.out.println("Steps: " + kmeans.getNumberOfStepsToConvergence());
}
System.out.println("Average time: " + totalTime / (double) iterations + "ms");
System.out.println("Min time: " + minTime + "ms");
// final ImagePlus imp1 = new ImagePlus("K-means", ip);
// final FileSaver saver = new FileSaver(imp1);
// saver.saveAsTiff("kmeans-output.tif");
}
开发者ID:ij-plugins,项目名称:ijp-toolkit,代码行数:67,代码来源:KMeans2DTest.java
示例9: run
import ij.process.StackConverter; //导入依赖的package包/类
@Override
public void run(String arg) {
// Open an image
String path = "/home/bene/PhD/brains/template.tif";
ImagePlus imp = IJ.openImage(path);
new StackConverter(imp).convertToGray8();
// Create a universe and show it
Image3DUniverse univ = new Image3DUniverse();
univ.show();
// Add the image as an isosurface
Content c = univ.addVoltex(imp);
sleep(5);
// Create a new Transform3D object
Transform3D t3d = new Transform3D();
// Make it a 45 degree rotation around the local y-axis
t3d.rotY(45 * Math.PI / 180);
// Apply the transformation to the Content. This concatenates
// the previous present transformation with the specified one
c.applyTransform(t3d);
sleep(5);
// Apply it again: this gives a 90 degree rotation in
// summary.
c.applyTransform(t3d);
sleep(5);
// setTransform() does not concatenate, but sets the specified
// transformation:
c.setTransform(t3d);
sleep(5);
// reset the transformation to the identity
t3d.setIdentity();
c.setTransform(t3d);
sleep(5);
// remove all contents and close the universe
univ.removeAllContents();
univ.close();
}
开发者ID:TOMIGalway,项目名称:cmoct-sourcecode,代码行数:47,代码来源:Apply_Transformation.java
示例10: run
import ij.process.StackConverter; //导入依赖的package包/类
@Override
public void run(String arg) {
// Open an image
String path = "/home/bene/PhD/brains/template.tif";
ImagePlus imp = IJ.openImage(path);
new StackConverter(imp).convertToGray8();
// Create a universe and show it
Image3DUniverse univ = new Image3DUniverse();
univ.show();
univ.rotateY(30 * Math.PI / 180);
// Add the image as a volume
Content c = univ.addVoltex(imp);
sleep(5);
// Retrieve the VoltexGroup
VoltexGroup voltex = (VoltexGroup)c.getContent();
// Define a ROI
Roi roi = new OvalRoi(240, 220, 70, 50);
// Define a fill color
byte fillValue = (byte)100;
// Fill the part of the volume which results from the
// projection of the polygon onto the volume:
voltex.fillRoi(univ.getCanvas(), roi, fillValue);
sleep(5);
// This can be optimally used for deleting some parts of
// the volume:
fillValue = (byte)0;
roi.setLocation(150, 150);
voltex.fillRoi(univ.getCanvas(), roi, fillValue);
sleep(5);
// The internal image is changed, too:
imp.show();
}
开发者ID:TOMIGalway,项目名称:cmoct-sourcecode,代码行数:42,代码来源:Volume_Rendering.java
注:本文中的ij.process.StackConverter类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论