thresholding-strategy

thresholding-strategy is a skill for Claude Code, Codex from aeren23/image-processing-skills. It costs 27 tokens per session (1,497 once invoked), scanned A, original, MIT.

A guide for choosing image thresholding methods that turn an image into foreground and background regions. It covers global, Otsu, and adaptive thresholding, plus contrast improvement with CLAHE.

In plain words
What is it for?
Use it to prepare images for separating objects, detecting contours, or applying shape operations. It helps select threshold settings and improve low-contrast images.
Why use it?
The right method depends on lighting and contrast: one method suits evenly lit images, another estimates the cutoff automatically, and another handles shadows or uneven lighting. The guide helps choose and tune preprocessing before image segmentation.

Skill for Claude CodeCodex

Written for no agent in particular: nothing here depends on one.

Good fit Use it to prepare images for separating objects, detecting contours, or applying shape operations. It helps select threshold settings and improve low-contrast images.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/aeren23/image-processing-skills/03-thresholding-strategy
Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

Any agent
npx skills add aeren23/image-processing-skills --skill 03-thresholding-strategy
Clone the repo
git clone --depth 1 https://github.com/aeren23/image-processing-skills

Made for: Claude Code, Codex.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for thresholding-strategy

README.md
[![agentmods](https://agentmods.dev/badge/skills/aeren23/image-processing-skills/03-thresholding-strategy.svg)](https://agentmods.dev/skills/aeren23/image-processing-skills/03-thresholding-strategy)
Your own site
<a href="https://agentmods.dev/skills/aeren23/image-processing-skills/03-thresholding-strategy"><img src="https://agentmods.dev/badge/skills/aeren23/image-processing-skills/03-thresholding-strategy.svg" alt="Measured on agentmods" height="20"></a>
Per session 27 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 1,497 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.00027 $0.01497
Opus 5 $0.00014 $0.00749
Sonnet 5 $0.00005 $0.00299
Haiku 4.5 $0.00003 $0.00150

Measured 8d ago against content hash aef87d291f95, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-08, from the pricing page.

Security

Grade A, and why

thresholding-strategy scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 8d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

skills/03-thresholding-strategy/SKILL.md · 162 lines

How it starts

The opening of the file, as written. The whole thing — 162 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Thresholding Strategy

When to Use This Skill

  • Converting an image to binary (black/white) for segmentation
  • Separating foreground objects from background
  • Preprocessing before contour detection or morphological operations
  • Improving contrast on low-contrast images
  • Working with images that have uneven lighting or shadows

Decision Framework

Which Thresholding Method?

Image lighting conditions?
├── Uniform lighting, good contrast
│   ├── You know the ideal threshold value
│   │   └── ✅ Global Threshold (cv2.threshold)
│   └── You don't know the ideal value
│       └── ✅ Otsu's Method (automatic optimal threshold)
│
├── Uneven lighting / shadows present
│   └── ✅ Adaptive Threshold (cv2.adaptiveThreshold)
│       ├── General use → ADAPTIVE_THRESH_MEAN_C
│       └── Text/document → ADAPTIVE_THRESH_GAUSSIAN_C (better)
│
└── Very low contrast (details invisible)
    └── First enhance contrast, THEN threshold:
        ├── Moderate enhancement → Histogram Stretching
        ├── Strong enhancement → Histogram Equalization
        └── Local enhancement → CLAHE (best for most cases)

Contrast Enhancement Comparison

Method Function Effect Best For
Histogram Stretching cv2.normalize(NORM_MINMAX) Linear rescale min→0, max→255 Natural-looking enhancement
Histogram Equalization cv2.equalizeHist() Aggressive CDF-based redistribution Maximum contrast, looks artificial
CLAHE cv2.createCLAHE() Local adaptive equalization Medical images, preserves local detail

Default choice: CLAHE. It provides strong enhancement without the over-amplification artifacts of global equalization.

Global Threshold Types

Type Above Threshold Below Threshold Use Case
THRESH_BINARY White (255) Black (0) Standard foreground extraction
THRESH_BINARY_INV Black (0) White (255) Dark objects on light background
THRESH_TRUNC Clamped to threshold Unchanged Brightness capping
THRESH_TOZERO Unchanged Set to 0 Keep only bright regions
THRESH_TOZERO_INV Set to 0 Unchanged Keep only dark regions

Read the full file on GitHub · 162 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 8d ago First seen · 162 lines · 27 tokens per session scan A aef87d291f95

Subscribe to this mod's changes

thresholding-strategy is a skill published in the GitHub repository aeren23/image-processing-skills (5 stars, last pushed 3mo ago), licensed MIT. It adds 27 tokens to every session and 1,497 once invoked, about $0.0001 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-31.

Related

Other skills, from other repositories

Cell Segmentation Skills Index

Cell and nucleus segmentation tools for microscopy images. Covers Cellpose, SAM-based methods, StarDist, InstanSeg, and Mesmer.

aristoteleo/PantheonOS · 35 tokens

Bio Image Processing Skills Index

Skills for biological image analysis: cell/nucleus segmentation, image restoration, and spatial data processing.

aristoteleo/PantheonOS · 25 tokens

tao-train-mask2former

Mask2Former for universal image segmentation (panoptic, instance, and semantic). Transformer-based with masked attention for high-quality segmentation results. Use when training, evaluating, exporting, quantizing, or running inference for a TAO Mask2Former model. Trigger phrases include "train Mask2Former", "universal…

NVIDIA-TAO/tao-skill-bank · 89 tokens

tao-train-mask-grounding-dino

Mask Grounding DINO for grounded instance segmentation. Extends Grounding DINO with a mask-prediction head for open-set segmentation guided by text prompts. Use when training, evaluating, exporting, quantizing, or running inference for a TAO Mask-Grounding-DINO model. Trigger phrases include "train Mask Grounding…

NVIDIA-TAO/tao-skill-bank · 100 tokens

tao-train-mask-auto-label

MAL (Mask Auto-Label) for weakly-supervised segmentation. Produces segmentation masks from minimal annotations (point or box annotations) using a ViT-MAE backbone. Use when training, evaluating, or running inference for a TAO MAL model. Trigger phrases include "train MAL", "Mask Auto-Label", "weakly-supervised…

NVIDIA-TAO/tao-skill-bank · 94 tokens

genomics-cnv-calling

Load when calling CNV segments via CBS-style segmentation on a bin-level log2-ratio CSV from exome / WGS coverage — emits per-segment 5-class CN state (amplification / gain / neutral / loss / deepdeletion), per-chromosome summary, genome-fraction-altered. Skip when working with single-cell / spatial CNV (use…

TianGzlab/OmicsClaw · 95 tokens