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


Python ij.ImagePlus类代码示例

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


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

示例1: SaveCoverFromFs

def SaveCoverFromFs(tiles, newwidth, newheight, cols, rows):

	tilewidth = int(newwidth/cols)
	tileheight = int(newheight/rows)

	newwidth = int(newwidth/tilewidth) * tilewidth
	newheight = int(newheight/tileheight) * tileheight

	hiresoutip = ColorProcessor(newwidth, newheight)
	hiresout = ImagePlus("hi res output", hiresoutip)
	hiresout.show()

	x = 0
	y = -1

	plane = []

	# scale the images
	for i in sorted(tiles.iterkeys()):
		if y < rows-1:
			y += 1
		else:
			y = 0
			x += 1
		imp = IJ.openImage(str(tiles[i]))
		scale = Scale(imp.getProcessor())
		ipscaled = ScaleImageToSize(scale, tilewidth, tileheight)
		hiresoutip.copyBits(ipscaled, x*tilewidth, y*tileheight, 0)
		hiresout.draw()
开发者ID:Cersad,项目名称:fiji,代码行数:29,代码来源:Cover_Maker.py

示例2: scale

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,代码行数:10,代码来源:registration_v5.py

示例3: draw_bounding_boxes

def draw_bounding_boxes(objects,title,templateImage):
	drawnIp = ByteProcessor(templateImage.getWidth(),templateImage.getHeight())
	drawnImage = ImagePlus(title,drawnIp)
	drawnImage.show()
	IJ.selectWindow(title)
	for j in range(len(objects)):
		IJ.makeRectangle(objects[j][42],objects[j][43],objects[j][45]-objects[j][42],objects[j][46]-objects[j][43])
		IJ.run("Draw","stack")
	drawnImage.hide()
	return(drawnImage)
开发者ID:stalepig,项目名称:deep-mucosal-imaging,代码行数:10,代码来源:Display_found_objects.py

示例4: generateOverlay

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,代码行数:26,代码来源:helpers.py

示例5: __init__

		def __init__(self, listpaths):
			self.__listpaths = listpaths
			self.__listimp = []
			for v in listpaths :
				print v
				imp = ImagePlus(v)
				print imp.getTitle()
				self.__listimp.append(imp)
			swing.JFrame.__init__(self, title="Images")
			self.setDefaultCloseOperation(swing.JFrame.DISPOSE_ON_CLOSE)
			self.run()
开发者ID:lisalam,项目名称:Code_VRD,代码行数:11,代码来源:ListeImageBis.py

示例6: scaleLongSide

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,代码行数:12,代码来源:registration_v5.py

示例7: siftSingle

def siftSingle(ref, target):
	""" perform SIFT registration for one image """
	impRef = ImagePlus('Sift_source', ref)
	impTarget = ImagePlus('Sift_target', target)
	expected_transformation = 'Similarity'
	initial_gaussian_blur = 2
	feature_descriptor_size = 8
	imp = ImagePlus('siftRefTest', ref)
	t = SIFT_ExtractPointRoi()
	t.exec( impRef, impTarget )
	roiRef = impRef.getRoi()
	roiTarget = impTarget.getRoi()
	return roiRef, roiTarget
开发者ID:mbarbie1,项目名称:fiji-registration-plugins,代码行数:13,代码来源:registration_v5.py

示例8: __init__

	def __init__(self):
		self.imp = None
		self.preview = None
		self.createMainWindow()
		self.cells = None
		self.files = []
		self.results = ResultsTable()
		ImagePlus.addImageListener(self)
		self.selectInputDir()
		self.selectOutputDir()
		self.pairs = []
		self.methods = []
		self.processNextFile()
开发者ID:rejsmont,项目名称:FijiScripts,代码行数:13,代码来源:mColoc3D.py

示例9: extract_frame_process_roi

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,代码行数:14,代码来源:Correct_3D_Drift_Plus--ImgLib2.py

示例10: test

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,代码行数:15,代码来源:analysingPatternPhotoLithography_fiji.py

示例11: extract_stack_under_arealist

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,代码行数:58,代码来源:extract_stack_under_arealist.py

示例12: __falign

	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,代码行数:46,代码来源:Stack_Cells.py

示例13: run_script

def run_script():
    # We can use import inside of code blocks to limit the scope.
    import math
    from ij import IJ, ImagePlus
    from ij.process import FloatProcessor
    blank = IJ.createImage("Blank", "32-bit black", img_size, img_size, 1)
    # This create a list of lists. Each inner list represents a line.
    # pixel_matrix[0] is the first line where y=0.
    pixel_matrix = split_list(blank.getProcessor().getPixels(), wanted_parts=img_size)
    # This swaps x and y coordinates.
    # http://stackoverflow.com/questions/8421337/rotating-a-two-dimensional-array-in-python
    # As zip() creates tuples, we have to convert each one by using list().
    pixel_matrix = [list(x) for x in zip(*pixel_matrix)]
    for y in range(img_size):
        for x in range(img_size):
            # This function oszillates between 0 and 1.
            # The distance of 2 maxima in a row/column is given by spacing.
            val = (0.5 * (math.cos(2*math.pi/spacing*x) + math.sin(2*math.pi/spacing*y)))**2
            # When assigning, we multiply the value by the amplitude.
            pixel_matrix[x][y] = amplitude * val
    # The constructor of FloatProcessor works fine with a 2D Python list.
    crystal = ImagePlus("Crystal", FloatProcessor(pixel_matrix))
    # Crop without selection is used to duplicate an image.
    crystal_with_noise = crystal.crop()
    crystal_with_noise.setTitle("Crystal with noise")
    IJ.run(crystal_with_noise, "Add Specified Noise...", "standard=%d" % int(amplitude/math.sqrt(2)))
    # As this is a demo, we don't want to be ask to save an image on closing it.
    # In Python True and False start with capital letters.
    crystal_with_noise.changes = False
    crystal.show()
    crystal_with_noise.show()
    filtered = fft_filter(crystal_with_noise)
    # We create a lambda function to be used as a parameter of img_calc().
    subtract = lambda values: values[0] - values[1]
    """ This is a short form for:
    def subtract(values):
        return values[0] - values[1]
    """
    # The first time we call img_calc with 2 images.
    difference = img_calc(subtract, crystal, filtered, title="Difference of 2")
    difference.show()
    # The first time we call img_calc with 3 images.
    minimum = img_calc(min, crystal, filtered, crystal_with_noise, title="Minimum of 3")
    minimum.show()
    for imp in (crystal, crystal_with_noise, filtered, difference, minimum):
        IJ.run(imp, "Measure", "")
开发者ID:imagej,项目名称:imagej-scripting,代码行数:46,代码来源:Wiki_Jython_Tutorial_2.py

示例14: extract_frame_process_roi

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,代码行数:18,代码来源:Correct_3D_Drift_Plus--ImgLib2--3D_ROI.py

示例15: SaveCoverFromZip

def SaveCoverFromZip(tileIndex, newwidth, newheight, cols, rows, originalspath):
	baseDir = re.sub(r'\/originals.zip', "", originalspath)

	#print baseDir

	zf = zipfile.ZipFile(originalspath, mode='r')

	tilewidth = int(newwidth/cols)
	tileheight = int(newheight/rows)

	newwidth = int(newwidth/tilewidth) * tilewidth
	newheight = int(newheight/tileheight) * tileheight

	hiresoutip = ColorProcessor(newwidth, newheight)
	hiresout = ImagePlus("hi res output", hiresoutip)
	hiresout.show()

	x = 0
	y = -1

	plane = []

	# scale the images
	for i in sorted(tileIndex.iterkeys()):
		if y < rows-1:
			y += 1
		else:
			y = 0
			x += 1
		#bi = bir.openImage(tileIndex[i]);
		#ip = ColorProcessor(bi)
		image = zf.read(str(tileIndex[i]) + ".jpeg")
		#IJ.log("Placing image :" + str(tileIndex[i]) + ".jpeg")
		my_file = open(baseDir + 'temporary.jpeg','w')
		my_file.write(image)
		my_file.close()
		imp = IJ.openImage(baseDir + "/temporary.jpeg")
		ip = imp.getProcessor()
		scale = Scale(ip)
		ipscaled = ScaleImageToSize(scale, tilewidth, tileheight)
		hiresoutip.copyBits(ipscaled, x*tilewidth, y*tileheight, 0)
		hiresout.draw()
开发者ID:Cersad,项目名称:fiji,代码行数:42,代码来源:Cover_Maker.py


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