Skip to main content
. 2025 Sep 7;25(17):5587. doi: 10.3390/s25175587
Algorithm 1 Pseudocode for Procedural Snowfall Augmentation
Input:
  • Original image Iorig

  • Image directory D (for batch processing)

  • Number of snowflakes Nsnow

  • Mask transparency αmask

  • Snow particle size range [smin,smax]

  • Snow mask output path Mout

Output:
  • Snow-augmented image Isnow

Step 1: Generate Snow Mask
  • 1.

    Create an empty RGBA mask M with the same size as Iorig.

  • 2.
    For i=1 to Nsnow:
    • Randomly sample position (xi,yi) in the image.
    • Randomly select particle type: grain or streak.
    • If grain:
      • Sample radius ri from [smin,smax].
      • Sample alpha αi from [αmin,αmax].
      • Draw an irregular filled polygon at (xi,yi) with ri and αi on M.
    • If streak:
      • Sample length li from [2.5ri,7.0ri], width wi from [0.8,1.4].
      • Sample angle θi from [π4,π4].
      • Sample alpha αi from [αmin,αmax].
      • Draw a line at (xi,yi) of length li, width wi, angle θi, αi on M.
  • 3.

    Apply Gaussian blur (e.g., σ=0.6) to M for realism.

  • 4.

    Save M as a snow mask to Mout.

Step 2: Blend Snow Mask with Original Image
  • 1.
    For each image Iorig in directory D:
    • Resize M to match Iorig if needed.
    • For each pixel (x,y):
      • Compute blended pixel:
        Isnow(x,y)=(1αmask)·Iorig(x,y)+αmask·MRGB(x,y)
    • Save Isnow to Mout.
  • 2.

    Output the snow-augmented images.