Commit 0e2b4d8a authored by Josef Brandt's avatar Josef Brandt

Replace dataset.py

parent 910bc09a
......@@ -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
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment