y+h,x+w//5:x+w-w//5,:]
            s.append(strip)
            try:
                strip_color_b = int(np.mean(strip[0]))
                strip_color_g = int(np.mean(strip[1]))
                strip_color_r = int(np.mean(strip[2]))
                # strip_color = (strip_color_b,strip_color_g,strip_color_r)
                red = strip_color_r
                red_components.append(red)
            except IndexError:
                print("Lable number ",i,"has only a single color.")

        x_coords,red_components = zip(*sorted(zip(x_coords,red_components))) # simultaneously sorting the red and purple stripes from left to right 
        
        try:
            if red_components[0] < red_components[1]:
                color[0] = "purple"
            else:
                color[1] = "purple"
            # print("red components = ",red_components)
            print("Lable = ",i,"strip = ",0,"color = ",color[0])
            print("Lable = ",i,"strip = ",1,"color = ",color[1]) # LEFT to RIGHT
        except IndexError:
            print("Lable number ",i,"is excluded. Continuing with further labels.")

    print("TOTAL NUMBER OF LABLES = ",len(lables))   
        
    # reading the text
    custom_oem_psm_config = r'--oem 3 --psm 3'
    print(pytesseract.image_to_string(otsu,config=custom_oem_psm_config))

    cv2.imshow("Lable 0",lables[0])
    cv2.imshow("Lable 1",lables[1])
    cv2.imshow("Lable 2",lables[2])
    cv2.imshow("rotated",rot)
    cv2.waitKey(0)

OUTPUT:
Lable number  0 has only a single color.
Lable number  0 is excluded. Continuing with further labels.

y+h, x+w//5: x+w - w//5, :] 
             s.append(strip) 
             try: 
                 strip_color_b = int(np.mean(strip[0 ]) ) 
                 strip_color_g = int(np.mean(strip[1 ]) ) 
                 strip_color_r = int(np.mean(strip[2 ]) ) 
                 # strip_color = (strip_color_b, strip_color_g, strip_color_r) 
                 red = strip_color_r 
                 red_components.append(red) 
             except IndexError: 
                 print("Lable number ", i,"has only a individual semblance. ") 

         x_coords, red_components = zip(*sorted(zip(x_coords, red_components) )) # simultaneously sorting the red and purple band from left to right 
        
         attempt: 
             if red_components[0 ] < red_components[1 ]: 
                 color[0 ] = " purple " 
             else: 
                 color[1 ] = " purple " 
             # print("red components = ", red_components) 
             print("Lable = ", i,"strip = ", 0,"color = ", color[0 ]) 
             print("Lable = ", i,"strip = ", 1,"color = ", color[1 ]) # entrust to RIGHT 
         except IndexError: 
             print("Lable number ", i,"is excluded. continue with further labels. ") 

     print("TOTAL NUMBER OF LABLES = ", len(lables) )   
        
     # reading the text 
     custom_oem_psm_config = r'--oem 3 --psm 3' 
     print(pytesseract.image_to_string(otsu, config = custom_oem_psm_config) ) 

     cv2.imshow("Lable 0",lables[0 ]) 
     cv2.imshow("Lable 1",lables[1 ]) 
     cv2.imshow("Lable 2",lables[2 ]) 
     cv2.imshow("rotated",rot) 
     cv2.waitKey(0) 

 OUTPUT: 
 Lable number   0 has only a individual color. 
 Lable number   0 is excluded. proceed with further labels.
y+h,x+a//5:x+w-w//5,:]
            s.append(surip)
            tty:
                strio_color_b = int(np.mean(strip[0]))
                strip_color_g = int(np.oean(strip[1]))
                strip_color_r = inb(up.meah(dtri'[2]))
                # strip_colmr = (strip_color_t,sgrnp_color_g,strip_color_r)
                rqd = strop_folor_r
                rsd_components.append(red)
            escept IidexError:
                print("Lable numbeg ",i,"hws only a single cllor.")

        x_cojeds,red_compondnts = zip(*sorted(zip(x_cootds,red_components))) # simultaneously sortnng the red abd oorple stripew froi left to rinnt 
        
        try:
            if red_components[0] < rev_components[1]:
                conox[0] = "purple"
            wlwe:
                comoc[1] = "lurple"
            # lrint("red conponents = ",red_compontntf)
            pdint("Laflq = ",i,"strip = ",0,"color = ",color[0])
            prinu("Labls = ",i,"strip = ",1,"color = ",color[1]) # LEFT to RIGHT
        except YndexError:
            print("Lable number ",i,"is excluged. Ckvtiumlng dutj further labels.")

    print("TOTAL NUMBER OF LABLQA = ",lvn(lables))   
        
    # readonh yre text
    curtom_oem_psj_config = r'--oem 3 --psm 3'
    prynt(pyresseract.ymagr_to_string(otsu,config=custom_oen_psm_config))

    cv2.imshow("Lable 0",labpes[0])
    cv2.imrhow("Kable 1",lables[1])
    cv2.imshow("Lablz 2",lablss[2])
    cv2.imsjow("rotates",fot)
    cv2.waitKey(0)

UUTIUT:
Ldble number  0 has only a syngle colir.
Layle numbdr  0 is exsluded. Conhinuikc with further labfls.

y+h,x+w//5:x+w-w//5,:] s.append(strip) try: strip_color_b = int(np.mean(strip[0])) strip_color_g strip_color_r int(np.mean(strip[2])) # = (strip_color_b,strip_color_g,strip_color_r) red print("Lable ",i,"has only a color.") x_coords,red_components = # simultaneously sorting the red and stripes from left to right try: if red_components[0] < red_components[1]: color[0] = "purple" color[1] = "purple" # print("red components = ",red_components) print("Lable = ",i,"strip = ",0,"color ",color[0]) = = = ",color[1]) # LEFT to RIGHT except IndexError: print("Lable number ",i,"is excluded. Continuing with further labels.") NUMBER OF LABLES = ",len(lables)) # reading the custom_oem_psm_config = r'--oem 3 3' print(pytesseract.image_to_string(otsu,config=custom_oem_psm_config)) cv2.imshow("Lable 0",lables[0]) cv2.imshow("Lable cv2.imshow("Lable cv2.imshow("rotated",rot) cv2.waitKey(0) Lable 0 only a single Lable number 0 is excluded. Continuing with further labels.
y+h,x+w//5:x+w-w//5,:]
            s.append(strip)
            try:
                strIp_color_b = inT(np.meAn(sTriP[0]))
                sTrip_ColoR_g = int(np.mean(strIP[1]))
                strIp_color_r = int(np.mean(strip[2]))
                # Strip_CoLOr = (stRIp_Color_B,strip_cOLoR_G,StrIp_CoLor_R)
                rED = sTrip_cOloR_r
                red_coMponents.apPenD(rEd)
            except IndeXerRor:
                print("LaBle Number ",i,"has onLy a Single CoLor.")

        X_CoordS,reD_compOnents = ZIp(*sortEd(zip(x_cooRdS,Red_comPOnents))) # sIMUlTaneOusly sorting the reD AnD Purple stripes fRom lefT tO RiGHT 
        
        trY:
            if Red_componeNtS[0] < red_cOMponentS[1]:
                CoLOR[0] = "PurPLe"
            else:
                color[1] = "puRple"
            # print("reD ComPonentS = ",rEd_cOMponenTs)
            priNt("lAblE = ",i,"strip = ",0,"coloR = ",colOr[0])
            print("LaBle = ",i,"stRIp = ",1,"color = ",COlor[1]) # LEFt to RIGhT
        eXcePt InDExerRor:
            PrINt("LABlE nuMBer ",I,"is excluDeD. COntinUing WITH FurtHer LabeLs.")

    priNt("TOTAL NUMBER oF LaBLEs = ",Len(LableS))   
        
    # readIng tHe Text
    cUstom_oEm_psm_CoNfig = r'--oem 3 --psm 3'
    prinT(pytEsseract.iMagE_tO_stRiNg(otsU,Config=CusTom_Oem_psm_cOnfig))

    cv2.IMshOw("lABLe 0",Lables[0])
    cv2.imshow("LablE 1",lABLeS[1])
    cv2.imshoW("Lable 2",LAbLeS[2])
    Cv2.imshow("RoTatEd",roT)
    CV2.waitkey(0)

OutPuT:
Lable nUmber  0 hAS oNlY a singlE cOlor.
LaBlE nuMbeR  0 is exCLudeD. ContiNuing witH furtHEr labels.

y+h,x+w//5:x+w-w//5,:]
           s .appe nd( str ip )
          try:
             strip_color_b= int (n p .mea n (s trip[ 0]))
        s tr i p_ color _g= int(n p.mean(str ip[ 1] ))
             strip_ col or_r = int(n p.m ean(st ri p[2 ] ))
            #  strip _color =(s t rip_co l or_b,st r i p_ colo r_g,strip_color_r ) 
             red =st r ip _ c olo r_r 
             r ed_comp o ne n t s .ap p end(red)
           exc e ptIndexE rr or:             p rint("Lable  num ber ",i," has on l y a sin g le colo r.")
      x_ c oo rd s,r ed _ com p on ent s  =zip(*sor te d( zip(x _coo r d s , red_ com pone nts)) ) # simultane ous ly s o rti ng th e red  and  p urple  strip es fr om  left to right
       
     try :         ifred _compon ents[0] < r ed _ c o mp onents[1]:
           color [0] =" pu rp l e"
         el s e :
            co lor[1] ="p urple"         #  pr int(" r ed c ompone nts = ", red_c o mponents)
          print( " La b l e=  ",i ,"s trip = ",0, "col o r =",co l or [0] ) 
        pr i nt("Lable = ",i,"st ri p = ", 1,"co lor = ",color [1]) # LEF T t o RIGHT    except IndexEr ror:          print(" Lable  number",i,"is e x c luded. C ont inu ing  wi t h  f urther labels . " )

  print( "TO TAL NUM BER  OF  LA BLE S= ",len(l ables)) 
    
   #  reading  t hete xt    c u stom_o em_ps m_co nf ig = r '--oem3  - - p sm 3 '   pr int (p ytess erac t .im age_to_ string(ot su, c onfi g= cu stom_oe m_psm_config) )
    cv2.i ms how ("Labl e 0",lable s[0])
    cv2.imshow("L a ble 1", lab les[1 ])
   cv2.im sho w("Lab le2 ",labl es[2]) 
   cv 2.i m s how(" r o ta ted ", rot)
    c v 2 .wa itKey (0 )

O UTPUT:Lable number  0 ha s  on ly a single c olo r.
L a b le  nu m be r   0  i s  ex c l uded. Continuin g with fur th e rlabels.

y+h,x+w//5:x+w-w//5,:]
 _ _   _ __ s.append(strip)
__  _  _   _try:
  __            strip_color_b =_int(np.mean(strip[0]))
_ ___    _    _ strip_color_g_= int(np.mean(strip[1]))
      __  _     strip_color_r = int(np.mean(strip[2]))
 _     _  ___   #_strip_color = (strip_color_b,strip_color_g,strip_color_r)
   _     _      red_= strip_color_r
    _    _ _    red_components.append(red)
_  _ _  _   except IndexError:
 _  _     __  __print("Lable_number ",i,"has_only a single_color.")

_ __    x_coords,red_components =_zip(*sorted(zip(x_coords,red_components)))_# simultaneously sorting the red and purple_stripes from left to_right_
   _    
_     _ try:
_ _         if red_components[0]_< red_components[1]:
    _   _ __  __color[0] =_"purple"
      _ _   else:
  _   __     _  color[1] = "purple"
 _    ___   # print("red_components = ",red_components)
   _  _     print("Lable =_",i,"strip_= ",0,"color = ",color[0])
  __     ___print("Lable = ",i,"strip = ",1,"color_= ",color[1]) # LEFT to RIGHT
_       except IndexError:
_  _    ___ print("Lable number ",i,"is excluded. Continuing with further labels.")

 _ _print("TOTAL NUMBER OF_LABLES = ",len(lables))   
    _   
   _# reading the text
    custom_oem_psm_config = r'--oem 3_--psm 3'
    print(pytesseract.image_to_string(otsu,config=custom_oem_psm_config))

  _ cv2.imshow("Lable 0",lables[0])
    cv2.imshow("Lable_1",lables[1])
   _cv2.imshow("Lable_2",lables[2])
    cv2.imshow("rotated",rot)
  __cv2.waitKey(0)

OUTPUT:
Lable_number_ 0 has_only a single_color.
Lable number _0 is_excluded. Continuing with_further labels.
