def _process(self):
w = self.display.widget
img = w.image
out = []
v = self.pRef.value()
if v == 'Reference points':
# 2x3 point warp:
r0, r1 = self._refPn
pts0 = np.array([(h['pos'].y(), h['pos'].x())
for h in r0.handles]) + r0.pos()
pts1 = np.array([(h['pos'].y(), h['pos'].x())
for h in r1.handles]) + r1.pos()
# TODO: embed in PyerspectiveCorrection
M = cv2.getAffineTransform(
pts0.astype(
np.float32), pts1.astype(
np.float32))
for n, i in enumerate(img):
out.append(
# TODO: allow different image shapes
cv2.warpAffine(i, M, w.image.shape[1:3],
borderValue=0))
else:
r = v == 'Reference image'
e = self.pExecOn.value()
for n, i in enumerate(img):
if (e == 'all images' or
(e == 'current image' and n == w.currentIndex) or
(e == 'last image' and n == len(img) - 1)):
if not (r and n == self._refImg_from_own_display):
corr = self.pc.correct(i)
# if r and self.pSubPx.value():
# corr = subPixelAlignment(
# corr, self._refImg,
# niter=20,
# grid=(self.pSubPx_y.value(),
# self.pSubPx_x.value()),
# method='smooth',
# # maxGrad=2,
# concentrateNNeighbours=self.pSubPx_neigh.value(),
# maxDev=self.pSubPx_maxDev.value())[0]
out.append(corr)
return out
评论列表
文章目录