+
    Ai                         ^ RI Ht  ^ RIHt ^ RIHt Rt ! R R	4      t	R
 t
R tR#   ] d    Rt ! R R]4      t L(i ; i)    )multiscale_basic_features)NotFittedError)RandomForestClassifierTFc                       ] tR t^tRtR# )r    N)__name__
__module____qualname____firstlineno____static_attributes__r       c/var/www/html/photoedit/myenv/lib/python3.14/site-packages/skimage/future/trainable_segmentation.pyr   r      s    r   r   c                   @   a  ] tR t^t o RtRR ltR tR tR tRt	V t
R# )	TrainableSegmenteraX  Estimator for classifying pixels.

Parameters
----------
clf : classifier object, optional
    classifier object, exposing a ``fit`` and a ``predict`` method as in
    scikit-learn's API, for example an instance of
    ``RandomForestClassifier`` or ``LogisticRegression`` classifier.
features_func : function, optional
    function computing features on all pixels of the image, to be passed
    to the classifier. The output should be of shape
    ``(m_features, *labels.shape)``. If None,
    :func:`skimage.feature.multiscale_basic_features` is used.

Methods
-------
compute_features
fit
predict
Nc                z    Vf+   \         '       d   \        ^dRR7      V n        M\        R4      hWn        W n        R # )N)n_estimatorsn_jobszOPlease install scikit-learn or pass a classifier instanceto TrainableSegmenter.)has_sklearnr   clfImportErrorfeatures_func)selfr   r   s   &&&r   __init__TrainableSegmenter.__init__%   s9    ;{1s2N!- 
 H*r   c                d    V P                   f   \        V n         V P                  V4      V n        R # )N)r   r   features)r   images   &&r   compute_features#TrainableSegmenter.compute_features2   s(    %!:D**51r   c                h    V P                  V4       \        W P                  V P                  4       R# )a  Train classifier using partially labeled (annotated) image.

Parameters
----------
image : ndarray
    Input image, which can be grayscale or multichannel, and must have a
    number of dimensions compatible with ``self.features_func``.
labels : ndarray of ints
    Labeled array of shape compatible with ``image`` (same shape for a
    single-channel image). Labels >= 1 correspond to the training set and
    label 0 to unlabeled pixels to be segmented.
N)r   fit_segmenterr   r   )r   r   labelss   &&&r   fitTrainableSegmenter.fit7   s$     	e$fmmTXX6r   c                    V P                   f   \        V n         V P                  V4      p\        W P                  4      # )a@  Segment new image using trained internal classifier.

Parameters
----------
image : ndarray
    Input image, which can be grayscale or multichannel, and must have a
    number of dimensions compatible with ``self.features_func``.

Raises
------
NotFittedError if ``self.clf`` has not been fitted yet (use ``self.fit``).
)r   r   predict_segmenterr   )r   r   r   s   && r   predictTrainableSegmenter.predictG   s7     %!:D%%e, 8844r   )r   r   r   )NN)r   r	   r
   r   __doc__r   r   r$   r(   r   __classdictcell__)__classdict__s   @r   r   r      s#     *+2
7 5 5r   r   c                n    V ^ 8  pW,          pW,          P                  4       pVP                  WE4       V# )a  Segmentation using labeled parts of the image and a classifier.

Parameters
----------
labels : ndarray of ints
    Image of labels. Labels >= 1 correspond to the training set and
    label 0 to unlabeled pixels to be segmented.
features : ndarray
    Array of features, with the first dimension corresponding to the number
    of features, and the other dimensions correspond to ``labels.shape``.
clf : classifier object
    classifier object, exposing a ``fit`` and a ``predict`` method as in
    scikit-learn's API, for example an instance of
    ``RandomForestClassifier`` or ``LogisticRegression`` classifier.

Returns
-------
clf : classifier object
    classifier trained on ``labels``

Raises
------
NotFittedError if ``self.clf`` has not been fitted yet (use ``self.fit``).
)ravelr$   )r#   r   r   masktraining_datatraining_labelss   &&&   r   r"   r"   Z   s5    2 A:DNMl((*OGGM+Jr   c                   V P                   pV P                  ^8  d   V P                  RVR,          34      p  VP                  V 4      pTP                  TRR 4      pT#   \         d    \	        R4      h\
         d\   pTP                  '       dC   RTP                  ^ ,          9   d+   \        TP                  ^ ,          R,           R,           4      hThRp?ii ; i)a  Segmentation of images using a pretrained classifier.

Parameters
----------
features : ndarray
    Array of features, with the last dimension corresponding to the number
    of features, and the other dimensions are compatible with the shape of
    the image to segment, or a flattened image.
clf : classifier object
    trained classifier object, exposing a ``predict`` method as in
    scikit-learn's API, for example an instance of
    ``RandomForestClassifier`` or ``LogisticRegression`` classifier. The
    classifier must be already trained, for example with
    :func:`skimage.future.fit_segmenter`.

Returns
-------
output : ndarray
    Labeled array, built from the prediction of the classifier.
zWYou must train the classifier `clf` firstfor example with the `fit_segmenter` function.z#x must consist of vectors of length
zLMaybe you did not use the same type of features for training the classifier.Nr   )shapendimreshaper(   r   
ValueErrorargs)r   r   shpredicted_labelserroutputs   &&    r   r'   r'   z   s    * 
B}}q##RBL1;;x0 %%b"g.FM  
=
 	
  888=!L`a  Is   A   C?C ACCN)skimage.featurer   sklearn.exceptionsr   sklearn.ensembler   r   r   	Exceptionr   r"   r'   r   r   r   <module>rA      sS    5	17KH5 H5V@*e  K s   ( ??