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


Python ImagePlus.getProcessor方法代码示例

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


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

示例1: generateOverlay

# 需要导入模块: from ij import ImagePlus [as 别名]
# 或者: from ij.ImagePlus import getProcessor [as 别名]
def generateOverlay(project, patch, shape):
    oWidth  = patch.getOWidth()
    oHeight = patch.getOHeight()

    overlayp = ByteProcessor(oWidth, oHeight)
    # TODO: Use ShortProcessor instead of ByteProcessor
    imp      = ImagePlus("Patch %s" % patch, overlayp)
    stepX    = oWidth/shape[0]
    stepY    = oHeight/shape[1]
    color    = 1

    for x in xrange(shape[0]):
        offsetX = x * stepX
        for y in xrange(shape[1]):
            offsetY = y * stepY
            imp.setRoi(offsetX, offsetY, stepX, stepY)
            imp.getProcessor().setValue(color)
            imp.getProcessor().fill()
            color += 1
    imp.setRoi(None)
    
    overlayPatch = Patch(project, "%s_overlay" % patch, 0.0, 0.0, imp)
    
    overlayPatch.setAffineTransform(patch.getAffineTransform())
    overlayPatch.setCoordinateTransform(patch.getCoordinateTransform())
    return overlayPatch
开发者ID:saalfeldlab,项目名称:intensity-transform,代码行数:28,代码来源:helpers.py

示例2: scale

# 需要导入模块: from ij import ImagePlus [as 别名]
# 或者: from ij.ImagePlus import getProcessor [as 别名]
def scale(ip, s):
	""" Scale the image with the parameter scale = s """
	imp = ImagePlus('scale',ip)
	IJ.run(imp, "Scale...", "x="+str(s)+" y="+str(s)+" interpolation=Bilinear average");
	ip = imp.getProcessor()
	w = ip.width
	h = ip.height
	cd = CanvasResizer()
	ip = cd.expandImage(ip, int(round(s*w)), int(round(s*h)), -int(round((1-s)/2*w)), -int(round((1-s)/2*h)) )
	return ip
开发者ID:mbarbie1,项目名称:fiji-registration-plugins,代码行数:12,代码来源:registration_v5.py

示例3: scaleLongSide

# 需要导入模块: from ij import ImagePlus [as 别名]
# 或者: from ij.ImagePlus import getProcessor [as 别名]
def scaleLongSide(ip, longSide):
	""" Scale the image with respect to the longSide parameter (new size along the long side of the image should equal the longSide parameter) """
	w = ip.width
	h = ip.height
	l = max(w,h)
	s = float(longSide)/l
	imp = ImagePlus('scaleLongSide',ip)
	IJ.run(imp, "Scale...", "x="+str(s)+" y="+str(s)+" interpolation=Bilinear average");
	ip = imp.getProcessor()
	cd = CanvasResizer()
	ip = cd.expandImage(ip, int(round(s*w)), int(round(s*h)), -int(round((1-s)/2*w)), -int(round((1-s)/2*h)) )
	return ip, s
开发者ID:mbarbie1,项目名称:fiji-registration-plugins,代码行数:14,代码来源:registration_v5.py

示例4: test

# 需要导入模块: from ij import ImagePlus [as 别名]
# 或者: from ij.ImagePlus import getProcessor [as 别名]
def test():
	newImg = ImagePlus("GrayScaled",imp)
	newip = newImg.getProcessor()

	hist = newip.getHistogram()
	lowTH = Auto_Threshold.IsoData(hist)
	newip.setThreshold(lowTH, max(hist),ImageProcessor.BLACK_AND_WHITE_LUT)


	rt = ResultsTable()
	pa = ParticleAnalyzer(ParticleAnalyzer.SHOW_RESULTS | ParticleAnalyzer.SHOW_OVERLAY_OUTLINES, Measurements.AREA |Measurements.MEAN |\
		Measurements.MEDIAN | Measurements.STD_DEV | Measurements.MIN_MAX | Measurements.RECT, rt,50, 200000, 0.5, 1  )
	pa.setResultsTable(rt)
	pa.analyze(newImg)
	rt.show("Results")
开发者ID:jagannath,项目名称:imageAnalysis,代码行数:17,代码来源:analysingPatternPhotoLithography_fiji.py

示例5: __falign

# 需要导入模块: from ij import ImagePlus [as 别名]
# 或者: from ij.ImagePlus import getProcessor [as 别名]
	def __falign(self) :
		#self.__impRes=IJ.getImage()
		stack = self.__impRes.getStack() # get the stack within the ImagePlus
		n_slices = stack.getSize() # get the number of slices
		ic = ImageCalculator()
		w = self.__impRes.getWidth()
		h = self.__impRes.getHeight()
		self.__sens[:] = []
		self.__listrois[:] = []

		
		
		for index in range(1, n_slices+1):	
			self.__impRes.setSlice(index)
			ip1 = stack.getProcessor(index)
			imp1 = ImagePlus("imp1-"+str(index), ip1)
			#imp1sqr = ic.run("Multiply create 32-bit", imp1, imp1)			

			#IJ.setThreshold(imp1sqr, 1, 4294967296)
			#IJ.run(imp1sqr, "Create Selection", "")
			#IJ.run(imp1sqr, "Select All", "")
			#roi = imp1sqr.getRoi()
			#rect=roi.getBounds()
			#roi = Roi(rect)

			#self.__listrois.append(roi)
			#ipsqr = imp1sqr.getProcessor()
			#is1 = ipsqr.getStatistics()
			#self.__impRes.killRoi()

			IJ.run(imp1, "Select All", "")
			roi = imp1.getRoi()
			self.__listrois.append(roi)			
			ipsqr = imp1.getProcessor()
			is1 = ipsqr.getStatistics()
			self.__impRes.killRoi()
			
			if is1.xCenterOfMass > w/2.00 : 
				self.__impRes.setRoi(roi)
				ip1 = self.__impRes.getProcessor()
				ip1.flipHorizontal()
				self.__impRes.killRoi()
				self.__sens.append(-1)
			else : self.__sens.append(1)
				
			self.__impRes.updateAndDraw()
开发者ID:leec13,项目名称:MorphoBactPy,代码行数:48,代码来源:Stack_Cells.py

示例6: __midline

# 需要导入模块: from ij import ImagePlus [as 别名]
# 或者: from ij.ImagePlus import getProcessor [as 别名]

#.........这里部分代码省略.........

		lineA=Line(xpoints[0],ypoints[0], xa, ya)
		lineB=Line(xpoints[-1],ypoints[-1], xb, yb)
		lineA.setWidth(0)
		lineB.setWidth(0)
		lineA.setStrokeWidth(0) 
		lineB.setStrokeWidth(0)
		
		ip2.setColor(0)
		ip2.fill()
		ip2.setColor(255)
		ip2.setRoi(lineA)
		lineA.drawPixels(ip2)
		ip2.setRoi(lineB)
		lineB.drawPixels(ip2)

		ip2.setRoi(self.__contour)
		ip2.setColor(0)
		ip2.fillOutside(self.__contour)
		ip2=ip2.crop()
		imb=ImagePlus("new-ip2", ip2)
				
		#-------------------------------------------------------------
		if debug : 
			imb.show()
			IJ.showMessage("imb l416")
		#-------------------------------------------------------------
		w2=ip2.getWidth()
		h2=ip2.getHeight()
		ip4 = ByteProcessor(w2+2, h2+2)
		im4=ImagePlus("im4", ip4)

		for i in range(w2):
			for j in range(h2):
				ip4.set(i+1,j+1,max([ip2.getPixel(i,j),ip3.getPixel(i,j)]))
		#im4.show()
		#-------------------------------------------------------------
		if debug : 
			im4.show()
			IJ.showMessage("im4 l430")
		#-------------------------------------------------------------
		im4.killRoi()
		#IJ.run(im4, "Skeletonize (2D/3D)", "")
		#IJ.run(skmp3, "Skeletonize", "")
		#-------------------------------------------------------------
		if debug : 
			imb.show()
			IJ.showMessage("imb l300")
		#-------------------------------------------------------------
		#IJ.run(skmp3, "Skeletonize", "")
		ip4=im4.getProcessor()
		
		rawPoints2=[]
		w4=ip4.getWidth()
		h4=ip4.getHeight()
		

		rawPoints2=[(x+xori-2,y+yori-2,self.__sommeVals(x,y,ip4)) for x in range(w4) for y in range(h4) if ip4.getPixel(x,y)==255]
		self.__MidBouts=[val for val in rawPoints2 if val[2]==2]

		# test
		if len(self.__MidBouts)!=2 : 
			IJ.run(im4, "BinaryConnectivity ", "white")
			ip4.setThreshold(3,3, ImageProcessor.BLACK_AND_WHITE_LUT)
			IJ.run(im4, "Convert to Mask", "")
			rawPoints2=[(x+xori-2,y+yori-2,self.__sommeVals(x,y,ip4)) for x in range(w4) for y in range(h4) if ip4.getPixel(x,y)==255]
			self.__MidBouts=[val for val in rawPoints2 if val[2]==2]
		
		ordpoints=[]
		p0=self.__MidBouts[0]
		rawPoints2.remove(p0)
		c=0
		
		while p0!=self.__MidBouts[1]:
			if c<len(rawPoints2):
				point=rawPoints2[c]
			else: break
			if abs(point[0]-p0[0])<2 and abs(point[1]-p0[1])<2:
				p0=point
				ordpoints.append(point)
				rawPoints2.remove(point)
				c=0
			else: c=c+1

		ordpoints.insert(0, self.__MidBouts[0])
		self.__midLine=ordpoints[:]
		self.__midCenters = self.__Centers(self.__midLine)
		npoints=len(ordpoints)
		xpoints=[point[0] for point in ordpoints]
		ypoints=[point[1] for point in ordpoints]

		polyOrd=PolygonRoi(xpoints, ypoints, npoints, PolygonRoi.POLYLINE)

		
		#print self.__midLine
		#print self.__MidBouts
		#print xpoints
		#print ypoints

		return polyOrd
开发者ID:leec13,项目名称:MorphoBactPy,代码行数:104,代码来源:MorphoBact.py

示例7: ImageStack

# 需要导入模块: from ij import ImagePlus [as 别名]
# 或者: from ij.ImagePlus import getProcessor [as 别名]
	iStack = ImageStack(theImage.getWidth(),theImage.getHeight())
	for sl in range(theImage.getNSlices()):
		sliceIp = ByteProcessor(theImage.getWidth(),theImage.getHeight())
		iStack.addSlice(sliceIp)
	maskImage = ImagePlus("maskImage",iStack)

	## Gets the user-defined ROIs; user can add in any order to image
	sliceList = []
	gd  = NonBlockingGenericDialog("Select freehand ROI, then hit OK when ready to store")
	gd.showDialog()
	while gd.wasOKed():
		roi = theImage.getRoi()
		if roi is not None:
			currSlice = theImage.getCurrentSlice()
			maskImage.setSlice(currSlice)
			currIp = maskImage.getProcessor()
			currIp.setRoi(roi)
			currIp.setColor(255)
			currIp.fill(currIp.getMask())
			sliceList.append(currSlice)
			theImage.setSlice(currSlice+1)
			
		gd  = NonBlockingGenericDialog("Select freehand ROI, then hit OK when ready to store")
		gd.showDialog()

	## Does simple interpolation of the ROIs through the stack
	if len(sliceList)>0:
		sliceList.sort(reverse=True)
		for sl in range(theImage.getNSlices()):
			if (sl+1) < sliceList[-1]:
				maskImage.setSliceWithoutUpdate(sliceList[-1])
开发者ID:stalepig,项目名称:deep-mucosal-imaging,代码行数:33,代码来源:Isolate_stack_ROI.py

示例8: ImagePlus

# 需要导入模块: from ij import ImagePlus [as 别名]
# 或者: from ij.ImagePlus import getProcessor [as 别名]
from ij.process import FloatProcessor
from ij.process import ImageProcessor
from ij.plugin.filter import EDM
from ij.plugin.filter import ParticleAnalyzer
from ij.plugin.frame import RoiManager


from java.util import Random
# don't need to import...
# from java.util import zip
from java.lang import Double
from jarray import zeros

# Explicit float image
imp = ImagePlus("ramp image", FloatProcessor(512, 512))
pix = imp.getProcessor().getPixels()
n_pixels = len(pix)
# catch width
w = imp.getWidth()
  
# create a ramp gradient from left to right
for i in range(len(pix)):
   pix[i] = i % w
  
# adjust min and max, since we know them
imp.getProcessor().setMinAndMax(0, w-1)
imp.show()


# Explicit Byte image
开发者ID:jrminter,项目名称:OSImageAnalysis,代码行数:32,代码来源:exemplarOne_.py

示例9: StackCells

# 需要导入模块: from ij import ImagePlus [as 别名]
# 或者: from ij.ImagePlus import getProcessor [as 别名]

#.........这里部分代码省略.........
		else : 
			roisarray =[(roi, 1) for roi in self.__rm.getRoisAsArray()]
			
		self.__rm.runCommand("reset")
		#self.__rm.runCommand("Delete")
		IJ.selectWindow(self.__impF.getTitle())

		self.__maxraf=float(self.__display19.text)
		self.__minraf=float(self.__display20.text)

		count=1

		for roielement in roisarray :
			roi = roielement[0]
			pos = roielement[1]
			lab = self.__impF.getImageStack().getShortSliceLabel(pos)

			if lab==None : lab=str(pos)
			
			if self.__conEllipses :
				IJ.selectWindow(self.__impF.getTitle())
				self.__impF.setSlice(pos)
				self.__impF.setRoi(roi)
				self.__rm.runCommand("Add")
				IJ.run(self.__impF,  "Fit Ellipse", "")
				ellipse=self.__impF.getRoi()
				params = ellipse.getParams()
				ferets = ellipse.getFeretValues()
				imp2 = Duplicator().run(self.__impF,pos,pos)
				IJ.run(imp2, "Rotate... ", "angle="+str(ferets[1])+" grid=0 interpolation=Bilinear enlarge slice")
				temproi=Roi((imp2.getWidth()-ferets[0])/2.0,(imp2.getHeight()-ferets[2])/2.0,ferets[0],ferets[2])
				imp2.setRoi(temproi)
				imp3 = Duplicator().run(imp2,1,1)
				ip3=imp3.getProcessor()

				if int(self.__display5.text) < ip3.getWidth() < int(self.__display6.text) : 
					self.__iplist.append(ip3)
					self.__display.text = self.__name + " cell " + str(len(self.__iplist))
					fer=Line(params[0],params[1],params[2],params[3])
					self.__cellsrois.append((fer, pos))
					self.__labels.append(self.__isF.getShortSliceLabel(pos))

				m=Morph(self.__impF, roi)

				twres.append(lab+tab+str(roi.getName())+tab+str(m.Solidity)+tab+str(m.Area)+tab+str(m.Circ)+tab+str(m.AR)+tab+str(m.MaxFeret)+tab+str(fer.getLength())+tab+str(1)+tab+str(0)+tab+str(0)+tab+str(0))
				self.__dictCells[count]=(str(roi.getName()), lab, roi)
				count=count+1
				continue
			
			if roi.getType() in [6,7] : 
				self.__impF.setSlice(pos)
				self.__impF.setRoi(roi)
				self.__rm.runCommand("Add")

			elif roi.getType() in [2,4] :
				self.__impF.setSlice(pos)
				self.__impF.setRoi(roi)
				m=Morph(self.__impF, roi)
				m.setMidParams(10, 2)
				midroi=m.MidAxis
				if midroi == None : continue

				raf = m.MaxFeret/midroi.getLength()
				
				if (self.__maxraf < raf) or (raf < self.__minraf) : continue
开发者ID:leec13,项目名称:MorphoBactDev,代码行数:69,代码来源:Stack_Cells.py

示例10: print

# 需要导入模块: from ij import ImagePlus [as 别名]
# 或者: from ij.ImagePlus import getProcessor [as 别名]
impG = WindowManager.getImage(imgNamG)
impG.show()

# create a gray image fo redirect...
impGbare = impG.duplicate()
impGbare.setTitle("green_channel")
impGbare.show()

impG.setRoi(OvalRoi(22,12,334,337))
impG.show()

w = impG.getWidth()
h = impG.getHeight()
print(w, h)
sp = ByteProcessor(w,h)
blank = ImagePlus("blank", sp)
pix = blank.getProcessor().getPixels()
for i in range(len(pix)):
   pix[i] = -1

blank.show()

IJ.selectWindow("original (green)");
IJ.run("Copy")
IJ.selectWindow("blank")
IJ.run("Paste")

blank.show()


开发者ID:jrminter,项目名称:OSImageAnalysis,代码行数:30,代码来源:R_Gupta_.py

示例11: processOneImage

# 需要导入模块: from ij import ImagePlus [as 别名]
# 或者: from ij.ImagePlus import getProcessor [as 别名]
def processOneImage(inputDir):
    tmp = glob.glob(os.path.join(inputDir, "fibrone*"))
    fibronectin = tmp[0]
    tmp = glob.glob(os.path.join(inputDir, "nucleus*"))
    nucleus = tmp[0]
    tmp = glob.glob(os.path.join(inputDir, "actin*"))
    actin = tmp[0]
    
    # read sample name
    head,tail = os.path.split(inputDir)
    sample = tail.replace(".tif_Files","")

    # original images
    imp_fn_orig = IJ.openImage(fibronectin)
    imp_nuc_orig = IJ.openImage(nucleus)

    # work copies
    imp_fn = imp_fn_orig.duplicate()
    imp_nuc = imp_nuc_orig.duplicate()

    IJ.run(imp_fn,"Set Scale...", "distance=1 known=1 pixel=1 unit=pixels")
    IJ.run(imp_fn,"Gaussian Blur...","sigma=5")
    IJ.run(imp_fn,"Make Binary","")
    IJ.run(imp_nuc,"Set Scale...", "distance=1 known=1 pixel=1 unit=pixels")
    IJ.run(imp_nuc,"Gaussian Blur...","sigma=5")
    IJ.run(imp_nuc,"Make Binary","")

    # get moments of the fibronectin image
    moments_file = os.path.join(OUTPUT, sample + " moments.txt")
    printMoments(fibronectin, moments_file)
    moments = readMoments(moments_file)
    print moments.m00
    sys.exit()

    # centroid of fibronectin anchor
    centers = getParticleCenters(imp_fn)
    cxfn = int(round(centers[0][0]))
    cyfn = int(round(centers[1][0]))
    fn_centroid_roi = PointRoi(cxfn,cyfn)
    fn_centroid_roi.setDefaultMarkerSize("Large")
    fn_centroid_roi.setStrokeColor(Color.CYAN)

    # center of mass of nucleus 
    centers = getParticleCenters(imp_nuc)
    cxnuc = int(round(centers[2][0]))
    cynuc = int(round(centers[3][0]))
    nuc_com_roi = PointRoi(cxnuc,cynuc)
    nuc_com_roi.setDefaultMarkerSize("Large")

    # skeletonize fibronectin anchor to find its orientation
    IJ.run(imp_fn,"Skeletonize","")
    skel = AnalyzeSkeleton_()
    skel.setup("",imp_fn)
    skelResult = skel.run(skel.NONE, False, True, None, True, True)
    graph = skelResult.getGraph()
    print len(graph)
    print skelResult.getNumOfTrees()
    # find the longest graph
    graph = sorted(graph, key=lambda g: getGraphLength(g), reverse=True)
    graph = graph[0]
    edges = graph.getEdges()
    # find longest edge, the main axis of the anchor
    edges = sorted(edges, key=lambda edge: edge.getLength(), reverse=True)
    #for e in edges:
    #    print e.getLength()
    v1long = edges[0].getV1()
    v2long = edges[0].getV2()
    x1 = v1long.getPoints()[0].x
    y1 = v1long.getPoints()[0].y
    x2 = v2long.getPoints()[0].x
    y2 = v2long.getPoints()[0].y
    anchor_roi = PointRoi(x1,y1)
    anchor_roi = anchor_roi.addPoint(x2,y2)
    # find top and bottom vertices of the graph
    vertices = graph.getVertices()
    vertices = sorted(vertices, key=lambda vertex: vertex.getPoints()[0].y)
    v1short = vertices[len(vertices)-1]
    v2short = vertices[0]
    x3 = v1short.getPoints()[0].x
    y3 = v1short.getPoints()[0].y
    x4 = v2short.getPoints()[0].x
    y4 = v2short.getPoints()[0].y
    anchor_roi = anchor_roi.addPoint(x3,y3)
    anchor_roi = anchor_roi.addPoint(x4,y4)
    # calculate angles
    a1 = math.atan(abs(float(y2-y1)/float(x2-x1))) / math.pi * 360
    a2 = math.atan(abs(float(x4-x3)/float(y4-y3))) / math.pi * 360
    amean = float((a1+a2)/2)
    dx = cxfn-cxnuc
    print sample,cxfn,cyfn,cxnuc,cynuc,dx,math.cos(amean)*dx,x1,y1,x2,y2,x3,y3,x4,y4,a1,a2

    # create composite
    comp = ImagePlus("composite",imp_nuc_orig.getProcessor().convertToColorProcessor())
    comp.getProcessor().setChannel(2,imp_fn_orig.getProcessor())
    comp.getProcessor().setChannel(3,imp_fn.getProcessor())
    comp.show()
    comp.getProcessor().drawRoi(fn_centroid_roi)
    comp.getProcessor().drawRoi(nuc_com_roi)
    comp.getProcessor().drawRoi(anchor_roi)
    comp.repaintWindow()
#.........这里部分代码省略.........
开发者ID:UH-LMU,项目名称:lmu-users,代码行数:103,代码来源:jaakko1.py


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