Skip to main content
. 2022 May 4;22(9):3494. doi: 10.3390/s22093494
Algorithm 1 Pseudo-code of the proposed method.

Step1: Collecting construction sign and road images

  • 1: 

    In-domain construction sign image: IIn

  • 2: 

    Out-domain construction sign image: IOut

  • 3: 

    Road image: IRoad

Step2: Labeling bounding box, segment, and four corners of the board

  • 4: 

    Bounding box labels: BboxIn, BboxOut

  • 5: 

    Segment labels: MIn, MOut

  • 6: 

    Four corners of the board: (xI1yI1xI2yI2xI3yI3xI4yI4), (xO1yO1xO2yO2xO3yO3xO4yO4)

Step3: Content swapping

  • 7: 

    Randomly select content image (source): S∈In

  • 8: 

    Randomly select frame image (target): T∈InOut

  • 9: 

    Set content region mask of target image using four corners label: CT

  • 10: 

    Compute transformation matrix T:      ▹ Section 3.4

    T=xS1yS11000−xS1xT1−yS1xT1000xS1yS11−xS1yT1−yS1yT1xS2yS21000−xS2xT2−yS2xT2000xS2yS21−xS2yT2−yS2yT2xS3yS31000−xS3xT3−yS3xT3000xS3yS31−xS3yT3−yS3yT3xS4yS41000−xS4xT4−yS4xT4000xS4yS41−xS4yT4−yS4yT4−1xT1yT1xT2yT2xT3yT3xT4yT4

  • 11: 

    Swap content: ITCS=T(IS)⊙CT+IT⊙(1−CT)

Step4: Cut-and-paste with realistic transformations

  • 12: 

    Randomly select road image (background): B∈Road

  • 13: 

    Compute pasteable region: PB    ▹ Section 3.5.1

  • 14: 

    Randomly select bottom point of the sign: p1=p1xp1y∈PB

  • 15: 

    Compute top point of the sign:    ▹ Section 3.5.2

    p2=p2xp2y=p1xtan−1tanα·p1y+β1−h−βtan−1tanα·p1y+β1−h−βαα

  • 16: 

    Cut sign image ITCS and paste to road image IB: ITCP=Cut−and−PasteITCS,MT,IB,p1,p2

  • 17: 

    Transform segment label to p1 and p2: MTCP=Transform_maskMT,p1,p2

  • 18: 

    Transform bounding box label to p1 and p2: BboxTCP=Transform_boxBboxT,p1,p2

  • 19: 

    Reduce color difference: ITGP=GP−GANITCS,MTCS    ▹ Section 3.5.3

Output: Synthesized training image: ITGP;

      Synthesized training label: BboxTCP