clojure2d.extra.segmentation

Segment image into parts.

Currently contains only quadtree segmentation.

Categories

    Other vars: *sequence-generator* segment-pixels

    *sequence-generator*

    dynamic

    Sequence generator used to select pixels for decision about subdivision. Defaults to R2 low-discrepancy sequence.

    segment-pixels

    (segment-pixels p ch)(segment-pixels p ch {:keys [min-size max-size threshold], :or {min-size 4, max-size 256, threshold 15.0}})

    Decompose channel ch from Pixels into square segments using quadtree decomposition.

    • min-size is minimum size of segment
    • max-size is maximum size
    • threshold is accuracy (minimum std dev of pixel values to make decision about subdivision).

    Returns lazy sequence of vectors containing x y size where x y is segment position and size is a side length.

    For segmentation, sequence generator (dynamic variable *sequence-generator* is used.

    Examples

    Usage

    (count (segment-pixels (p/load-pixels "docs/cockatoo.jpg") 0))
    ;;=> 705
    (nth (segment-pixels (p/load-pixels "docs/cockatoo.jpg")
                         0
                         {:min-size 2, :threshold 40})
         5)
    ;;=> [40 0 2]