Skip to content
/ cast-off Public

Automatic Mask Removal for Color Negative Films.

Notifications You must be signed in to change notification settings

TCDCY/cast-off

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

53 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Negative Film Mask Removal Tool

Automatically remove color mask from camera raw film scans.

Quick Start

Process order.

stages = [
    RawLoadStage("LoadRAW"),
    BorderExtractStage("BorderExtract"),
    ColorClassifyStage("ColorClassify"),
    WhiteBalanceComputeStage("WBCompute"),
    WhiteBalanceApplyStage("WBApply"),
    InvertStage("Invert"),
    LevelRegionSelectStage("LevelRegionSelect"),
    LevelAdjustStage("LevelAdjust"),
    ToneAdjustStage("ToneAdjust"),
]
  1. black/white point auto tune by threshold first
  2. overwrite with specific black/white if --tone-white, --tone-black, --level-white-point is not None
image
  • run:
python cast_off.py ./RAW.dng --border u0.02 --level-pixel-threshold 0.0001  --wb-ix 4,3 --debug --visualize  --tone-pixel-threshold 0.02  --center-ratio 0.8 --tone-black 37000
  • get vis like:

RAW_1769685698_vis

  • output:

RAW_1769685698

Save preset

python cast_off.py ./ZFC_5837.NEF --border l0.1,r0.1 --level-pixel-threshold r0.001,g0.001,b0.03  --wb-ix 4,1 --debug --visualize  --tone-pixel-threshold 0.03  --tone-white 64000 --level-white-point "b61000" --save-preset ./preset.pkl

Load preset

python cast_off.py ./ZFC_5837.NEF --load-preset ./preset.pkl -o "new_{name}.png"

Processing Pipeline

  1. White Balance: Compute white balance from border area, apply to entire image
    • Classify border pixels into clusters by brightness
    • Select specific clusters for white balance calculation
    • --wb-ix 4,0,1 means 4 clusters, select [0, 1] to compute wb.
  2. Invert: Invert all 3 RGB channels (negative to positive)
  3. Level Adjustment: Redefine black and white points
    • Automatically calculate percentile threshold for each channel
  4. Luminance Adjustment
    • Set black/white point from [0, 65535]

About

Automatic Mask Removal for Color Negative Films.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages