// Generated file. To retain edits, remove this comment.
import { InterfaceTypes, runPipeline } from 'itk-wasm';
import { getPipelinesBaseUrl } from './pipelines-base-url.js';
import { getPipelineWorkerUrl } from './pipeline-worker-url.js';
import { getDefaultWebWorker } from './default-web-worker.js';
/**
 * Interpolates contours between slices.
 *
 * @param {Image} inputImage - The input image
 * @param {MorphologicalContourInterpolationOptions} options - options object
 *
 * @returns {Promise<MorphologicalContourInterpolationResult>} - result object
 */
async function morphologicalContourInterpolation(inputImage, options = {}) {
    const desiredOutputs = [
        { type: InterfaceTypes.Image },
    ];
    const inputs = [
        { type: InterfaceTypes.Image, data: inputImage },
    ];
    const args = [];
    // Inputs
    const inputImageName = '0';
    args.push(inputImageName);
    // Outputs
    const outputImageName = '0';
    args.push(outputImageName);
    // Options
    args.push('--memory-io');
    if (options.label) {
        args.push('--label', options.label.toString());
    }
    if (options.axis) {
        args.push('--axis', options.axis.toString());
    }
    if (options.noHeuristicAlignment) {
        options.noHeuristicAlignment && args.push('--no-heuristic-alignment');
    }
    if (options.noUseDistanceTransform) {
        options.noUseDistanceTransform && args.push('--no-use-distance-transform');
    }
    if (options.useCustomSlicePositions) {
        options.useCustomSlicePositions && args.push('--use-custom-slice-positions');
    }
    if (options.noUseExtrapolation) {
        options.noUseExtrapolation && args.push('--no-use-extrapolation');
    }
    if (options.useBallStructuringElement) {
        options.useBallStructuringElement && args.push('--use-ball-structuring-element');
    }
    if (options.labeledSliceIndicesAxis) {
        args.push('--labeled-slice-indices-axis', options.labeledSliceIndicesAxis.toString());
    }
    if (options.labeledSliceIndicesLabel) {
        args.push('--labeled-slice-indices-label', options.labeledSliceIndicesLabel.toString());
    }
    if (options.labeledSliceIndices) {
        if (options.labeledSliceIndices.length < 1) {
            throw new Error('"labeled-slice-indices" option must have a length > 1');
        }
        args.push('--labeled-slice-indices');
        await Promise.all(options.labeledSliceIndices.map(async (value) => {
            args.push(value.toString());
        }));
    }
    const pipelinePath = 'morphological-contour-interpolation';
    let workerToUse = options?.webWorker;
    if (workerToUse === undefined) {
        workerToUse = await getDefaultWebWorker();
    }
    const { webWorker: usedWebWorker, returnValue, stderr, outputs } = await runPipeline(pipelinePath, args, desiredOutputs, inputs, { pipelineBaseUrl: getPipelinesBaseUrl(), pipelineWorkerUrl: getPipelineWorkerUrl(), webWorker: workerToUse, noCopy: options?.noCopy });
    if (returnValue !== 0 && stderr !== "") {
        throw new Error(stderr);
    }
    const result = {
        webWorker: usedWebWorker,
        outputImage: outputs[0]?.data,
    };
    return result;
}
export default morphologicalContourInterpolation;
//# sourceMappingURL=morphological-contour-interpolation.js.map