Skip to main content
. 2026 May 12;12(5):207. doi: 10.3390/jimaging12050207
Algorithm 1 HybridAugment+
Require: Image I(RGB photograph or grayscale radiograph), parameters Nmin = 2, Nmax = 10, σ = 2, M = 9, Minimal constant ε
Ensure: Augmented image Iaug
  /* Step 1: Contrast enhancement */
  1: if I is RGB photograph then
  2:  Igray=(IR+IG+IB)/3                  /* Convert to grayscale */
  3: else
  4:  Igray= I                       /* Radiograph already grayscale */
  5: end if
  6: Ieq = CLAHE(Igray, clip_limit=2.0, grid_size =(8,8))         /* Local contrast enhancement */
                                                                     0/* Step 2: Color balancing (photographs only) */
  7: Hmax=log2max(Ieq)+1)                 /*Identify bit-depth */
  8: Imax =2Hmax −1
  9: if I is RGB photograph then
10:  Ibalanced= GrayWorldColorBalance(I)            /*Reduce illumination bias */
11:  G=(Ieq+ε)⊘(Igray +ε)                 /*Compute pixel-wise gain */
12:  Ibase = clip(Ibalanced ⊗G,0,Imax )             /*Apply gain to all channels */
13: else
14:  Ibase =Ieq
15: end if
                                                                                      0/* Step 3: Entropy computation */
16: Compute histogram P(gi) from Ieq for i = 0, …, 2Hmax – 1
17: H =−∑i=02Hmax−1P(gi)log2P(gi)                /*Shannon entropy in bits */
18: Hnorm =H/Hmax                     /*Normalize by maximum entropy */
                                                                     /* Step 4: Adaptive operation count selection */
19: p= Nmin+(Nmax−Nmin)× (1−Hnorm)             /*Expected operation count */
20: Nsample =random.normal(mean=p,std = σ)           /*Stochastic sampling */
21: Nfinal = clip(round(Nsample ), Nmin, Nmax)             /*Discrete operation count*/
                                                           /* Step 5: RandAugment with modality-specific operations */
22: Iaug=RandAugment(Ibase, N=Nfinal, M=M, operation_pool=Pool(I)) /*Pool selected based on modality/*
                                                                     /*Step 6: Color preservation (photographs only) */
23: if I is RGB photograph then
24:  Iaug = ColorPreservation(Iaug, Ibase )            /*Mild gamut mapping/*
25: end if
26: return Iaug