当前位置: 首页>>代码示例>>Python>>正文


Python ResultsTable.getValue方法代码示例

本文整理汇总了Python中ij.measure.ResultsTable.getValue方法的典型用法代码示例。如果您正苦于以下问题:Python ResultsTable.getValue方法的具体用法?Python ResultsTable.getValue怎么用?Python ResultsTable.getValue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ij.measure.ResultsTable的用法示例。


在下文中一共展示了ResultsTable.getValue方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: run_straighten

# 需要导入模块: from ij.measure import ResultsTable [as 别名]
# 或者: from ij.measure.ResultsTable import getValue [as 别名]
def run_straighten(roiWindowsize = 4):
    """ Original straightening function based on Nick's macro. Used in final version.
    Returns coordinate string used to make centerline. """
    IJ.run("Set Measurements...", "mean min center redirect=None decimal=3")
    IJ.runMacro("//setTool(\"freeline\");")
    IJ.run("Line Width...", "line=80");
    numPoints = 512/roiWindowsize
    xvals = []
    yvals = []
    maxvals = []
    counter = 0

    for i in range(0, 512, roiWindowsize):
        IJ.run("Clear Results")
        IJ.makeRectangle(i, 0, roiWindowsize, 512)
        IJ.run("Measure")
        table = RT.getResultsTable()
        xvals.append(i + roiWindowsize/2)
        yvals.append(RT.getValue(table, "YM", 0))
        maxvals.append((RT.getValue(table, "Max", 0)))

        if maxvals[counter] == 0 and counter > 0:
            yvals[counter] = yvals[counter - 1]

        counter += 1

    coords = ""
    for i in range(numPoints - 1):
        coords += str(xvals[i]) + ", " + str(yvals[i]) +", "
    coords += str(xvals[numPoints-1]) + ", " + str(yvals[numPoints-1])

    IJ.runMacro("makeLine("+coords+")")
    IJ.run("Straighten...", "line = 80")
    return coords
开发者ID:jsegert,项目名称:Bio119_root_tracking,代码行数:36,代码来源:Straighten+Root+Stack_.py

示例2: straighten_roi_rotation

# 需要导入模块: from ij.measure import ResultsTable [as 别名]
# 或者: from ij.measure.ResultsTable import getValue [as 别名]
def straighten_roi_rotation(roiWindowsize = 8):
    """ Root straightening function that rotates ROI to follow root slope.
    Does not work properly.
    """
    IJ.run("Set Measurements...", "mean standard min center redirect=None decimal=3")
    IJ.runMacro("//setTool(\"freeline\");")
    IJ.run("Line Width...", "line=80");
    #numPoints = 512/roiWindowsize
    xvals = []
    yvals = []
    maxvals = []
    counter = 0
    maxIters = 800/roiWindowsize
    minIters = 10

    imp = IJ.getImage().getProcessor()

    rm = RoiManager()
    if find_first_pixel(0,imp) == None or find_last_pixel(0,imp)[1] == None:
        return
    y = (find_first_pixel(0,imp)[1]+find_last_pixel(0,imp)[1])/2
    roi = roiWindow_(imp, center = (roiWindowsize/2,y), width = roiWindowsize, height = 512)
    xvals.append(roiWindowsize/2)
    yvals.append(y)
    maxvals.append(0)
    roi.findTilt_()
    i = 0
    while i < maxIters and roi.containsRoot_():
    	roi.advance_(roiWindowsize)
        IJ.run("Clear Results")
        IJ.run("Measure")
        table = RT.getResultsTable()

        x  = RT.getValue(table, "XM", 0)
        y = RT.getValue(table, "YM", 0)
        if imp.getPixel(int(x),int(y)) != 0:
            xvals.append(x)
            yvals.append(y)
            maxvals.append((RT.getValue(table, "Max", 0)))


        #roi.advance_(roiWindowsize)
        print "here"
        roi.unrotateRoot_()
        IJ.run("Clear Results")
        IJ.run("Measure")
        roi.restoreCenter_(RT.getValue(table, "XM", 0), RT.getValue(table, "YM", 0))
        #exit(1)
        sleep(.5)
        roi.findTilt_()
        i += 1
    coords = ""
    for i in range(len(xvals)-1):
        coords += str(xvals[i]) + ", " + str(yvals[i]) +", "
    coords += str(xvals[len(xvals)-1]) + ", " + str(yvals[len(xvals)-1])

    IJ.runMacro("makeLine("+coords+")")
    IJ.run("Straighten...", "line = 80")
开发者ID:jsegert,项目名称:Bio119_root_tracking,代码行数:60,代码来源:Straighten+Root+Stack_.py

示例3: containsRoot_

# 需要导入模块: from ij.measure import ResultsTable [as 别名]
# 或者: from ij.measure.ResultsTable import getValue [as 别名]
 def containsRoot_(self):
     IJ.run("Clear Results")
     IJ.run("Measure")
     table = RT.getResultsTable()
     if RT.getValue(table, "Max", 0) == 0:
         return False
     return True
开发者ID:jsegert,项目名称:Bio119_root_tracking,代码行数:9,代码来源:Straighten+Root+Stack_.py

示例4: measure_growth

# 需要导入模块: from ij.measure import ResultsTable [as 别名]
# 或者: from ij.measure.ResultsTable import getValue [as 别名]
def measure_growth(imgDir, filename = "Fiji_Growth.txt"):
    """ Collects measurement data in pixels and writes to a file. Uses straightened binary images"""
    f = open(imgDir + filename, 'w')
    f.write("Img number\tEnd point (pixels)\n")
    IJ.run("Set Measurements...", "area mean min center redirect=None decimal=3")
    index = "000000000"
    filename = imgDir + "/binary" + "/img_" + index + "__000-padded.tif"
    while path.exists(filename):
		imp = IJ.openImage(filename)
		imp.show()
		IJ.run("Clear Results")
		for i in xrange(800): #hard coded to target length for now
			IJ.makeRectangle(i, 0, 1, 80)
			IJ.run("Measure")
			table = RT.getResultsTable()
			#print "i:", i, "counter:", table.getCounter()
			maxi = RT.getValue(table, "Max", i)
			if maxi == 0:
				f.write(str(int(index)) + "\t" + str(i) + "\n")
				break

		IJ.runMacro("while (nImages>0) {selectImage(nImages);close();}")
		index = to_9_Digits(str(int(index)+1))
		filename = imgDir + "/padded" + "/img_" + index + "__000-padded.tif"
    f.close()
开发者ID:jsegert,项目名称:Bio119_root_tracking,代码行数:27,代码来源:Straighten+Root+Stack_.py

示例5: process

# 需要导入模块: from ij.measure import ResultsTable [as 别名]
# 或者: from ij.measure.ResultsTable import getValue [as 别名]
    def process(self,imp):
        # extract nucleus channel, 8-bit and twice binned
        imp.setC(self.nucleusChannel)
        ip = imp.getChannelProcessor().duplicate()
        ip = ip.convertToByteProcessor()
        ip = ip.bin(4)
        nucleus = ImagePlus("nucleus_channel", ip)

        # threshold image and separate clumped nuclei
        IJ.run(nucleus, "Auto Threshold", "method=Otsu white setthreshold show");
        IJ.run(nucleus, "Make Binary", "thresholded remaining black");
        IJ.run(nucleus, "Watershed", "");

        directory = imp.getTitle()
        directory = directory.replace(" ", "_")\
            .replace(",", "_")\
            .replace("#", "_series")\
            .replace("...", "")\
            .replace(".","_")
        directory = os.path.join(self.exportDir, directory)
        sliceDirectory = os.path.join(directory, "slices")
        print directory
        print sliceDirectory
        if not os.path.exists(sliceDirectory):
            os.makedirs(sliceDirectory)

        # Create a table to store the results
        table = ResultsTable()

        # Create a hidden ROI manager, to store a ROI for each blob or cell
        #roim = RoiManager(True)

        # remove small particles and border particles
        pa = ParticleAnalyzer(\
            ParticleAnalyzer.ADD_TO_MANAGER | ParticleAnalyzer.EXCLUDE_EDGE_PARTICLES,\
            Measurements.CENTER_OF_MASS,\
            table,\
            self.minArea, self.maxArea,\
            0.0,1.0)

        if pa.analyze(nucleus):
            print "All ok, number of particles: ", table.size()
        else:
            print "There was a problem in analyzing", imp, nucleus
        table.save(os.path.join(directory, "rt.csv"))

        # read the center of mass coordinates
        cmx = table.getColumn(0)
        cmy = table.getColumn(1)

        if self.debug:
            imp.show()

        i=0
        for i in range(0, min(self.nCells,table.size())):
            # ROI around the cell
            cmx = table.getValue("XM",i)
            cmy = table.getValue("YM",i)
            x = 4 * cmx - (self.boxSize - 1) / 2
            y = 4 * cmy - (self.boxSize - 1) / 2
            if (x < self.edge or y < self.edge or x > imp.getWidth() - self.edge or y > imp.getHeight() - self.edge):
                continue
            roi = Roi(x,y,self.boxSize,self.boxSize)
            imp.setRoi(roi, False)

            cellStack = ImageStack(self.boxSize, self.boxSize)

            for z in range(1, imp.getNSlices() + 1):
                imp.setSlice(z)
                for c in range(1, imp.getNChannels() + 1):
                    imp.setC(c)
                    # copy ROI to stack
                    imp.copy()
                    impSlice = imp.getClipboard()
                    cellStack.addSlice(impSlice.getProcessor())
                    if self.slices:
                        sliceTitle = "cell_%s_z%s_c%s" % (str(i).zfill(4), str(z).zfill(3), str(c))
                        print sliceTitle
                        IJ.saveAsTiff(impSlice, os.path.join(sliceDirectory, sliceTitle))
                    impSlice.close()

            title = "cell_" + str(i).zfill(4)
            cell = ImagePlus(title, cellStack)

            # save ROI image
            IJ.saveAsTiff(cell, os.path.join(directory, title))
            cell.close()

            if self.debug:
                imp.updateAndDraw()
                wait = Wait("particle done")
                wait.show()
开发者ID:UH-LMU,项目名称:lmu-scripts,代码行数:94,代码来源:extract_cells.py

示例6: Morph

# 需要导入模块: from ij.measure import ResultsTable [as 别名]
# 或者: from ij.measure.ResultsTable import getValue [as 别名]

#.........这里部分代码省略.........
		p2 = self.__midLine[icenter]
		#xpoints = (429,472,466)
		#ypoints = (114,133,99)
		xpoints = [int(p1[0]), int(p2[0]), int(p3[0])]
		ypoints = [int(p1[1]), int(p2[1]), int(p3[1])]
		#print ypoints
		#return ""
		r = PolygonRoi(xpoints, ypoints, 3, Roi.ANGLE)
		return r.getAngle()

	def __NbFoci(self):
		self.__boolFoci=True
		self.__image.killRoi()
		self.__image.setRoi(self.__contour)
		self.__ip=self.__image.getProcessor()
		rt=ResultsTable.getResultsTable()
		rt.reset()
		mf=MaximumFinder()
		mf.findMaxima(self.__ip, self.__noise, 0, MaximumFinder.LIST, True, False)
		self.__listMax[:]=[]
		
		#feret=self.getFercoord()
		#xc=feret[0]-((feret[0]-feret[2])/2.0)
		#yc=feret[1]-((feret[1]-feret[3])/2.0)

		#print xc, yc

		xc=self.getXC()
		yc=self.getYC()

		#print xc, yc
		
		for i in range(rt.getCounter()):
			x=int(rt.getValue("X", i))
			y=int(rt.getValue("Y", i))
			size=self.__localwand(x, y, self.__ip, self.__seuilPeaks, self.__peaksMethod, self.__light)
			coord=[(1, xc, x), (1, yc, y)]
 			d=self.distMorph(coord,"Euclidean distance")
 			d=( d / (self.getMaxF()/2) )*100
 			self.__listMax.append((x, y, size[0], size[1], size[2], size[3], size[4], d))
		rt.reset()
		
			
	def __FeretAxis(self):

		__boolFL=True
		if (self.__contour is not None) and (self.__contour.getType() in range(1,11)):
			self.__image.killRoi()
			self.__image.setRoi(self.__contour)
			if self.__contour.getType() in [1,5,9,10]:
				self.__polygon=self.__contour.getPolygon()
			else:
				self.__polygon=self.__contour.getFloatPolygon()
			points = self.__polygon.npoints
			self.__polx = self.__polygon.xpoints
			self.__poly = self.__polygon.ypoints
			diameter=0.0
			for i in range(points):
				for j in range(i, points):
					dx=self.__polx[i]-self.__polx[j]
					dy=self.__poly[i]-self.__poly[j]
					d=math.sqrt(dx*dx+dy*dy)
					if d>diameter:
						diameter=d
						i1=i
						i2=j
开发者ID:leec13,项目名称:MorphoBactPy,代码行数:70,代码来源:MorphoBact.py

示例7: import_and_straighten

# 需要导入模块: from ij.measure import ResultsTable [as 别名]
# 或者: from ij.measure.ResultsTable import getValue [as 别名]
def import_and_straighten(imgDir):
    """
    Core function. Opens images in given directory in series and calls a straightening function.
    Thresholds using weka if stddev of pixel intensities is too high (bright field), otherwise uses
    histogram based segmentation.
    """
    targetWidth = 800 #adjustable
    make_directory(imgDir)
    index = "000000000"
    filename = imgDir + "/img_" + index + "__000.tif"
    if path.exists(filename):
        weka = Weka_segmentor(IJ.openImage(filename))
    while path.exists(filename):
        IJ.run("Set Measurements...", "mean standard min center redirect=None decimal=3")
        IJ.run("Clear Results")
        imp = IJ.openImage(filename)
        imp.show()
        IJ.run("Rotate 90 Degrees Left")
        IJ.run("Measure")
        table = RT.getResultsTable()
        stddev = RT.getValue(table, "StdDev", 0)

        if stddev < 20:
            segmented = weka.getThreshold(imp)
            segmented.show()
            IJ.run("8-bit")
            IJ.run("Invert")
            imp.close()
            imp = segmented

        else:
            IJ.run(imp, "Auto Threshold", "method=Li white") #threshold

        imp = preProcess_(imp)

        #straighten_roi_rotation()
        coords = run_straighten()

        newImp = IJ.getImage()
        """
        fs = FileSaver(newImp)
        fs.saveAsTiff(imgDir + "/straightened" + "/img_" + index + "__000-straight.tif")
        """

        IJ.run("Image Padder", "pad_right="+str(targetWidth - newImp.getWidth()))
        paddedImp = IJ.getImage()
        fs = FileSaver(paddedImp)
        fs.saveAsTiff(imgDir + "/binary" + "/img_" + index + "__000-padded.tif")

        IJ.runMacro("while (nImages>0) {selectImage(nImages);close();}")

        #use same centerline for original greyscale image
        imp = IJ.openImage(filename)
        imp.show()
        IJ.run("Rotate 90 Degrees Left")
        IJ.run("8-bit")
        IJ.runMacro("makeLine("+coords+")")
        IJ.run("Straighten...", "line = 80")
        newImp = IJ.getImage()
        IJ.run("Image Padder", "pad_right="+str(targetWidth - newImp.getWidth()))
        paddedImp = IJ.getImage()
        IJ.run("8-bit")
        fs = FileSaver(paddedImp)
        fs.saveAsTiff(imgDir + "/greyscale" + "/img_" + index + "__000-padded.tif")
        IJ.runMacro("while (nImages>0) {selectImage(nImages);close();}")

        index = to_9_Digits(str(int(index)+1))
        filename = filename = imgDir + "/img_" + index + "__000.tif"
开发者ID:jsegert,项目名称:Bio119_root_tracking,代码行数:70,代码来源:Straighten+Root+Stack_.py


注:本文中的ij.measure.ResultsTable.getValue方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。