Skip to main content
. 2026 Jul 25;26(15):4728. doi: 10.3390/s26154728
Algorithm 2 Automated Bounding Box Generation for Lesion Detection
  •   1:

    procedure Generate(I)

  •   2:

        Igray←rgb2gray(I)

  •   3:

        T←otsu(Igray)

  •   4:

        Ibinary←Igray>T

  •   5:

        K←ellipse(15,15)

  •   6:

        Iclosed←morphClose(Ibinary,K)

  •   7:

        Iprocessed←morphOpen(Iclosed,K)

  •   8:

        C←findContours(Iprocessed)

  •   9:

        if C=∅ then

  • 10:

            return (0.5,0.5,0.7,0.7)

  • 11:

        else

  • 12:

            cmax←argmaxc∈Carea(c)

  • 13:

            (x,y,w,h)←boundingRect(cmax)

  • 14:

            xcenter←(x+w/2)/W

  • 15:

            ycenter←(y+h/2)/H

  • 16:

            bboxw←min(1.15·w/W,1.0)

  • 17:

            bboxh←min(1.15·h/H,1.0)

  • 18:

            return (xcenter,ycenter,bboxw,bboxh)

  • 19:

        end if

  • 20:

    end procedure