Commit 06d183e1 authored by Robert's avatar Robert Committed by Robert Ohmacht

-fixed: when zooming in and clicking somewhere in MainWindow DetectionView...

-fixed: when zooming in and clicking somewhere in MainWindow DetectionView sometimes does not show the correct image segment
parent 6c17dbc3
......@@ -279,7 +279,7 @@ class ParticleDetectionView(QtWidgets.QWidget):
super().__init__(parent, QtCore.Qt.Window)
self.dataset = self.verifySeedpoints(dataset)
self.pyramid = pyramid
self.img = pyramid.getFullImage()
self.img = None
self.imgclip = 0, 0, 0, 0
self.seg = Segmentation(self.dataset, self)
self.seg.detectionState.connect(self.updateDetectionState)
......@@ -583,11 +583,12 @@ class ParticleDetectionView(QtWidgets.QWidget):
self.updateImageSeeds()
def setImageCenter(self, center=None):
"""
:param center : scene coordinates of the click event
:return:
"""
'''
as more than the tiles are part of the scene
bounding rect may be bigger than just a rect around the tiles
tiles should be grouped
width and height of the full image
'''
width, height = self.pyramid.getBoundingRectDim()
......@@ -626,35 +627,6 @@ class ParticleDetectionView(QtWidgets.QWidget):
self.imgclip = int(y1), int(y2), int(x1), int(x2)
self.subimg, pix = self.pyramid.getSubImage(self.imgclip)
'''
img = QtGui.QImage(x2 - x1, y2 - y1, QtGui.QImage.Format_RGB888)
self.view.scene().render(
QtGui.QPainter(img),
QtCore.QRectF(0, 0, img.width(), img.height()),
#QtCore.QRectF(x1 + x0, y1 + y0, x2 - x1, y2 - y1)
QtCore.QRectF(x1, y1, x2 - x1, y2 - y1)
)
#pix = self.view.grab(QtCore.QRect(x1 + x0, y1 + y0, x2 - x1, y2 - y1))
# @see https://stackoverflow.com/a/11399959
#img = pix.toImage().convertToFormat(QtGui.QImage.Format_RGB888)
ptr = img.bits()
#ptr.setsize(img.byteCount())
ptr.setsize(img.height() * img.width() * 3)
self.subimg = np.asarray(ptr).reshape(img.height(), img.width(), 3)
pix = QtGui.QPixmap()
pix.convertFromImage(img)
'''
'''
sub = self.img[n1:n2,m1:m2,:].copy()
self.imgclip = n1,n2,m1,m2
self.subimg = sub
height, width, channel = sub.shape
bytesPerLine = 3 * width
pix = QtGui.QPixmap()
pix.convertFromImage(QtGui.QImage(sub.data, width, height,
bytesPerLine, QtGui.QImage.Format_RGB888))
'''
self.imglabel.clearData()
self.imglabel.setPixmap(pix)
self.updateImageSeeds()
......@@ -738,6 +710,7 @@ class ParticleDetectionView(QtWidgets.QWidget):
self.blockUI()
self.pdetectall.setText("Cancel")
self.threadrunning = True
self.img = self.pyramid.getFullImage()
self.thread = Thread(target=self._worker)
self.thread.start()
self.timer = QtCore.QTimer(self)
......
......@@ -492,10 +492,7 @@ class ScenePyramid:
:return: (width, height)
:rtype: (int, int)
"""
group = self.scene.createItemGroup(self.currentTiles)
rect = group.boundingRect()
self.scene.destroyItemGroup(group)
return rect.width(), rect.height()
return self.fullImageWidth, self.fullImageHeight
def addSrcTileSimple(self, img, pos, p):
"""
......
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