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): SIn

  • 8: 

    Randomly select frame image (target): TInOut

  • 9: 

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

  • 10: 

    Compute transformation matrix T:      ▹ Section 3.4

    T=xS1yS11000xS1xT1yS1xT1000xS1yS11xS1yT1yS1yT1xS2yS21000xS2xT2yS2xT2000xS2yS21xS2yT2yS2yT2xS3yS31000xS3xT3yS3xT3000xS3yS31xS3yT3yS3yT3xS4yS41000xS4xT4yS4xT4000xS4yS41xS4yT4yS4yT41xT1yT1xT2yT2xT3yT3xT4yT4

  • 11: 

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

Step4: Cut-and-paste with realistic transformations

  • 12: 

    Randomly select road image (background): BRoad

  • 13: 

    Compute pasteable region: PB    ▹ Section 3.5.1

  • 14: 

    Randomly select bottom point of the sign: p1=p1xp1yPB

  • 15: 

    Compute top point of the sign:    ▹ Section 3.5.2

    p2=p2xp2y=p1xtan1tanα·p1y+β1hβtan1tanα·p1y+β1hβαα

  • 16: 

    Cut sign image ITCS and paste to road image IB: ITCP=CutandPasteITCS,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=GPGANITCS,MTCS    ▹ Section 3.5.3

Output: Synthesized training image: ITGP;

      Synthesized training label: BboxTCP