Region Competition plugin is based on the MOSAIC Discrete Region Competition algorithm for image segmentation.

.. figure:: resources/regionCompetition/rc.png

:scale: 75 %

:align: center

Region Competition (RC) in action

Developer Resources

===================

Source code and helpful information about MosaicSuite development can be found in :ref:`mosaicsuite-development` section.

Tutorial

========

Input/Output

------------

Algorithm requires following inputs:

- **Image source** Can be in any format recognized by ImageJ, the image is automaticaly converted into a floating point intensity image

- **Energy function** The segmentation is driven by the minimization of an energy function. In this plugin several energy functions or combinations of energy functions can be selected. In the following we introduce briefly all them, but for a complete explanation of which one use and in which situation look in the region competition paper.

- **Energy function parameters** The energy function in general have free parameter, that should be setted by the user or initialized to some default value

- **Label image source (optional)** This is an optional image that defines the initial segmentation from which the algoritm should start. If not given the default behaviour is to use an autogenerated starting labels image.

Output of a plugin:

- **Label output image** Output with segmentation, each found region is labelled with different color.

- **Animated iteration sequence** Is the evolution of the segmentation produced by the algorithm, can be saved in all imageJ supported formats.

- **Statistics** Information about found regions like size, coordinates, mean intensity, label etc.

Energy function parameters

--------------------------

Press Parameters button in the main window, you can tune global parameters like the maxium number of iteration and the oscillation threshold that control the convergence of the algorithm. You can also tune global parameters related to the energy, like Lambda and Theta that we will explain below.

Lambda E length: Is a scaling factor for the Energy length, this term in general is sensitive to the shape of the region

- **Theta E merge**

Factor needed for the merging energy function, this term implements model that controls the merging of two regions

- **Max Iteration**

Maximum number of iterations

- **Oscillation Threadshold**

This parameter controls the convergence of the algorithm in this way, at each iteration the global energy is stored, the standard deviation is calculated along all history and starting from the last 10 iterations.

- **E data**

This is the Energy part that depend from the input image, each model have an "options window" that can be opened pressing the near "Options" button. Energies that are possible to choose:

- PC

No Additional options are available.

.. figure:: resources/regionCompetition/E_pc.jpg

:scale: 75%

:align: center

- PS

**Radius**: Radius of the sphere where the mean of the intensity is calculated

**Beta Balloon force**: Beta controls the strenght of the Balloon force

.. figure:: resources/regionCompetition/E_ps.jpg

:scale: 75%

:align: center

- Deconvolution

**Open PSF Image**: Open an image and use it as Point Spread Function

**Generate**: Generate a gaussian PSF Image, before starting the simulation

.. figure:: resources/regionCompetition/E_dev.jpg

:scale: 75%

:align: center

- **E length (Energy Length model)**

From a practical point of view, this energy locally reduces concavity, tips , and globally the length of the countor region.

- Sphere Regularization

*Radius*: Radius of the hypersphere in the curvature regularization. The image show what happen when the segmentation is driven only by the Sphere Regularization energy term.

Before the simulation start, the normalized intensity image is shown, and it ask to user to draw a starting region using the selection tools of ImageJ, when done press shift to start the simulation.

- Local Maxima

the initial regions are created around the local maxima of the image, and the following three steps are performed.

- **Sigma**: The first stage is to apply a gaussian blur filter to the image with sigma variance.

- **Tolerance**: Find out the locals maxima according to the tollerance parameter. The maxima are accepted only if protruding more than this value from the ridge to a higher maximum. High value of tollerance means that only high local maxima will be accepted, reducing the Tolerance, increases the group of possible maxima accepted (from left to right in the image)

- **Region Tol**: Filter the regions found such that: If the region is smaller that "Region Tol", creates a bubble with radius (Radius) *1*, otherwise leave the region unchanged *2*