Graduate program needs so wrote a:
ImportNumPy as NP fromPILImportImageImportSkimage.io#value the picture twodefbinaryzation (pic_id, new_id): IMG=image.open (pic_id) img= Img.convert ("L") IMGs=Skimage.io.imread (pic_id) TTT= 1.4 *Np.mean (IMGs) white, BLACK= 255, 0 img= Img.point (LambdaX:whiteifX > TTTElseBLACK) img= Img.convert ('1') Img.save (new_id)#Calculate plaque Area percentagedefzone_cal (new_id): IMGs=Skimage.io.imread (new_id) a=imgs.tolist () b= W =0 forJinchA: forLinchJ:ifL <= 125: b+ = 1Else: w+ = 1fungi_percent= w/(w +b)returnfungi_percent#Print (Fungi_percent, W, b)before = after =0 forXinchRange (1, 4): Binaryzation ('d:/p/hx-'+STR (x) +'. jpg','d:/p/hx-'+STR (x) +'2 value. jpg') before+ = Zone_cal ('d:/p/hx-'+STR (x) +'2 value. jpg') forXinchRange (4, 7): Binaryzation ('d:/p/hx-'+STR (x) +'. jpg','d:/p/hx-'+STR (x) +'2 value. jpg') After+ = Zone_cal ('d:/p/hx-'+STR (x) +'2 value. jpg') before/= 3 After/= 3Print(before, after)
‘‘‘
0.27155324073124204 0.11879577511345958
‘‘‘
Online with Matlab do more, the principle is also very clear, not much to say. No noise is dealt with and details are lost more.
Using Python to calculate plaque area