2.6 KiB
2.6 KiB
AutoCropBorders
AutoCropBorders trims uniform borders from photos—think scanner edges, letterbox bars, or projector frames—before the image moves deeper into your workflow.
Inputs
image– The photo you want to clean; connect any RGB image tensor.fuzz_mode– Choose how tolerant the detector should be:adaptivewidens the tolerance automatically based on border noise.percentsticks to the value fromfuzz_percent.
fuzz_percent– Maximum colour variation allowed whenpercentmode is active. Lower values assume a perfectly uniform border.adaptive_k– Multiplier used inadaptivemode; higher values accept noisier borders.edge_margin_px– Width of the strip sampled on each side to learn the border colour. Increase for thicker frames.pad_px– Expand the final crop box by this many pixels if you want a little breathing room.use_luma_only– WhenTrue, the decision runs on brightness only instead of full RGB. Handy for black-and-white content.max_growth_iter– Safety cap on how many expansion steps the border mask can take.return_border_mask– Toggle to output the detected border mask alongside the cropped image.use_gpu– WhenTrue, temporary tensors jump to CUDA. Disable on tight VRAM budgets.
Outputs
image– The cropped photo with even width and height where possible.left,top,width,height– Crop rectangle relative to the original image.border_mask– Binary mask of removed borders (zeroed out when the mask output is disabled).
Where It Fits
Use AutoCropBorders on scanned headshots or production stills before resizing or running diffusion. It quickly removes black bars from footage exports so downstream nodes don’t waste cycles on empty pixels.
Tuning Tips
- Switch to
percentmode with a lowfuzz_percentwhen dealing with perfectly solid borders (e.g., exact RGB black). - Bump
edge_margin_pxfor thicker frames so the sampler grabs enough context. - Disable
use_gpuif you are processing long batches on a shared card; the CPU path is slower but reliable.
Troubleshooting
- Border remains – Increase
fuzz_percent(in percent mode) oradaptive_k(in adaptive mode) so minor noise doesn’t block detection. - Image cropped too tightly – Raise
pad_pxor reduce the fuzz tolerance so fewer pixels are marked as border. - Unexpected slivers left behind – Check that
max_growth_iterisn’t too low for high-resolution images; raising it lets the mask reach the true content edge.
Screenshot: docs/screenshots/auto_crop_borders.png