MCPcopy
hub / github.com/vladmandic/sdnext / _apply_grain

Function _apply_grain

modules/processing_grading.py:169–172  ·  view source on GitHub ↗

Film grain via random noise blend.

(img: torch.Tensor, strength: float)

Source from the content-addressed store, hash-verified

167
168
169def _apply_grain(img: torch.Tensor, strength: float) -> torch.Tensor:
170 """Film grain via random noise blend."""
171 noise = torch.randn_like(img) * strength * 0.1
172 return (img + noise).clamp(0, 1)
173
174
175def _apply_color_temp(img: torch.Tensor, kelvin: float) -> torch.Tensor:

Callers 2

test_apply_grainFunction · 0.90
grade_imageFunction · 0.85

Calls

no outgoing calls

Tested by 1

test_apply_grainFunction · 0.72