Search in sources :

Example 1 with ImageFloat

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;
}
Also used : ImageFloat(bacmman.image.ImageFloat)

Example 2 with ImageFloat

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;
}
Also used : BlankMask(bacmman.image.BlankMask) ImageInteger(bacmman.image.ImageInteger) Iterator(java.util.Iterator) Predicate(java.util.function.Predicate) Collection(java.util.Collection) BiFunction(java.util.function.BiFunction) Set(java.util.Set) ImageShort(bacmman.image.ImageShort) HashMap(java.util.HashMap) EllipsoidalNeighborhood(bacmman.processing.neighborhood.EllipsoidalNeighborhood) Function(java.util.function.Function) TreeSet(java.util.TreeSet) RegionPopulation(bacmman.data_structure.RegionPopulation) BooleanSupplier(java.util.function.BooleanSupplier) HashSet(java.util.HashSet) Voxel(bacmman.data_structure.Voxel) List(java.util.List) bacmman.image(bacmman.image) ImageFloat(bacmman.image.ImageFloat) Map(java.util.Map) ImageMask(bacmman.image.ImageMask) Comparator(java.util.Comparator) Region(bacmman.data_structure.Region) ImageLabeller(bacmman.image.ImageLabeller) ImageFloat(bacmman.image.ImageFloat)

Example 3 with ImageFloat

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;
}
Also used : ImagePlus(ij.ImagePlus) ImageFloat(bacmman.image.ImageFloat)

Example 4 with ImageFloat

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;
}
Also used : ImageFloat(bacmman.image.ImageFloat)

Example 5 with ImageFloat

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;
}
Also used : ImageMask(bacmman.image.ImageMask) PredicateMask(bacmman.image.PredicateMask) SubtractedMask(bacmman.image.SubtractedMask) ImageFloat(bacmman.image.ImageFloat)

Aggregations

ImageFloat (bacmman.image.ImageFloat)51 Image (bacmman.image.Image)20 ImageByte (bacmman.image.ImageByte)10 ArrayList (java.util.ArrayList)8 ImageShort (bacmman.image.ImageShort)6 EllipsoidalNeighborhood (bacmman.processing.neighborhood.EllipsoidalNeighborhood)6 Core (bacmman.core.Core)5 RegionPopulation (bacmman.data_structure.RegionPopulation)5 ImageMask (bacmman.image.ImageMask)5 Aspects (imagescience.image.Aspects)5 Arrays (java.util.Arrays)5 List (java.util.List)5 Map (java.util.Map)5 Region (bacmman.data_structure.Region)4 SegmentedObject (bacmman.data_structure.SegmentedObject)4 Hint (bacmman.plugins.Hint)4 Utils (bacmman.utils.Utils)4 bacmman.configuration.parameters (bacmman.configuration.parameters)3 Voxel (bacmman.data_structure.Voxel)3 bacmman.image (bacmman.image)3