Commit 910bc09a authored by Lars Bittrich's avatar Lars Bittrich

Pullrequest from Josef to allow recreation of fullimage by deletion and...

Pullrequest from Josef to allow recreation of fullimage by deletion and robustness changes in segmentation.py
parent ac123cc1
......@@ -104,8 +104,8 @@ class DataSet(object):
from opticalscan import loadAndPasteImage
# try to load png and check for detection contours
buggyimage = recreatefullimage
if not buggyimage and os.path.exists(self.getLegacyImageName()):
recreatefullimage = recreatefullimage or not os.path.exists(self.getLegacyImageName())
if not recreatefullimage:
img = cv2imread_fix(self.getLegacyImageName())
Nc = len(self.particlecontours)
if Nc>0:
......@@ -113,12 +113,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):
buggyimage = True
if not buggyimage:
recreatefullimage = True
if not recreatefullimage:
cv2imwrite_fix(self.getImageName(), img)
del img
if buggyimage:
if recreatefullimage:
print("recreating fullimage from grid data")
imgdata = None
zvalimg = None
......
......@@ -279,6 +279,10 @@ class Segmentation(object):
if return_step=="contrastcurve": return gray, 0
# image blur for noise-reduction
if self.blurRadius%2 != 1:
self.blurRadius += 1
print('blur Radius was an even number, incremented blur Radius by 1')
blur = cv2.medianBlur(gray, self.blurRadius)
blur = np.uint8(blur*(255/blur.max()))
if return_step=="blurRadius": return blur, 0
......@@ -331,7 +335,10 @@ class Segmentation(object):
h, w = sure_fg.shape[:2]
mask = np.zeros((h+2, w+2), np.uint8)
for p in np.int32(deletepoints):
cv2.floodFill(sure_fg, mask, tuple(p), 0)
if p[0] >= 0 and p[1] >= 0:
cv2.floodFill(sure_fg, mask, tuple(p), 0)
else:
print('skipped del point at {}'.format(p))
for p in np.int32(deletepoints):
cv2.circle(sure_fg, tuple(p), int(seedradius), 0, -1)
......
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