Search in sources :

Example 1 with OptionsMisc

use of net.imagej.options.OptionsMisc in project imagej-plugins-commands by imagej.

the class ReciprocalDataValues method run.

// -- public interface --
@Override
public void run() {
    Dataset dataset = imgDispService.getActiveDataset(display);
    Overlay overlay = overlayService.getActiveOverlay(display);
    DatasetView view = imgDispService.getActiveDatasetView(display);
    final OptionsMisc optionsMisc = optionsService.getOptions(OptionsMisc.class);
    final String dbzString = optionsMisc.getDivByZeroVal();
    double dbzVal;
    try {
        dbzVal = Double.parseDouble(dbzString);
    } catch (final NumberFormatException e) {
        dbzVal = Double.POSITIVE_INFINITY;
    }
    final RealReciprocal<DoubleType, DoubleType> op = new RealReciprocal<DoubleType, DoubleType>(dbzVal);
    final InplaceUnaryTransform<T, DoubleType> transform;
    if (allPlanes)
        transform = new InplaceUnaryTransform<T, DoubleType>(op, new DoubleType(), dataset, overlay);
    else
        transform = new InplaceUnaryTransform<T, DoubleType>(op, new DoubleType(), dataset, overlay, view.getPlanePosition());
    transform.run();
}
Also used : DatasetView(net.imagej.display.DatasetView) Dataset(net.imagej.Dataset) RealReciprocal(net.imglib2.ops.operation.real.unary.RealReciprocal) DoubleType(net.imglib2.type.numeric.real.DoubleType) Overlay(net.imagej.overlay.Overlay) OptionsMisc(net.imagej.options.OptionsMisc)

Example 2 with OptionsMisc

use of net.imagej.options.OptionsMisc in project imagej-plugins-commands by imagej.

the class DivideDataValuesBy method getOperation.

@Override
public RealDivideConstant<DoubleType, DoubleType> getOperation() {
    final OptionsMisc optionsMisc = optionsService.getOptions(OptionsMisc.class);
    final String dbzString = optionsMisc.getDivByZeroVal();
    double dbzVal;
    try {
        dbzVal = Double.parseDouble(dbzString);
    } catch (final NumberFormatException e) {
        dbzVal = Double.POSITIVE_INFINITY;
    }
    return new RealDivideConstant<DoubleType, DoubleType>(value, dbzVal);
}
Also used : RealDivideConstant(net.imglib2.ops.operation.real.unary.RealDivideConstant) OptionsMisc(net.imagej.options.OptionsMisc)

Aggregations

OptionsMisc (net.imagej.options.OptionsMisc)2 Dataset (net.imagej.Dataset)1 DatasetView (net.imagej.display.DatasetView)1 Overlay (net.imagej.overlay.Overlay)1 RealDivideConstant (net.imglib2.ops.operation.real.unary.RealDivideConstant)1 RealReciprocal (net.imglib2.ops.operation.real.unary.RealReciprocal)1 DoubleType (net.imglib2.type.numeric.real.DoubleType)1