Skip to content

refactor(imgproc): de-duplicate imgproc module (#47)#63

Merged
kalwalt merged 1 commit into
feat/refactor-jsfeat-nextfrom
refactor/47-dedup-imgproc
Jul 8, 2026
Merged

refactor(imgproc): de-duplicate imgproc module (#47)#63
kalwalt merged 1 commit into
feat/refactor-jsfeat-nextfrom
refactor/47-dedup-imgproc

Conversation

@kalwalt

@kalwalt kalwalt commented Jul 8, 2026

Copy link
Copy Markdown
Member

Second slice of #47, following the pattern proven in #62 (core base class + math). Guarded by the 57-test parity suite — 14 of those tests pin imgproc bit-for-bit against original jsfeat.

What changed

  • src/imgproc/imgproc.ts — the type-only stub (all methods throw "Method not implemented") is replaced by the real implementation, moved verbatim from the monolith (mechanical sed line-range extraction): grayscale, resample, box_blur_gray, gaussian_blur, hough_transform, pyrdown, scharr_derivatives, sobel_derivatives, compute_integral_image, equalize_histogram, canny, warp_perspective, warp_affine, skindetector.
  • One deliberate change: gaussian_blur instantiates math via a direct module import (../math/math) instead of the jsfeatNext.math static slot — same class, but removes an attach-order dependency on the aggregator.
  • src/jsfeatNext.ts shrinks by ~1050 lines (now ~2350, from the original ~3900).

Bonus: latent trap healed

src/orb/rectify_patch.ts imports imgproc — until now that resolved to the throwing stub (a known audit finding). It now gets the real implementation with zero changes to that file.

Verification

  • tsc --noEmit → clean
  • npm test57/57 (imgproc suite = bit-for-bit oracle match)
  • UMD bundle checked: instanceof chain, static-constant inheritance, grayscale + gaussian_blur smoke test on the built artifact
  • dist//types/ untouched (release-time rebuild, per precedent)

Advances #47. Next in queue: fast_cornerspyramid_tlinalgorbyape06motion_estimatoroptical_flow_lk.

🤖 Generated with Claude Code

Second de-duplication step of #47, following the pattern proven in #62.

- src/imgproc/imgproc.ts: replace the type-only stub with the REAL
  implementation moved verbatim from the monolith (grayscale, resample,
  box_blur_gray, gaussian_blur, hough_transform, pyrdown, scharr/sobel
  derivatives, compute_integral_image, equalize_histogram, canny,
  warp_perspective, warp_affine, skindetector). Only deliberate change:
  gaussian_blur instantiates the math module directly (import from
  ../math/math) instead of via the jsfeatNext.math static slot, removing
  an attach-order dependency on the aggregator.
- src/jsfeatNext.ts: shrinks by ~1050 lines; attaches imgproc from its
  module (jsfeatNext.imgproc = imgproc).
- Side effect: the latent trap in src/orb/rectify_patch.ts (it imports
  imgproc, which until now was the throwing stub) is healed — it resolves
  to the real implementation.

Verified behavior-preserving: tsc --noEmit clean; npm test 57/57 (14 of
those pin imgproc bit-for-bit vs original jsfeat); UMD build checked
(instanceof chain, static-constant inheritance, grayscale + gaussian_blur
smoke on the bundle).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@kalwalt kalwalt added this to the Parity & Modernization milestone Jul 8, 2026
@kalwalt kalwalt self-assigned this Jul 8, 2026
@kalwalt kalwalt added enhancement New feature or request Typescript all about Typescript javascript tests labels Jul 8, 2026
@kalwalt kalwalt changed the base branch from dev to feat/refactor-jsfeat-next July 8, 2026 09:46
@kalwalt kalwalt merged commit bd48ed8 into feat/refactor-jsfeat-next Jul 8, 2026
4 checks passed
kalwalt added a commit that referenced this pull request Jul 8, 2026
Third de-duplication step of #47, following the #62/#63 pattern.

- src/fast_corners/fast_corners.ts: replace the type-only stub with the
  REAL implementation moved verbatim from the monolith (set_threshold,
  detect, _cmp_offsets; imports _cmp_score_16 from ./fast_private, which
  was already a real module).
- src/jsfeatNext.ts: shrinks by ~225 lines; attaches fast_corners from its
  module.

Verified behavior-preserving: tsc --noEmit clean; npm test 57/57 (detector
parity suite pins fast_corners.detect against original jsfeat); UMD bundle
smoke-checked (instanceof chain, static inheritance, corner detection on a
synthetic image).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
kalwalt added a commit that referenced this pull request Jul 8, 2026
Third de-duplication step of #47, following the #62/#63 pattern.

- src/fast_corners/fast_corners.ts: replace the type-only stub with the
  REAL implementation moved verbatim from the monolith (set_threshold,
  detect, _cmp_offsets; imports _cmp_score_16 from ./fast_private, which
  was already a real module).
- src/jsfeatNext.ts: shrinks by ~225 lines; attaches fast_corners from its
  module.

Verified behavior-preserving: tsc --noEmit clean; npm test 57/57 (detector
parity suite pins fast_corners.detect against original jsfeat); UMD bundle
smoke-checked (instanceof chain, static inheritance, corner detection on a
synthetic image).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
kalwalt added a commit that referenced this pull request Jul 9, 2026
Third de-duplication step of #47, following the #62/#63 pattern.

- src/fast_corners/fast_corners.ts: replace the type-only stub with the
  REAL implementation moved verbatim from the monolith (set_threshold,
  detect, _cmp_offsets; imports _cmp_score_16 from ./fast_private, which
  was already a real module).
- src/jsfeatNext.ts: shrinks by ~225 lines; attaches fast_corners from its
  module.

Verified behavior-preserving: tsc --noEmit clean; npm test 57/57 (detector
parity suite pins fast_corners.detect against original jsfeat); UMD bundle
smoke-checked (instanceof chain, static inheritance, corner detection on a
synthetic image).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@kalwalt kalwalt deleted the refactor/47-dedup-imgproc branch July 10, 2026 11:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request javascript tests Typescript all about Typescript

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant