use of bacmman.image.ImageFloat in project bacmman by jeanollion.
the class RadonProjection method getSinogram.
public static ImageFloat getSinogram(Image image, double angleMin, double angleMax, double stepSize, int projSize) {
double[] angles = getAngleArray(angleMin, angleMax, stepSize);
ImageFloat res = new ImageFloat("sinogram", angles.length, projSize, 1);
float[] proj = new float[projSize];
for (int i = 0; i < angles.length; ++i) {
radonProject(image, 0, angles[i], proj, true);
for (int j = 0; j < projSize; ++j) if (proj[j] != Float.NaN)
res.setPixel(i, j, 0, proj[j]);
}
return res;
}
use of bacmman.image.ImageFloat in project bacmman by jeanollion.
the class RegionCluster method drawInterfaceValues.
public static <I extends InterfaceVoxels<I>> ImageFloat drawInterfaceValues(RegionCluster<I> cluster, Function<I, Double> value) {
ImageFloat im = new ImageFloat("Interface Values", cluster.population.getImageProperties());
for (I i : cluster.interfaces) {
double val = value.apply(i);
i.getVoxels().stream().filter(// case of background pixels -> can be out of bound
(v) -> cluster.population.getLabelMap().contains(v.x, v.y, v.z)).forEach((v) -> im.setPixel(v.x, v.y, v.z, val));
}
return im;
}
use of bacmman.image.ImageFloat in project bacmman by jeanollion.
the class LocalThickness method localThickness.
/**
* @param in
* @param scaleZScaleXYRatio scaleZ / scaleXY
* @param inside if true, computes local thickness inside mask, if false compute local thickness of the background
* @param multithread whether it should be run in parallel or not
* @return local thickness (in pixels)
*/
public static ImageFloat localThickness(ImageMask in, double scaleZScaleXYRatio, boolean inside, boolean multithread) {
ImageFloat edm = EDT.transform(in, inside, 1, (float) scaleZScaleXYRatio, multithread);
DistanceRidge dr = new DistanceRidge();
ImagePlus distRidge = dr.run(IJImageWrapper.getImagePlus(edm), (float) scaleZScaleXYRatio, multithread);
LocalThickness lt = new LocalThickness();
lt.run(distRidge, (float) scaleZScaleXYRatio, multithread);
CleanUpLocalThickness cult = new CleanUpLocalThickness();
// TODO use array of EDM to save memory
ImagePlus localThickness = cult.run(distRidge);
distRidge.flush();
ImageFloat res = (ImageFloat) IJImageWrapper.wrap(localThickness);
res.translate(in);
res.setCalibration(in);
return res;
}
use of bacmman.image.ImageFloat in project bacmman by jeanollion.
the class AutoRotationXY method computeRotationAngleXY.
public double[] computeRotationAngleXY(Image image, int z, double ang1, double ang2, double stepSize, float[] proj, boolean var, double filterScale) {
// initial search
double[] angles = getAngleArray(ang1, ang2, stepSize);
double[] angleMax = new double[] { angles[0], angles[0] };
double max = -1;
ImageFloat sinogram = null;
if (testMode.testExpert())
sinogram = new ImageFloat("sinogram search angles: [" + ang1 + ";" + ang2 + "]", angles.length, proj.length, 1);
for (int angleIdx = 0; angleIdx < angles.length; ++angleIdx) {
radonProject(image, z, angles[angleIdx] + 90, proj, true);
if (testMode.testExpert())
paste(proj, sinogram, angleIdx);
// if (filterScale>0) filter(filterScale, proj);
double tempMax = var ? RadonProjection.var(proj) : RadonProjection.max(proj);
if (tempMax > max) {
max = tempMax;
angleMax[0] = angles[angleIdx];
angleMax[1] = angles[angleIdx];
} else if (tempMax == max) {
angleMax[1] = angles[angleIdx];
}
// logger.trace("radon projection: computeRotationAngleXY: {}", angleMax);
}
if (testMode.testExpert()) {
if (sinogram1Test.size() <= sinogram2Test.size())
sinogram1Test.add(sinogram);
else
sinogram2Test.add(sinogram);
}
angleMax[0] = -angleMax[0];
angleMax[1] = -angleMax[1];
return angleMax;
}
use of bacmman.image.ImageFloat in project bacmman by jeanollion.
the class EVF method getEVFMap.
public static ImageFloat getEVFMap(SegmentedObject container, int[] referenceObjectClasses, boolean negativeInsideRef, double erodeContainer) {
double zAspectRatio = container.getScaleZ() / container.getScaleXY();
boolean parentIsPartOfRef = Arrays.stream(referenceObjectClasses).filter(i -> i == container.getStructureIdx()).findAny().isPresent();
// only parent
boolean refIsParent = parentIsPartOfRef && referenceObjectClasses.length == 1;
ImageFloat edt;
ImageMask mask, erosionMask = null;
if (refIsParent) {
mask = container.getMask();
edt = EDT.transform(mask, true, 1, zAspectRatio, false);
if (erodeContainer > 0) {
erosionMask = new PredicateMask(edt, erodeContainer, false, true);
mask = new SubtractedMask(mask, erosionMask);
}
} else {
ImageMask inside = getInsideMask(container, referenceObjectClasses);
mask = new SubtractedMask(container.getMask(), inside);
if (erodeContainer > 0) {
ImageFloat parentEdt = EDT.transform(container.getMask(), true, 1, zAspectRatio, false);
erosionMask = new PredicateMask(parentEdt, 0, true, erodeContainer, true);
mask = new SubtractedMask(mask, erosionMask);
}
if (parentIsPartOfRef)
edt = EDT.transform(mask, true, 1, zAspectRatio, false);
else
edt = EDT.transform(inside, false, 1, zAspectRatio, false);
if (negativeInsideRef) {
ImageFloat edtIn = EDT.transform(inside, true, 1, zAspectRatio, false);
ImageMask.loop(inside, (x, y, z) -> edt.setPixel(x, y, z, -edtIn.getPixel(x, y, z)));
mask = erodeContainer > 0 ? new SubtractedMask(container.getMask(), erosionMask) : container.getMask();
}
}
normalizeDistanceMap(edt, mask, erosionMask, parentIsPartOfRef);
edt.resetOffset().translate(container.getBounds());
return edt;
}
Aggregations