react-native-mask-segment-c.../dist/utils/activeContour.d.ts
a1518 3a3f07628d
Some checks failed
Deploy Docs to GitHub Pages / deploy (push) Has been cancelled
Publish to npm / publish (push) Has been cancelled
feat: add manual lasso wall splitting with magnetic edge-snapping and active contour refinement
- New magneticLasso module: Sobel energy map + Dijkstra shortest-path + Douglas-Peucker
- New activeContour module: greedy snake + balloon force for polygon-to-edge refinement
- wallTextureSplit: edge barrier mask, morphological mask hole closing, Moore boundary tracing, simplified polygon contours, manual pick map patching, gap absorption
- MaskSegmentCanvas: full lasso gesture pipeline (tap vertices, drag, magnetic paths, close polygon, endLasso/cancelLasso/deleteLasso)
- New maskConfig options: splitWallsEdgeBarrierThreshold, splitWallsCloseMaskRadius, manualSplitWalls, manualSplitWallsMaxCount, manualSplitWallsGapAbsorbDilatePx, magneticLasso, activeContourRefine
- New ref methods: startLasso, endLasso, cancelLasso, getManualRegions, deleteLasso
- New exported types: LassoPolygon, ManualWallPartition
- RegionMaskData carries indexToName and wallSemanticIdx through downsample
- Simplify README to point to documentation site
- Update documentation site (EN + ZH-CN) with all new APIs and interaction guide
- Example app: lasso mode toggles and operation buttons

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-07-06 20:23:57 -07:00

47 lines
1.9 KiB
TypeScript

/**
* Active Contour Model — greedy snake + balloon force.
*
* After the user finishes a lasso polygon, this module refines the boundary
* vertices outward toward the true wall-mask edge. Each vertex samples
* positions along its outward normal and picks the one with lowest energy.
*
* Pipeline:
* 1. Subdivide polygon to get evenly-spaced control points
* 2. For each iteration (3-5 rounds):
* a. Compute outward normal at each point
* b. Sample N positions along the normal (outward first, then inward)
* c. Score each position: E = E_edge + E_smooth
* d. Move vertex to min-energy position (constrained to wall mask)
* 3. Douglas-Peucker simplify
*/
import { type WallMaskSample } from './magneticLasso';
export type ActiveContourOpts = {
/** Number of greedy iterations (default 3). */
iterations?: number;
/** Number of sample positions along normal per direction (default 6). */
samplesPerDirection?: number;
/** Step size (norm coords) between samples (default 0.003). */
sampleStep?: number;
/** Smoothness weight — higher keeps vertices more uniformly spaced (default 0.15). */
smoothWeight?: number;
/** Edge weight — higher makes contour hug mask boundary (default 1.0). */
edgeWeight?: number;
/** Balloon bias — extra outward push per iteration (default 0.002). */
balloonForce?: number;
/** Minimum vertex count for a polygon to be refined (default 4). */
minVertices?: number;
};
/**
* Refine a single closed lasso polygon to hug the wall-mask outer boundary.
*
* Returns a new vertex list (not mutated in place). Returns the original
* polygon unchanged if it has too few vertices or no wall mask is given.
*/
export declare function refinePolygonToWallEdges(vertices: {
x: number;
y: number;
}[], mask: WallMaskSample, opts?: ActiveContourOpts): {
x: number;
y: number;
}[];