Commit fcca6561 authored by Josef Brandt's avatar Josef Brandt
Browse files

Bugfix in calculation of particle stats

parent b421c24d
Loading
Loading
Loading
Loading
+8 −4
Original line number Diff line number Diff line
@@ -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
        
@@ -252,7 +254,9 @@ class ParticleEditor(QtCore.QObject):
        if short>long:
            long, short = short, long
        
        return long, short, longellipse, shortellipse, cv2.contourArea(cnt)
        area = cv2.contourArea(cnt)
    
        return long*pixelscale, short*pixelscale, longellipse*pixelscale, shortellipse*pixelscale, area*pixelscale**2

    @QtCore.pyqtSlot(list)
    def deleteParticles(self, contourIndices):