def _process(self):
d = self.display
img = d.widget.image
out = np.empty(shape=img.shape[:3], dtype=bool)
width = self.pWidth.value()
debug = self.pDebug.value()
laps, linelikellyness, params = [], [], []
ki = self.pKSizeIntensity.value()
ki += 1 - ki % 2 # enusre odd number
t = d.tools['Selection']
path = t.findPath(PerspectiveGridROI)
shape = path.nCells if path is not None else (6, 10)
border = path.vertices() if path is not None else None
if border is None:
print('No [Grid] found, assume image is corrected and there is \
no border around the image')
v = self.pMask.value()
if v != '-':
grid = d.widget.cItems[v].image_full
else:
grid = None
print('Please define [Grid Mask] to improve precision')
for n, im in enumerate(img):
if self.pDetect.value():
kwargs = detectLabelCrackParams(img, shape)
self.pKSizeProp.setValue(kwargs['ksize_length'])
self.pThreshProp.setValue(kwargs['thresh_length'] * 100)
self.pKSizeIntensity.setValue(kwargs['ksize_intensity'])
self.pThreshIntensity.setValue(kwargs['thresh_intensity'])
else:
kwargs = dict(ksize_intensity=ki,
ksize_length=self.pKSizeProp.value(),
thresh_length=self.pThreshProp.value() / 100,
norientations=self.pNorient.value(),
thresh_intensity=self.pThreshIntensity.value())
cracks, h, orient, lap, mx = labelCracks(im, grid,
cracks_are_bright=not self.pDark.value(),
**kwargs)
params.append(evalCracks(cracks, h, orient, shape, border))
if width > 1:
cracks = maximum_filter(cracks, width)
out[n] = cracks
if debug:
laps.append(lap)
linelikellyness.append(mx)
return out, laps, linelikellyness, params
评论列表
文章目录