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

  • Image directory D (for batch processing)

  • Number of rain layers Nlayers

  • Number of rain lines per layer Nlines

  • Rain line length range [lmin,lmax]

  • Rain line angle mean μθ and std σθ

  • Rain line thickness range [wmin,wmax]

  • Rain line brightness range [bmin,bmax]

  • Motion blur kernel size kmb

  • Transparency (per-layer alpha) range [αmin,αmax]

  • Output path Oout

Output:
  • Rain-augmented image Irain

Step 1: Generate and Overlay Rain Layers
  • 1.

    Initialize Irain=Iorig

  • 2.
    For j=1 to Nlayers:
    • Create empty mask Mj with same size as Iorig
    • For i=1 to Nlines:
      • Randomly sample start point (xstart,ystart)
      • Randomly sample length li[lmin,lmax]
      • Randomly sample angle θiN(μθ,σθ)
      • Compute end point (xend,yend) by li and θi
      • Randomly sample thickness wi[wmin,wmax]
      • Randomly sample brightness bi[bmin,bmax]
      • Draw line from (xstart,ystart) to (xend,yend) with width wi, brightness bi on Mj
    • Apply motion blur with kernel size kmb along θj to Mj
    • Randomly sample transparency αj[αmin,αmax]
    • Blend Mj onto Irain:
      Irain=(1αj)·Irain+αj·Mj
Step 2: Batch Processing and Output
  • 1.

    Repeat the above for each Iorig in directory D

  • 2.

    Save Irain to Oout

  • 3.

    Output the rain-augmented images