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


Python ImagePlus.setRoi方法代码示例

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


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

示例1: generateOverlay

# 需要导入模块: from ij import ImagePlus [as 别名]
# 或者: from ij.ImagePlus import setRoi [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: extract_stack_under_arealist

# 需要导入模块: from ij import ImagePlus [as 别名]
# 或者: from ij.ImagePlus import setRoi [as 别名]
def extract_stack_under_arealist():
	# Check that a Display is open
	display = Display.getFront()
	if display is None:
		IJ.log("Open a TrakEM2 Display first!")
		return
	# Check that an AreaList is selected and active:
	ali = display.getActive()
	if ali is None or not isinstance(ali, AreaList):
		IJ.log("Please select an AreaList first!")
		return

	# Get the range of layers to which ali paints:
	ls = display.getLayerSet()
	ifirst = ls.indexOf(ali.getFirstLayer())
	ilast = ls.indexOf(ali.getLastLayer())
	layers = display.getLayerSet().getLayers().subList(ifirst, ilast +1)

	# Create a stack with the dimensions of ali
	bounds = ali.getBoundingBox()
	stack = ImageStack(bounds.width, bounds.height)

	# Using 16-bit. To change to 8-bit, use GRAY8 and ByteProcessor in the two lines below:
	type = ImagePlus.GRAY16
	ref_ip = ShortProcessor(bounds.width, bounds.height)

	for layer in layers:
		area = ali.getArea(layer)
		z = layer.getZ()
		ip = ref_ip.createProcessor(bounds.width, bounds.height)
		if area is None:
			stack.addSlice(str(z), bp)
			continue

		# Create a ROI from the area of ali at layer:
		aff = ali.getAffineTransformCopy()
		aff.translate(-bounds.x, -bounds.y)
		roi = ShapeRoi(area.createTransformedArea(aff))

		# Create a cropped snapshot of the images at layer under ali:
		flat = Patch.makeFlatImage(type, layer, bounds, 1.0, layer.getDisplayables(Patch), Color.black)
		b = roi.getBounds()
		flat.setRoi(roi)
		ip.insert(flat.crop(), b.x, b.y)

		# Clear the outside of ROI (ShapeRoi is a non-rectangular ROI type)
		bimp = ImagePlus("", ip)
		bimp.setRoi(roi)
		ip.setValue(0)
		ip.setBackgroundValue(0)
		IJ.run(bimp, "Clear Outside", "")

		# Accumulate slices
		stack.addSlice(str(z), ip)

	imp = ImagePlus("AreaList stack", stack)
	imp.setCalibration(ls.getCalibrationCopy())
	imp.show()
开发者ID:151706061,项目名称:fiji,代码行数:60,代码来源:extract_stack_under_arealist.py

示例3: extract_frame_process_roi

# 需要导入模块: from ij import ImagePlus [as 别名]
# 或者: from ij.ImagePlus import setRoi [as 别名]
def extract_frame_process_roi(imp, frame, channel, process, roi):
  # extract frame and channel 
  imp_frame = ImagePlus("", extract_frame(imp, frame, channel)).duplicate()
  # check for roi and crop
  if roi != None:
    #print roi.getBounds()
    imp_frame.setRoi(roi)
    IJ.run(imp_frame, "Crop", "")
  # process  
  if process:
    IJ.run(imp_frame, "Mean 3D...", "x=1 y=1 z=0");
    IJ.run(imp_frame, "Find Edges", "stack");
  # return
  return imp_frame
开发者ID:tischi,项目名称:fiji-correct-3d-drift,代码行数:16,代码来源:Correct_3D_Drift_Plus--ImgLib2.py

示例4: extract_frame_process_roi

# 需要导入模块: from ij import ImagePlus [as 别名]
# 或者: from ij.ImagePlus import setRoi [as 别名]
def extract_frame_process_roi(imp, frame, channel, process, roi, roiz):
  
  if( imp.getStack().getClass().getName() == "ct.vss.VirtualStackOfStacks"):
    imp_frame = extract_cropped_frame_from_VirtualStackOfStacks(imp, frame-1, channel, roi, roiz)
  else:
    # extract frame and channel 
    imp_frame = ImagePlus("", extract_frame(imp, frame, channel, roiz)).duplicate()
    # check for roi and crop
    if roi != None:
      #print roi.getBounds()
      imp_frame.setRoi(roi)
      IJ.run(imp_frame, "Crop", "")
  # process  
  if process:
    IJ.run(imp_frame, "Mean 3D...", "x=1 y=1 z=0");
    IJ.run(imp_frame, "Find Edges", "stack");
  # return
  return imp_frame
开发者ID:tischi,项目名称:fiji-correct-3d-drift,代码行数:20,代码来源:Correct_3D_Drift_Plus--ImgLib2--3D_ROI.py

示例5: run

# 需要导入模块: from ij import ImagePlus [as 别名]
# 或者: from ij.ImagePlus import setRoi [as 别名]
def run():
	""" Loads an image stack which contains both reference and target images for the registration
		Scales the images to have their largest side equal to longSide
		Registration is performed:
			- translation (brute force optimization)
			- rotation (brute force optimization)
			- sift registration
			- bunwarpj registration
		Calculation of the errors by different methods """

	# load the input stack as an ImagePlus
	imp = IJ.openImage(filePath.getAbsolutePath())
	stack = imp.getStack()
	sizeZ = imp.getStackSize()

	LAND_MARKS = 0

	# Copy the reference and target slice
	refId = 1
	ref = stack.getProcessor(refId).duplicate()

	if (Scale == 1):
		[ref, s] = scaleLongSide(ref, longSide)

	sizeZ = min(sizeZ, maxSlice)
	stackReg = ImageStack(ref.getWidth(), ref.getHeight())
	stackReg.addSlice(ref)
# = stack.duplicate()
	for i in range(2, sizeZ+1):
		targetId = i
		target = stack.getProcessor(targetId).duplicate()

		# Scale the slices: scale the reference slice using the longSide parameter, and use the same scale for the target slice.
		if (Scale == 1):
			target = scale(target, s)
			#ImagePlus('Ref',ref).show()
			#ImagePlus('Target',target).show()
	
		if (Reg == 1):
	
			if (translationReg == 1):
				target = translation(ref, target)
	
			if (rotationReg == 1):
				[rot, target] = rotationSingle(ref,target,rotationStep)
	
			if (siftReg == 1):
				[roiRef, roiTarget] = siftSingle(ref, target)
				impTarget = ImagePlus('Target',target)
				impTarget.setRoi(roiTarget)
				#impTarget.show()
				impRef = ImagePlus('Ref',ref)
				impRef.setRoi(roiRef)
				#impRef.show()
				LAND_MARKS = 1

			if (bunwarpjReg == 1):
				target = bunwarpjSingle(impRef, impTarget, LAND_MARKS, 'direct_transfo_' + str(i) + '.txt', 'inverse_transfo_' + str(i) + '.txt')
				impTarget = ImagePlus('unwarpj_target', target)
				#impTarget.show()
				fileName = 'target_id' + str(targetId) + '.tif'
				IJ.saveAs(impTarget, "Tiff", os.path.join(saveDir.getAbsolutePath(), fileName))

			#stackReg.setProcessor(target.convertToShortProcessor(), i)
			stackReg.addSlice(target)

	if (calculateError == 1):
		eCorrelation = zeros(sizeZ, 'f')
		eMSE = zeros(sizeZ, 'f')
		eMSE_ROI = zeros(sizeZ, 'f')
		eRMSE = zeros(sizeZ, 'f')
		eNRMSE = zeros(sizeZ, 'f')
		eCVRMSE = zeros(sizeZ, 'f')
		for i in range(1, sizeZ+1):
			ip = stackReg.getProcessor(i).duplicate()
			#ImagePlus('test',ip).show()
			eCorrelation[i-1], eMSE[i-1], eMSE_ROI[i-1], eRMSE[i-1], eNRMSE[i-1], eCVRMSE[i-1] = measureError(ref,ip)
		errorFileName = 'error.txt'
		errorFilePath = os.path.join(saveDir.getAbsolutePath(), errorFileName)
		writeCSV( errorFilePath, [eCorrelation,eMSE, eMSE_ROI, eRMSE,eNRMSE,eCVRMSE], ["Correlation","MSE","MSE_ROI","RMSE","N_RMSE","CV_RMSE"] )
开发者ID:mbarbie1,项目名称:fiji-registration-plugins,代码行数:82,代码来源:registration_v5.py

示例6: __midline

# 需要导入模块: from ij import ImagePlus [as 别名]
# 或者: from ij.ImagePlus import setRoi [as 别名]
	def __midline(self):
		debug=False
		#print "line 251", self.__boolML
		if self.__boolML :
			ordpoints=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)
			return polyOrd

		#if self.getMaxF()<15 : return None
			#self.__FeretAxis()
			#return self.__line

		self.__boolML=True
		self.__image.killRoi()
		self.__image.setRoi(self.__contour)
		boundRect=self.__contour.getBounds()
		boundRoi=Roi(boundRect)
		xori=boundRect.x
		yori=boundRect.y
		wori=boundRect.width
		hori=boundRect.height
		ip2 = ByteProcessor(self.__image.getWidth(), self.__image.getHeight())
		ip2.setColor(255)
		ip2.setRoi(self.__contour)
		ip2.fill(self.__contour)
		skmp=ImagePlus("ip2", ip2)
		skmp.setRoi(xori-1,yori-1,wori+1,hori+1)
		ip3=ip2.crop()
		skmp3=ImagePlus("ip3", ip3)
		skmp3.killRoi()
		#-------------------------------------------------------------
		if debug : 
			skmp3.show()
			IJ.showMessage("imp3 l287")
		#-------------------------------------------------------------
		IJ.run(skmp3, "Skeletonize (2D/3D)", "")
		#IJ.run(skmp3, "Skeletonize", "")
		#-------------------------------------------------------------
		if debug : 
			skmp3.show()
			IJ.showMessage("imp3 l294")
		#-------------------------------------------------------------
		IJ.run(skmp3, "BinaryConnectivity ", "white")
		ip3.setThreshold(3,4, ImageProcessor.BLACK_AND_WHITE_LUT)
		IJ.run(skmp3, "Convert to Mask", "")
		#-------------------------------------------------------------
		if debug : 
			skmp3.show()
			IJ.showMessage("imp3 l302")
		#-------------------------------------------------------------
		#IJ.run(skmp3, "Skeletonize", "")
		#-------------------------------------------------------------
		if debug : 
			skmp3.updateAndDraw() 
			skmp3.show()
			IJ.showMessage("imp3 l308")
		#-------------------------------------------------------------
		rawPoints=[]
		w=ip3.getWidth()
		h=ip3.getHeight()
		
		rawPoints=[(x+xori,y+yori,self.__sommeVals(x,y,ip3)) for x in range(w) for y in range(h) if ip3.getPixel(x,y)==255]
		tempbouts=[val for val in rawPoints if val[2]==2]

		if len(tempbouts)!=2 : return None
		# test
		#if len(tempbouts)!=2 :
		#	
		#	IJ.run(skmp3, "BinaryConnectivity ", "white")
		#	ip3.setThreshold(3,3, ImageProcessor.BLACK_AND_WHITE_LUT)
		#	IJ.run(skmp3, "Convert to Mask", "")
		#	#-------------------------------------------------------------
		#	if debug==debug : 
		#		skmp3.updateAndDraw() 
		#		skmp3.show()
		#		IJ.showMessage("if test l 328")
		##-------------------------------------------------------------
		#	rawPoints=[(x+xori,y+yori,self.__sommeVals(x,y,ip3)) for x in range(w) for y in range(h) if ip3.getPixel(x,y)==255]
		#	tempbouts=[val for val in rawPoints if val[2]==2]
			
		ip3.setRoi(boundRect)
		if rawPoints==[]: return None
		npoints=len(rawPoints)
		xpoints=[point[0] for point in rawPoints]
		ypoints=[point[1] for point in rawPoints]
		valpoints=[point[2] for point in rawPoints]
		
		bouts={}
		
		if tempbouts==[]: return None
		
		if tempbouts[0][1]>tempbouts[1][1]:
			bouts["A"]=tempbouts[0]
			bouts["B"]=tempbouts[1]
		else:
			bouts["A"]=tempbouts[1]
			bouts["B"]=tempbouts[0]
#.........这里部分代码省略.........
开发者ID:leec13,项目名称:MorphoBactPy,代码行数:103,代码来源:MorphoBact.py

示例7: __fmaxfinder

# 需要导入模块: from ij import ImagePlus [as 别名]
# 或者: from ij.ImagePlus import setRoi [as 别名]
	def __fmaxfinder(self) :
		#stack = self.__impRes.getStack()
		self.__impD.killRoi()
		self.__impF.killRoi()
		stack = self.__impF.getStack()
		n_slices = stack.getSize()
		#newstack=ImageStack(self.__impRes.getWidth(), self.__impRes.getHeight())
		newstack=ImageStack(self.__impF.getWidth(), self.__impF.getHeight())
		noise = self.__display3.text
		for index in range(1,n_slices+1):
			IJ.selectWindow(self.__impF.getTitle())
			self.__impF.setSlice(index)
			ip = self.__impF.getProcessor()
			mf=MaximumFinder()
			ipmax = mf.findMaxima(ip, int(noise), 0, 0, False, False)
			newstack.addSlice("", ipmax)
			

		newimage=ImagePlus("max points"+self.__name, newstack)
		newimage.show()
		newimage.updateAndDraw()
		
		listip = []
		maxh=self.__impRes.getHeight()

		for roi in self.__cellsrois : 
			straightener = Straightener()
			newimage.setSlice(roi[1])
			newimage.setRoi(roi[0])
			#listip.append(straightener.straighten(newimage, roi[0], int(self.__widthl)))
			listip.append(straightener.straighten(newimage, roi[0], maxh))
		
		ipw=[ ip.getWidth() for ip in listip ]
		iph=[ ip.getHeight() for ip in listip ]
		maxw=max(ipw)
		maxh=max(iph)
		
		if self.__enlarge : resizelist = [ ip.resize(maxw, maxh, True) for ip in listip ]
		
		elif  self.__alignC : 
			resizelist = []
			for ip in listip :
				tempip = ByteProcessor(maxw, maxh)
				tempip.copyBits(ip, 0, 0, Blitter.COPY)
				resizelist.append(tempip)

		else :
			resizelist = []
			for ip in listip :
				tempip = ByteProcessor(maxw, maxh)
				tempip.copyBits(ip, 0, 0, Blitter.COPY)
				resizelist.append(tempip)
				
		ims = ImageStack(maxw, maxh) 	
		
		#for ip in resizelist : ims.addSlice("", ip)
		for i in range(len(resizelist)) : 
			ims.addSlice(self.__labels[i], resizelist[i])
		
		self.__impMax = ImagePlus(self.__name+"-max", ims)
		self.__impMax.show()
		stack = self.__impMax.getStack() # get the stack within the ImagePlus
		n_slices = stack.getSize()
		
		for index in range(1, n_slices+1):
			self.__impMax.killRoi()	
			self.__impMax.setSlice(index)
			roi = self.__listrois[index-1]
			
			if self.__sens[index-1]<0 : 
				self.__impMax.setRoi(roi)
				ip1 = self.__impMax.getProcessor()
				ip1.flipHorizontal()
				self.__impMax.killRoi()
				self.__impMax.updateAndDraw()

			ip = self.__impMax.getProcessor()
			for i in range(ip.getWidth()*ip.getHeight()) :
				if ip.getf(i) > 0 : ip.setf(i, 255)
				#else : ip.setf(i, 0)

		IJ.run(self.__impMax, "8-bit", "")
		IJ.run(self.__impMax, "Options...", "iterations=2 count=1 black edm=Overwrite do=Close stack")
		IJ.run(self.__impMax, "Ultimate Points", "stack")
		
		self.__impMax.updateAndDraw()
开发者ID:leec13,项目名称:MorphoBactDev,代码行数:88,代码来源:Stack_Cells.py

示例8: StackCells

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

#.........这里部分代码省略.........
	def __new(self, event): 
		self.__init = True
		self.__n += 1
		self.__name = "stackcells"+str(self.__n)
		self.__display.text = self.__name
		self.__sens[:] = []
		self.__listrois[:] = []
		self.__iplist[:] = []
		self.__cellsrois[:] = []
		self.__labels[:] = []

	def __add(self, event): 
		if ( not self.__init) : 
			IJ.showMessage("", "please start a new stack")
			return
		if ( not self.__initDIA) :
			IJ.showMessage("", "please select an image for DIA")
			return

		if ( not self.__initFLUO) :
			IJ.showMessage("", "please select an image for FLUO")
			return
		
		self.__widthl = self.__display2.getText()
		roi = self.__impD.getRoi()
		
		if roi == None : 
			IJ.showMessage("", "No selection")
			return

		if roi.getType() in [6,7] : 		
			nslice = self.__impD.getCurrentSlice()
			self.__impF.setSlice(nslice)
			self.__impF.setRoi(roi)
		elif roi.getType() in [2,4] :
			nslice = self.__impD.getCurrentSlice()
			self.__impF.setSlice(nslice)
			m=Morph(self.__impF, roi)
			m.setMidParams(10, 2)
			roi=m.MidAxis
			if roi == None :
				self.__display.text = "roi fail"
				if not self.__skip : IJ.showMessage("", "failed roi, please draw it as polyline")
				return				

		#if roi.getType() != 6 : self.__impF.setRoi(roi)
		else : 
			IJ.showMessage("", "This selection is not yet allowed")
			return

		self.__impF.setRoi(roi)
		
		straightener = Straightener()
		new_ip = straightener.straighten(self.__impF, roi, int(self.__widthl))
		
		self.__iplist.append(new_ip)
		self.__labels.append(self.__isF.getShortSliceLabel(nslice))
		
		self.__display.text = self.__name + " cell " + str(len(self.__iplist)) +" width="+str(new_ip.getWidth())+ " height="+ str(new_ip.getHeight())
		roi.setPosition(self.__impD.getCurrentSlice())	

		self.__rm = RoiManager.getInstance()
		if (self.__rm==None): self.__rm = RoiManager()
		
		self.__rm.add(self.__impD, roi, len(self.__iplist))
		self.__cellsrois.append((roi, self.__impD.getCurrentSlice()))
开发者ID:leec13,项目名称:MorphoBactDev,代码行数:70,代码来源:Stack_Cells.py

示例9: call

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

#.........这里部分代码省略.........
				pre_smooth_filename = self.params.output_folder + str(self.patchB) + "_" + str(self.patchA) + "_pre_smooth_pts.txt"
				self.writePointsFile(pm12, pre_smooth_filename)

			if self.params.use_local_smoothness_filter:
				model = Util.createModel(self.params.local_model_index)
				try:
					model.localSmoothnessFilter(pm12, pm12, self.params.local_region_sigma, self.params.max_local_epsilon, self.params.max_local_trust)
					if self.params.save_data:
						post_smooth_filename = self.params.output_folder + str(self.patchB) + "_" + str(self.patchA) + "_post_smooth_pts.txt"
						self.writePointsFile(pm12, post_smooth_filename)
				except:
					pm12.clear()

			color_samples, max_displacement = self.matches2ColorSamples(pm12)
			post_smooth_block_matches = len(pm12)
				
			print time.asctime()
			print str(self.patchB) + "_" + str(self.patchA) + "\tblock_matches\t" + str(pre_smooth_block_matches) + "\tsmooth_filtered\t" + str(pre_smooth_block_matches - post_smooth_block_matches) + "\tmax_displacement\t" + str(max_displacement) + "\trelaxed_length\t" + str(self.params.spring_length) + "\tsigma\t" + str(self.params.local_region_sigma)
			IJ.log(time.asctime())
			IJ.log(str(self.patchB) + "_" + str(self.patchA) + ": block_matches " + str(pre_smooth_block_matches) + ", smooth_filtered " + str(pre_smooth_block_matches - post_smooth_block_matches) + ", max_displacement " + str(max_displacement) + ", relaxed_length " + str(self.params.spring_length) + ", sigma " + str(self.params.local_region_sigma))
			if self.params.save_data and self.wf:
				self.wf.write(str(self.patchB) + 
					"\t" + str(self.patchA) + 
					"\t" + str(pre_smooth_block_matches) + 
					"\t" + str(pre_smooth_block_matches - post_smooth_block_matches) + 
					"\t" + str(max_displacement) + 
					"\t" + str(self.params.spring_length) + 
					"\t" + str(self.params.local_region_sigma) + 
					"\t" + str(num_x) + "\n")

			if self.params.export_point_roi:
				pm12Sources = ArrayList()
				pm12Targets = ArrayList()

				PointMatch.sourcePoints(pm12, pm12Sources)
				PointMatch.targetPoints(pm12, pm12Targets)

				roi1 = pointsToPointRoi(pm12Sources)
				roi2 = pointsToPointRoi(pm12Targets)

				# # Adapted from BlockMatching.java
				# # https://github.com/axtimwalde/mpicbg/blob/master/mpicbg/src/main/java/mpicbg/ij/blockmatching/BlockMatching.java
				# tTarget = TranslationModel2D()
				# sTarget = SimilarityModel2D()
				# tTarget.set(-self.params.search_radius, -self.params.search_radius)
				# sTarget.set(1.0/self.params.scale, 0, 0, 0)
				# lTarget = CoordinateTransformList()
				# lTarget.add(sTarget)
				# lTarget.add(tTarget)
				# lTarget.add(t)
				# targetMapping = TransformMapping(lTarget)

				# mappedScaledTarget = FloatProcessor(fp1.getWidth() + 2*search_radius, fp1.getHeight() + 2*search_radius)

				# targetMapping.mapInverseInterpolated(fp2, mappedScaledTarget)
				# imp1 = tileImagePlus("imp1", fp1)
				# imp1.show()				
				# imp2 = ImagePlus("imp2", mappedScaledTarget)
				# imp2.show()

				imp1 = ImagePlus("imp1", fp1)
				imp1.show()				
				imp2 = ImagePlus("imp2", fp2)
				imp2.show()				

				imp1.setRoi(roi1)
				imp2.setRoi(roi2)

			if self.params.export_displacement_vectors:
				pm12Targets = ArrayList()
				PointMatch.targetPoints(pm12, pm12Targets)

				maskSamples2 = RealPointSampleList(2)
				for point in pm12Targets:
					maskSamples2.add(RealPoint(point.getW()), ARGBType(-1))
				factory = ImagePlusImgFactory()
				kdtreeMatches = KDTree(color_samples)
				kdtreeMask = KDTree(maskSamples)
				
				img = factory.create([fp1.getWidth(), fp1.getHeight()], ARGBType())
				self.drawNearestNeighbor(
							img, 
							NearestNeighborSearchOnKDTree(kdtreeMatches),
							NearestNeighborSearchOnKDTree(kdtreeMask))
				scaled_img = self.scaleIntImagePlus(img, 0.03)
				if self.params.save_data:
					fs = FileSaver(scaled_img)
					fs.saveAsTiff(self.params.output_folder + str(self.patchB) + "_" + str(self.patchA) + ".tif")
				else:
					scaled_img.show()
				print time.asctime()
				print str(self.patchB) + "_" + str(self.patchA) + "\tsaved"
				IJ.log(time.asctime())
				IJ.log(str(self.patchB) + "_" + str(self.patchA) + ": saved")
		except Exception, ex:
			self.exception = ex
			print str(ex)
			IJ.log(str(ex))
			if self.params.save_data and self.wf:
				self.wf.write(str(ex) + "\n")
开发者ID:seung-lab,项目名称:StitchEM,代码行数:104,代码来源:block_matching_montage.py

示例10: range

# 需要导入模块: from ij import ImagePlus [as 别名]
# 或者: from ij.ImagePlus import setRoi [as 别名]
# time_series_measure.py
# this script makes ROI measurements of each slice of a movie
# the results are listed in on continuing table/text file


# Dan White and Silke Gerwig MPI-CBG
# Aug 2009
# Dan White 2016 

#!/usr/bin/env python

from ij import IJ, ImagePlus
# the current image
imp = IJ.getImage()
stack = imp.getStack()
roi = imp.getRoi()

# for all the frames in the movie, run  measure
for i in range(1, imp.getNFrames() + 1):  # remember a python range (1, 10) is the numbers 1 to 9!
#getNFrames not getNSlices since input data is a 2D time series stack NOT a 3D stack.
	frame = ImagePlus(str(i), stack.getProcessor(i))
 	# Execute get statistics exactly on this slice i, with the ROI in use
	frame.setRoi(roi)
	stats = frame.getStatistics()
	IJ.log(" area: "+ str(stats.area) + " mean: "+ str(stats.mean))
IJ.log("Done!")
开发者ID:chalkie666,项目名称:imagejMacros,代码行数:28,代码来源:Time_Series_Measure.py

示例11:

# 需要导入模块: from ij import ImagePlus [as 别名]
# 或者: from ij.ImagePlus import setRoi [as 别名]
    rndOut.append(rnd[j])
    solOut.append(sol[j])
    arOut.append(ar[j])
    gmOut.append(gMode[j])
      
  # rt.reset()  
  # rt.updateResults() 
  if bClose:
    imp.changes = False
    imp.close()
      
  # Now draw particles into the original image
  rm = RoiManager.getInstance()
  ra = rm.getRoisAsArray()
  for r in ra:
    orig.setRoi(r)
    strStroke = "  stroke=%s width=%g" % (col, wid)
    IJ.run(orig, "Properties... ", strStroke )
    IJ.run(orig, "Add Selection...", "")
    orig.killRoi()

  rm.close() 
  outPth = sRptImgPath + strName + ".png"
  # burn a scale bar and save the image
  IJ.run(orig, "RGB Color", "")
  IJ.run(orig, "Add Scale Bar", "width=100 height=6 font=28 color=Green location=[Lower Right] bold")
  IJ.saveAs(orig, "PNG", outPth)
  orig.changes = False
  orig.close()
  
  i += 1 
开发者ID:jrminter,项目名称:OSImageAnalysis,代码行数:33,代码来源:testParticleAnalysis.py


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