Commit fcca6561 authored by Josef Brandt's avatar Josef Brandt

Bugfix in calculation of particle stats

parent b421c24d
......@@ -143,7 +143,8 @@ class ParticleEditor(QtCore.QObject):
print(f'Combining particles {contourIndices} into {newAssignment}')
contours = self.particleContainer.getParticleContoursByIndex(contourIndices)
newContour = self.mergeContours(contours.copy())
stats = self.characterizeParticle(newContour)
pixelscale = self.viewparent.dataset.getPixelScale()
stats = self.characterizeParticle(newContour, pixelscale)
self.particleContainer.mergeParticles(contourIndices, newContour, stats, newAssignment=newAssignment)
for ind in contourIndices:
......@@ -178,7 +179,8 @@ class ParticleEditor(QtCore.QObject):
def acceptPaintedResult(self):
newContour = self.mergeContours(self.particlePainter.contours.copy())
stats = self.characterizeParticle(newContour)
pixelscale = self.viewparent.dataset.getPixelScale()
stats = self.characterizeParticle(newContour, pixelscale)
self.particleContainer.mergeParticles(self.storedIndices, newContour, stats, newAssignment=self.storedAssignmend)
for ind in self.storedIndices:
......@@ -237,7 +239,7 @@ class ParticleEditor(QtCore.QObject):
return newContour
def characterizeParticle(self, contours):
def characterizeParticle(self, contours, pixelscale):
##characterize particle
longellipse, shortellipse = np.nan, np.nan
......@@ -251,8 +253,10 @@ class ParticleEditor(QtCore.QObject):
long, short = rect[1]
if short>long:
long, short = short, long
area = cv2.contourArea(cnt)
return long, short, longellipse, shortellipse, cv2.contourArea(cnt)
return long*pixelscale, short*pixelscale, longellipse*pixelscale, shortellipse*pixelscale, area*pixelscale**2
@QtCore.pyqtSlot(list)
def deleteParticles(self, contourIndices):
......
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