# setConSplitMerge

Set functions to split and merge the contrast by a logical vector.

## Contents

- Syntax
- Description
- Example
- Input Arguments
- Output Arguments
- More About
- See Also
- Code

## Syntax

    seti = setConSplitMerge(seti)

## Description

`seti = setConSplitMerge(seti)` provides the function handles `seti.qObs` and `seti.qBack` to split the contrast into obstacle and background by a given logical vector `seti.obsMask`. Further, the function handle `seti.qMerge` can merge this two parts again.

## Example

    seti.nROI = 3;
    seti.dim = 2;
    maxind = seti.nROI^seti.dim;
    seti.obsMask = zeros(maxind,1); seti.obsMask([3:5,7]) = 1;
    seti.obsMask = logical(seti.obsMask);
    seti = setConSplitMerge(seti);
    q = 10.*transpose([1:maxind]);
    qObs = seti.qObs(q);
    qBack = seti.qBack(q);
    qMerge = seti.qMerge(qObs,qBack);

## Input Arguments

- `seti.nROI` : Discretization number of ROI for each dimension.
- `seti.dim` : Dimension of the problem.
- `seti.obsMask` : Mask in ROI characterinzing the probably obstacle area (stored as vector) (logical array of size seti.nROI^seti.dim x 1).

## Output Arguments

- `seti.qObs` : Function handle to get the obstacle part of the contrast.
- `seti.qBack` : Function handle to get the background part of the contrast.
- `seti.qMerge` : Function handle to merge obstacle and background parts again.

## More About

This functions are used to split and merge the contrast into two parts: the obstacle and the background. This can be used as a priori information from e.g. the factorization method to improve the reconstruction setting the background pixels to 0 using `fp2` as term of , see setInvType.html.

## See Also

- factorizationGuide.html

## Code

    function seti = setConSplitMerge(seti)

    ind = transpose(1:seti.nROI^seti.dim);

    % Split:
    seti.qObs = @(q) q(ind(seti.obsMask));
    seti.qBack = @(q) q(ind(seti.obsMask~=1));

    % Merge:
    seti.qMerge = @(qObs,qBack) qMerge(qObs,qBack,ind,seti);

    end

    function q = qMerge(qObs,qBack,ind,seti)
    q(ind(seti.obsMask)) = qObs;
    q(ind(seti.obsMask~=1)) = qBack;
    q = transpose(q);
    end