image-redaction
Operate Presidio image OCR redaction for standard images and DICOM pixel PHI.
- License 许可
- MIT
- 最近更新
- 2026-09-03
- Stars
- ★ 351
- Forks
- 27
01 前言 Front Matter
- name
- image-redaction
- license
- MIT
- metadata
- { "disco-role": "operating" }
- description
- Operate Presidio image OCR redaction for standard images and DICOM pixel PHI.
- disable-model-invocation
- true
02 资源文件 4
- 参考文档references/api-reference.md10.9 KB
- 参考文档references/ocr-and-dicom-workflows.md10.4 KB
- 参考文档references/troubleshooting.md9.4 KB
- 脚本scripts/image_ocr_smoke.py11.1 KB
03 SKILL.md 正文
image-redaction
Use this sub-skill when the task is about Presidio Image Redactor package workflows: OCR text detection in images, redacting image pixels, returning or validating bounding boxes, choosing the OCR engine, or handling DICOM burnt-in text redaction.
Use when
- You need
ImageRedactorEngine.redact()orredact_and_return_bbox()on a PIL image, image-like object, NumPy array, or image file path accepted by the image preprocessor. - You need
ImageAnalyzerEngine.analyze()to run OCR, feed extracted text through Presidio Analyzer, and map analyzer spans back to image bounding boxes. - You need
ImagePiiVerifyEngine.verify()for an annotated verification image showing OCR/PII boxes. - You need
DicomImageRedactorEnginefor DICOM pixel redaction from a loadedpydicominstance, one file, or a directory tree. - You need
DicomImagePiiVerifyEngineto create DICOM verification overlays or compute precision/recall against ground-truth bounding boxes. - You need to choose or troubleshoot
TesseractOCRversus optionalDocumentIntelligenceOCR. - You need
ImageRecognizerResult, bbox coordinate semantics, color/fill choices,ocr_kwargs, or analyzer kwargs passed through image workflows.
Route elsewhere
- Text analyzer tuning, recognizer design, entity/language lists, score thresholds, context, allow lists, NLP engine configuration, or missing spaCy model diagnosis beyond the image pass-through:
../analyze-text/SKILL.md. - Text anonymization operators or deanonymization:
../anonymize-text/SKILL.md. - HTTP service startup, Docker/container guidance, or REST endpoint use:
../../references/service-and-rest-api.md. - DICOM metadata de-identification: outside this sub-skill. This sub-skill only covers pixel redaction; metadata PHI must be scrubbed by a DICOM metadata de-identification workflow after pixel redaction.
Read first
references/api-reference.mdfor constructors, methods, return values, bbox shape, fill values, and kwarg routing.references/ocr-and-dicom-workflows.mdfor standard image, custom analyzer, Azure Document Intelligence, DICOM file/directory, and verification recipes.references/troubleshooting.mdfor missing Tesseract, empty OCR, analyzer/model failures, Azure credentials, pydicom/GDCM, and bbox/fill surprises.scripts/image_ocr_smoke.pyfor a no-source-path smoke check that imports the package, checks Tesseract, creates an in-memory image, and verifies at least one redaction bbox.
Operating checklist
- Confirm prerequisites:
presidio-image-redactoris importable; Tesseract is onPATHfor the defaultTesseractOCR; the default analyzer path hasen_core_web_lgunless you inject a custom analyzer that does not need it. - Decide OCR backend:
- Use
TesseractOCRby default for local image and DICOM workflows. - Use
DocumentIntelligenceOCRonly when Azure Document Intelligence credentials and one-page document constraints are acceptable.
- Use
- Decide analyzer behavior:
- Pass image workflow kwargs such as
language,entities,score_threshold,allow_list,allow_list_match, andcontextthrough to the underlyingAnalyzerEngine.analyze(). - Route recognizer/NLP design details to
../analyze-text/SKILL.md.
- Pass image workflow kwargs such as
- For standard images, choose
ImageRedactorEngine.redact()when only the image is needed; chooseredact_and_return_bbox()when you needImageRecognizerResultobjects for validation or downstream review. - For DICOM, choose
redact_and_return_bbox()for loaded instances andredact_from_file()/redact_from_directory()for filesystem workflows. Usesave_bboxes=Truewhen you need sidecar bbox JSON. - Treat
use_metadata=Trueas a pixel-detection aid only: it uses DICOM metadata terms to find matching burnt-in pixel text, but it does not remove or alter metadata PHI. - When a run returns no boxes, debug in this order: Tesseract availability, raw OCR words, image resolution/contrast/orientation,
ocr_threshold, analyzer kwargs/entities/language/model, then bbox mapping.
Fast facts
- Standard-image
fillis an integer grayscale value or an RGB tuple, for example1,255, or(255, 0, 0). - DICOM
fillis"contrast"/"invert"/"inverted"/"inverse"for a contrasting mask, or"background"/"bg"for a background-like mask. ocr_kwargsis forwarded to the OCR backend after image code stripsocr_threshold;ocr_thresholdaccepts values from-1through100.- Analyzer kwargs are passed through to Presidio Analyzer; keep complex analyzer construction in
../analyze-text/SKILL.mdand inject the resultingAnalyzerEngineintoImageAnalyzerEngine. ImageRecognizerResulthas text span fields plus pixel fields:entity_type,start,end,score,left,top,width,height.- Multi-word or overlapping analyzer results can produce multiple boxes for one entity; overlapping image boxes can represent different entity labels for the same OCR word.
- DICOM file/directory helpers duplicate inputs into the requested output directory before editing; loaded-instance methods return a copied in-memory dataset.
04 同仓库更多 Skills
passnet-triton-opt
Make a single PassNet Triton kernel fast AND numerically faithful: performance model (when a replacement can win at all), block/grid/warp tuning, autotune policy, launch overhead, and per-op numeric recipes to pass the dtype baseline tolerances. Use when a pass matches and is correct but speedup below expected, or when correctness fails by small numeric margins.
passnet-solve
END-TO-END playbook for solving one PassNet sample: analyze the computation graphs, decide the optimization strategy (what to fuse, what to replace, what to leave alone), drive the iteration loop, and maximize the sample score. This is the ENTRY skill — invoke it first for any PassNet optimization task; it tells you when to use passnet-pattern-fusion, passnet-triton-opt and passnet-feedback.
passnet-skill
PassNet GPU kernel optimization via compiler passes. Design and implement Triton-based optimization passes, create pass files under ./pass_dir/, self-evaluate with pass_evaluator, and iterate to maximize GPU speedup.
passnet-pattern-fusion
Author PassNet pass files: write patterns that actually MATCH the FX graph, pick fusion regions (which ops to absorb into one Triton kernel), and structure multi-pass submissions with the mandatory shared-dispatch architecture. Use when creating or fixing pattern()/replacement_args()/replacement_func() files, when a pass "failed to match", or when deciding how to fuse multiple kernels/ops.
passnet-orchestrate
Round/batch planning and decision support for PassNet graph optimization. Use for multi-sample triage, worker allocation, eval-budget policy, and post-eval keep/revert decisions. For solving one concrete sample end to end, use passnet-solve as the entry skill; consult this skill only when you need broader planning or a specific decision gate.
passnet-feedback
Fast, deterministic feedback for PassNet work: pre-flight pattern/match verification WITHOUT burning a GPU evaluation, per-node bottleneck analysis of a sample's graphs, and eval-log parsing into per-variant status + estimated score + failure classification. Use BEFORE every GPU evaluation (check_pattern), at the START of a sample (analyze_graph), and AFTER every evaluation (parse_eval_log).