예제 #1
0
	def showAssessedMask(self,imgfile,imgdata):
		self.filename = imgfile
		image = pyami.mrc.read(imgfile)
		sessiondata = self.params['sessionname']
		maskassessname = self.params['checkMask']
		mask,maskbin = apMask.makeInspectedMask(sessiondata,maskassessname,imgdata)
		overlay = apMask.overlayMask(image,mask)
		self.app.panel.setImage(overlay.astype(numpy.float32))
예제 #2
0
    def displayCurrent(self):
        imarray = numpy.zeros((2, 2))
        while imarray.max() == 0:
            currentname = self.files[self.currentindex]

            self.logger.info('Displaying %s' % (currentname))
            dir = self.maskdir
            fullname = os.path.join(dir, currentname)

            imarray = self.readPNG(fullname)

            if imarray.max() == 0:
                if self.forward:
                    if self.currentindex == len(self.files) - 1:
                        self.logger.info('End reached.')
                        return
                    else:
                        self.currentindex += 1
                else:
                    if self.currentindex == 0:
                        self.logger.info('Beginning reached.')
                        return
                    else:
                        self.currentindex -= 1
        if currentname.find('_mask') > -1:
            alpha = 0.5
            imgdata = self.images[self.currentindex]
            parentimg = imgdata['image']
            maskshape = imarray.shape

            targets = apMask.getRegionsAsTargets(self.maskrundata, maskshape,
                                                 imgdata)
            if targets is None or len(targets) == 0:
                self.logger.warning('No Mask Regions in this Image')
            keep = apDatabase.getImgAssessmentStatus(imgdata)
            if keep == False:
                self.logger.warning('Rejected Image, Mask Irelavent')
            self.alltargets = targets[:]
            self.setTargets(targets, 'Regions')

            binning = parentimg.shape[0] / imarray.shape[0]
            parentimg = imagefun.bin(parentimg, binning)
            overlay = apMask.overlayMask(parentimg, imarray)
            self.setImage(overlay, 'Mask')
            imarray = parentimg
        self.setImage(imarray, 'Image')
예제 #3
0
	def displayCurrent(self):
		imarray = numpy.zeros((2,2))
		while imarray.max() == 0:
			currentname = self.files[self.currentindex]

			self.logger.info('Displaying %s' % (currentname))
			dir = self.maskdir
			fullname = os.path.join(dir, currentname)

			imarray = self.readPNG(fullname)
			
			if imarray.max() ==0:
				if self.forward:
					if self.currentindex == len(self.files)-1:
						self.logger.info('End reached.')
						return
					else:
						self.currentindex += 1
				else:
					if self.currentindex == 0:
						self.logger.info('Beginning reached.')
						return
					else:
						self.currentindex -= 1
		if currentname.find('_mask') > -1:
			alpha = 0.5
			imgdata = self.images[self.currentindex]
			parentimg = imgdata['image']
			maskshape = imarray.shape

			targets = apMask.getRegionsAsTargets(self.maskrundata,maskshape,imgdata)
			if targets is None or len(targets)==0:
				self.logger.warning('No Mask Regions in this Image')
			keep = apDatabase.getImgAssessmentStatus(imgdata)
			if keep == False:
				self.logger.warning('Rejected Image, Mask Irelavent')
			self.alltargets = targets[:]
			self.setTargets(targets, 'Regions')
				
			binning = parentimg.shape[0]/imarray.shape[0]
			parentimg=imagefun.bin(parentimg,binning)
			overlay = apMask.overlayMask(parentimg,imarray)
			self.setImage(overlay, 'Mask')
			imarray=parentimg
		self.setImage(imarray, 'Image')
	def onAdd(self, evt):
		vertices = []
		vertices = self.panel.getTargetPositions('Region to Remove')
		
		# Write out vertices to mask file
		def reversexy(coord):
			clist=list(coord)
			clist.reverse()
			return tuple(clist)
		vertices = map(reversexy,vertices)

		polygonimg = leginon.polygon.filledPolygon(self.panel.imagedata.shape,vertices)
		type(polygonimg)
		self.panel.maskimg = self.panel.maskimg + polygonimg

		overlay = apMask.overlayMask(self.panel.image,self.panel.maskimg)
		self.panel.setImage(overlay.astype(numpy.float32))

		self.panel.setTargets('Region to Remove', [])
    def onAdd(self, evt):
        vertices = []
        vertices = self.panel.getTargetPositions('Region to Remove')

        # Write out vertices to mask file
        def reversexy(coord):
            clist = list(coord)
            clist.reverse()
            return tuple(clist)

        vertices = map(reversexy, vertices)

        polygonimg = leginon.polygon.filledPolygon(self.panel.imagedata.shape,
                                                   vertices)
        type(polygonimg)
        self.panel.maskimg = self.panel.maskimg + polygonimg

        overlay = apMask.overlayMask(self.panel.image, self.panel.maskimg)
        self.panel.setImage(overlay.astype(numpy.float32))

        self.panel.setTargets('Region to Remove', [])