Skip to content

Instantly share code, notes, and snippets.

@Gotoryoo
Created November 29, 2016 05:25
Show Gist options
  • Save Gotoryoo/cb7b60c9b9e5f5064bb2b95442ce88ee to your computer and use it in GitHub Desktop.
Save Gotoryoo/cb7b60c9b9e5f5064bb2b95442ce88ee to your computer and use it in GitHub Desktop.
# -*- coding: utf-8 -*-
"""
Created on Wed Jul 15 14:12:54 2015
@author: mks
"""# -*- coding: utf-8 -*-
"""
Spyder Editor
This is a temporary script file.
"""
import numpy
import cv2
import glob
import os
import matplotlib.pyplot as plt
import matplotlib.pyplot as pyplot
import sys
#import matplotlib.patches as mpatches
files = glob.glob("C:\\Users\\ryousuke\\Desktop\\lab_data\\20150715_contrast\\mod64pl12\\1\\all\\*.bmp")
#files.sort(key=os.path.getctime)
cv2.namedWindow("display_img",cv2.WINDOW_AUTOSIZE)
depth = []
imean = []
imini = []
imaxi = []
icont = []
diff = 138.0
for file in files:
print file
img = cv2.imread(file,cv2.CV_LOAD_IMAGE_GRAYSCALE)
gau =cv2.GaussianBlur(img, (3,3), 0)
imean.append( gau.mean())
imini.append(numpy.amin(gau))
imaxi.append( numpy.amax(gau))
icont.append(( imaxi[-1]*1.0 - imini[-1]*1.0 )/ diff )
filenamespl=file.split('\\')
depth.append( int(filenamespl[-1][2:-4])*5 )
cv2.destroyAllWindows()
#plt.plot(depth, imaxi, depth, imini, depth, imean)
#plt.plot(depth, imaxi,label = 'maximum')
#plt.plot(depth, imean,label = 'mean')
#plt.plot(depth, imini,label = 'minimum')
plt.plot(depth, icont,label = 'contrast')
#pyplot.plot(depth, imaxi, label ='kk')
plt.legend(loc="upper left")
plt.title('Brightness & Depth of emulsion in Z-axis')
plt.xlabel('Depth along Z-axis (micron)')
plt.ylabel('Brightness')
axis = plt.gca()
#axis.set_ylim(0,280)
axis.set_ylim(0,2)
#axis.set_xlim(0,180)
plt.savefig("43c_gtr.png")
#plt.show()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment