pyproximal.optimization.segmentation.Segment#
- pyproximal.optimization.segmentation.Segment(y: ndarray[tuple[Any, ...], dtype[_ScalarT]], cl: ndarray[tuple[Any, ...], dtype[_ScalarT]], sigma: float, alpha: float, clsigmas: Optional[ndarray[tuple[Any, ...], dtype[_ScalarT]]] = None, z: Optional[ndarray[tuple[Any, ...], dtype[_ScalarT]]] = None, niter: int = 10, x0: Optional[ndarray[tuple[Any, ...], dtype[_ScalarT]]] = None, callback: Optional[Callable[[ndarray[tuple[Any, ...], dtype[_ScalarT]]], None]] = None, show: bool = False, kwargs_simplex: Optional[Dict[str, Any]] = None) Tuple[ndarray[tuple[Any, ...], dtype[_ScalarT]], ndarray[tuple[Any, ...], dtype[_ScalarT]]][source]#
Primal-dual algorithm for image segmentation
Perform image segmentation over \(N_{cl}\) classes using the general version of the first-order primal-dual algorithm [1].
- Parameters
- y
np.ndarray Image to segment (must have 2 or more dimensions)
- cl
numpy.ndarray Classes
- sigma
float Positive scalar weight of the misfit term
- alpha
float Positive scalar weight of the regularization term
- clsigmas
numpy.ndarray, optional Classes standard deviations
- z
numpy.ndarray, optional Additional vector
- niter
int, optional Number of iterations of iterative scheme
- x0
numpy.ndarray, optional Initial vector
- callback
callable, optional Function with signature (
callback(x)) to call after each iteration wherexis the current model vector- show
bool, optional Display iterations log
- kwargs_simplex
dict, optional Arbitrary keyword arguments for
pyproximal.Simplexoperator
- y
- Returns
- x
numpy.ndarray Classes probabilities. This is a vector of size \(N_{dim} \times N_{cl}\) whose columns contain the probability for each pixel to be in the class \(c_i\)
- cl
numpy.ndarray Estimated classes. This is a vector of the same size of the input data
ywith the selected classes at each pixel.
- x
Notes
This solver performs image segmentation over \(N_{cl}\) classes solving the following nonlinear minimization problem using the general version of the first-order primal-dual algorithm of [1]:
\[\min_{\mathbf{x} \in X} \frac{\sigma}{2} \mathbf{x}^T \mathbf{f} + \mathbf{x}^T \mathbf{z} + \frac{\alpha}{2}||\nabla \mathbf{x}||_{2,1}\]where \(X=\{ \mathbf{x}: \sum_{i=1}^{N_{cl}} x_i = 1,\; x_i \geq 0 \}\) is a simplex and \(\mathbf{f}=[\mathbf{f}_1, ..., \mathbf{f}_{N_{cl}}]^T\) with \(\mathbf{f}_i = |\mathbf{y}-c_i|^2/\sigma_i\). Here \(\mathbf{c}=[c_1, ..., c_{N_{cl}}]^T\) and \(\mathbf{\sigma}=[\sigma_1, ..., \sigma_{N_{cl}}]^T\) are vectors representing the optimal mean and standard deviations for each class.