Keep mouth crops independent of teeth settings

This commit is contained in:
Olive Vaughn 2026-09-28 09:06:30 -04:00
parent 7738c4e1c8
commit 7249e73e7c
3 changed files with 34 additions and 12 deletions

View file

@ -0,0 +1,22 @@
(ns arthur.flow.measure.interior-test
(:require [cljs.test :refer [deftest is]]
[arthur.flow.measure.interior :as interior]))
(def ^:private ring
[{:x 0.2 :y 0.2} {:x 0.8 :y 0.2}
{:x 0.8 :y 0.8} {:x 0.2 :y 0.8}])
(defn- region-size [box cavity-erode]
(let [image #js {:data (js/Uint8ClampedArray. (* 4 (:w box) (:h box)))}
result (interior/measure
{:cavity-erode cavity-erode :tongue-reject 0.1 :blob-grow 0
:top-bias 0 :teeth-verts 8 :min-area 1 :debug? true}
box image)]
(count (filter pos? (array-seq (get-in result [:debug :region]))))))
(deftest the-crop-is-reusable-while-cavity-erosion-changes-the-measurement
(let [box (interior/crop ring [100 100])]
(is (= ring (:shape box)))
(is (= [20 20 60 60] ((juxt :x :y :w :h) box)))
(is (= 3600 (region-size box 0)))
(is (= 2304 (region-size box 0.2)))))