From 0e2b4d8a0e486ef12bbe17b4760c2a2f1cb627fa Mon Sep 17 00:00:00 2001 From: Josef Brandt Date: Fri, 12 Oct 2018 08:15:56 -0400 Subject: [PATCH] Replace dataset.py --- dataset.py | 30 +++++++++++++++++++++++++----- 1 file changed, 25 insertions(+), 5 deletions(-) diff --git a/dataset.py b/dataset.py index c86fa7b..6b49705 100644 --- a/dataset.py +++ b/dataset.py @@ -74,6 +74,18 @@ class DataSet(object): self.pshift = None # shift of raman scan position relative to image center self.seedpoints = np.array([]) self.seeddeletepoints = np.array([]) + self.detectParams = {'points': np.array([[50,0],[100,200],[200,255]]), + 'contrastcurve': True, + 'blurRadius': 9, + 'threshold': 0.2, + 'maxholebrightness': 0.5, + 'erodeconvexdefects': 0, + 'minparticlearea': 20, + 'minparticledistance': 20, + 'measurefrac': 1, + 'compactness': 0.1, + 'seedRad': 3} + self.ramanpoints = [] self.particlecontours = [] self.particlestats = [] @@ -104,8 +116,8 @@ class DataSet(object): from opticalscan import loadAndPasteImage # try to load png and check for detection contours - recreatefullimage = recreatefullimage or not os.path.exists(self.getLegacyImageName()) - if not recreatefullimage: + buggyimage = recreatefullimage + if not buggyimage and os.path.exists(self.getLegacyImageName()): img = cv2imread_fix(self.getLegacyImageName()) Nc = len(self.particlecontours) if Nc>0: @@ -113,12 +125,12 @@ class DataSet(object): contpixels = img[contour[:,0,1],contour[:,0,0]] if np.all(contpixels[:,1]==255) and np.all(contpixels[:,2]==0) \ and np.all(contpixels[:,0]==0): - recreatefullimage = True - if not recreatefullimage: + buggyimage = True + if not buggyimage: cv2imwrite_fix(self.getImageName(), img) del img - if recreatefullimage: + if buggyimage: print("recreating fullimage from grid data") imgdata = None zvalimg = None @@ -248,4 +260,12 @@ class DataSet(object): def save(self): saveData(self, self.fname) + + +if __name__ == '__main__': + dset = loadData(r'C:\Users\brandt\Desktop\20180723DemoTZW\20180723DemoTZW.pkl') + print(dset.detectParams) +# dset.seedpoints = np.array([]) +# dset.seeddeletepoints = np.array([]) +# dset.save() \ No newline at end of file -- GitLab