Example #1
0
 def pbinary(self):
     """ Returns boolean mask of all particles IN the image, with 
         background removed."""      
     # Faster to get all coords in image at once since going to paint white
     out = np.zeros( self.rez, dtype=bool )
     if self.particles:
         rr_cc = coords_in_image( self._particles.rr_cc_all, self.rez)
         out[rr_cc] = True
     return out  
Example #2
0
    def _draw_particles(self, image, force_binary=False):
        """ Draws particles over any image (ie background, background+grid.
        force_binary is a hack to allow for drawing binary particles, useful
        for canvas.show(cmap=pbinary)"""
        for p in self._particles:   
            rr_cc = p.particle.rr_cc

            # Lot of crap!  Need it this way or grid color will be inverted too
            if force_binary:
                if force_binary == 'pbinary_r':
                    color = False
                else:
                    color = True
            else:
                color = p.color
                
            rr_cc = coords_in_image(rr_cc, image.shape)
            image[rr_cc] = color
        return image