python 處理映像(綠色亮度)

來源:互聯網
上載者:User

標籤:

# coding=utf-8import Imageimport osimport csvimport numpy as np# openimg_path = r"G:\kangyufeng\pics"def myimage(img_path):    try:        img_list = os.listdir(img_path)    except:        print ‘not a document‘        return    Bigm = 0.01    for img in img_list:        if "tif" in img:            print img            im = Image.open(img_path+‘\\‘+img)            #im.save("%s%s"%(img.split(".")[-2],‘.jpeg‘))            w,l=im.size            source = im.split()            R,G,B = 0,1,2            S = 0                        count = 1            mtr = np.array(source[G])            mtr.transpose()                        mtr = mtr[l/2-300:l/2+300]            mtr = mtr.reshape(1,w*600)            print len(mtr[0])            mmean = mtr.mean()                        print mmean            for i in mtr[0]:                if i > mmean/10:                    S += i                    count += 1            m = S/count            if Bigm < m:                Bigm = m            print m,count                        with open("%s%s%s%s" % (img_path,‘\\‘,img_path.split(‘\\‘)[-1],‘_results.csv‘),‘ab‘) as f: #如果不使用‘ab‘方式只用’a‘會產生多餘空行                f = csv.writer(f,dialect=‘excel‘)                f.writerow([img,str(m),str(float(m)/Bigm*float(img_path.split(‘_‘)[-1]))+‘Mmol/L‘])        else:            if ‘csv‘ not in img:                myimage(img_path+‘\\‘+img)myimage(img_path)

python 處理映像(綠色亮度)

python 處理映像(綠色亮度)

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.