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


Python ij.ImageStack类代码示例

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


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

示例1: z_stack_opener

def z_stack_opener(path, numberOfSlices="1", file_name_string="%s-Site_%s_%s_z%s.tif", file_name_variables=[]):
    """
        Opens a series of tifs into a stack.
        
        args:
        path -- path to files
        numberOfSlices -- the number of slices to open min 1
        file_name_string -- string with %s formating spaces, z must be last
        file_name_variables -- list of variables to fill in %s spaces
        
        returns:
        z_stack -- imageJ stack -- stack of processors
        paths -- list of paths to the files that were opened
        """
    paths = []
    full_file_name_string = os.path.join(path, file_name_string)
    ## open the first slice
    all_name_variables = tuple(file_name_variables + ["1"])
    img = IJ.openImage(full_file_name_string % all_name_variables)
    ## open a stack
    z_stack = ImageStack(img.width, img.height)
    z_stack.addSlice(file_name_string % all_name_variables, img.getProcessor())
    paths.append(full_file_name_string % all_name_variables)
    ## open the other slices
    for i in range(2, numberOfSlices + 1):
        sliceNameVariables = tuple(file_name_variables + [str(i)])
        img = IJ.openImage(full_file_name_string % sliceNameVariables)
        z_stack.addSlice(file_name_string % sliceNameVariables, img.getProcessor())
        paths.append(full_file_name_string % sliceNameVariables)
    return z_stack, paths
开发者ID:nhthayer,项目名称:PyScroscopyProcessing,代码行数:30,代码来源:MDAprocessing.py

示例2: run

def run():
  sId = IJ.getString("Filenames contain:", "T0000");
  srcDir = DirectoryChooser("Choose!").getDirectory()
  if not srcDir:
    # user canceled dialog
    return
  # Assumes all files have the same size
  stack = None
  for root, directories, filenames in os.walk(srcDir):
    for filename in filenames:
      # Skip non-TIFF files
      if not (sId in filename):
        continue
      print(filename)
      path = os.path.join(root, filename)
      # Upon finding the first image, initialize the VirtualStack
      imp = IJ.openImage(path)
      if stack is None:
        # stack = VirtualStack(imp.width, imp.height, None, srcDir)
        stack = ImageStack(imp.width, imp.height)
      # Add a slice to the virtual stack, relative to the srcDir
      #
      #stack.addSlice(path[len(srcDir):])
      
      # Add a slice to the real stack
      #
      stack.addSlice(filename, imp.getProcessor())
      
  # Make a ImagePlus from the stack
  ImagePlus("Stack from subdirectories", stack).show()
开发者ID:tischi,项目名称:imagej-courses,代码行数:30,代码来源:import-from-sub-folders.py

示例3: run

def run():
  srcDir = DirectoryChooser("Choose!").getDirectory()
  if not srcDir:
    # user canceled dialog
    return
  # Assumes all files have the same size
  filepaths = []
  pattern = re.compile('ch1(.*)_(.*)transformed.mha')
  for root, directories, filenames in os.walk(srcDir):
    for filename in filenames:
      # Skip non-TIFF files
      match = re.search(pattern, filename)
      if (match == None) or (match.group(1) == None):
	    continue
      print(filename)
      path = os.path.join(root, filename)
      filepaths.append(path)
      # Upon finding the first image, initialize the VirtualStack
  
  vs = None
  sorted_filepaths = sorted(filepaths)
  
  for f in sorted(filepaths):
      IJ.openImage(f)
      print(f.split('\\')[-1])
      imp = IJ.getImage()  
      if vs is None:
        vs = ImageStack(imp.width, imp.height)
      # Add a slice, relative to the srcDir
      vs.addSlice(f.split('\\')[-1],imp.getProcessor())
      imp.hide()

  ImagePlus("Stack from subdirectories", vs).show()
开发者ID:tischi,项目名称:fiji-registration,代码行数:33,代码来源:fiji--import-mha-sequence.py

示例4: segmentNuc

def segmentNuc(impc2):
	impdup = Duplicator().run(impc2)
	IJ.run(impdup, "8-bit", "")
	IJ.run(impdup, "Gaussian Blur...", "sigma=1.5 stack")
#	AutoThresholder().getThreshold(AutoThresholder.Method.valuOf('Otsu'), int[] histogram) 
	IJ.setAutoThreshold(impdup, "Otsu dark")
	IJ.run(impdup, "Convert to Mask", "stack")
 	#IJ.setAutoThreshold(impdup, "Otsu dark")
	#opt = PA.SHOW_MASKS + PA.SHOW_RESULTS + PA.EXCLUDE_EDGE_PARTICLES + PA.INCLUDE_HOLES # option for stack missing
	opt = PA.SHOW_MASKS + PA.EXCLUDE_EDGE_PARTICLES + PA.INCLUDE_HOLES # option for stack missing
	##area mean centroid bounding integrated stack redirect=None decimal=4
	meas = Meas.AREA + Meas.MEAN + Meas.CENTROID + Meas.RECT + Meas.INTEGRATED_DENSITY + Meas.STACK_POSITION
	rt = ResultsTable().getResultsTable()
	pa = PA(opt, meas, rt, 10.0, 300000.0, 0, 1.0)
	PA.processStack = True
	pa.setHideOutputImage(True)
	##run("Analyze Particles...", "size=800-Infinity circularity=0.00-1.00 pixel show=Masks display exclude include stack");
	outstack = ImageStack(impdup.getWidth(), impdup.getHeight())
	for i in range(1,impdup.getStackSize()+1):
		impdup.setSlice(i)
		pa.analyze(impdup)
		impbin = pa.getOutputImage()
		outstack.addSlice(impbin.getProcessor())
 	impbin = ImagePlus("out", outstack)
	IJ.run(impbin, "Invert LUT", "")
	#IJ.run(impbin, "Fill Holes", "stack")
	return impbin, rt
开发者ID:cmci,项目名称:ijmacros,代码行数:27,代码来源:nuctrack.py

示例5: getCroppedChannels

	def getCroppedChannels(self, imp, cell):
		splitter = ChannelSplitter()
		imp.setRoi(None)
		if cell.mode3D:
			cropRoi = cell.getCropRoi()
		else:
			cropRoi = cell.roi
		if cropRoi is None:
			return None
		crop = cropRoi.getBounds()
		channels = []
		for c in range(1, imp.getNChannels() + 1):
			slices = ImageStack(crop.width, crop.height)
			channel = splitter.getChannel(imp, c)
			for z in range(1, channel.getSize() + 1):
				zslice = channel.getProcessor(z)
				zslice.setRoi(cropRoi)
				nslice = zslice.crop()
				if cell.mode3D:
					oroi = cell.slices[z - 1].roi	
				else:
					oroi = cell.roi
				if oroi is not None:
					roi = oroi.clone()
					bounds = roi.getBounds()
					roi.setLocation(bounds.x - crop.x, bounds.y - crop.y)
					nslice.setColor(Color.black)
					nslice.fillOutside(roi)
					slices.addSlice(nslice)
			channels.append(ImagePlus("Channel %i" % c, slices))
		return channels
开发者ID:rejsmont,项目名称:FijiScripts,代码行数:31,代码来源:mColoc3D.py

示例6: thresholdStackW

def thresholdStackW(imp, low, high):
    i = 1
    stack = imp.getStack()
    depth = imp.getNSlices()
    print "thresholdStackW: depth", depth
    width = stack.getProcessor(i).getWidth()
    height = stack.getProcessor(i).getHeight()
    winput = [None]
    w = Weaver.inline(
            """
            byte[] input = (byte[]) winput.get(0);
            byte[] output = new byte[input.length];
            for (int i=0; i<input.length; i++) {
                if (input[i] < low || input[i] > high){
                    output[i] = (byte)0;
                } else {
                    output[i] = (byte)255;
                }
            }
            return output;
            """,
            {"winput":winput, "low":low, "high":high})
    stackout = ImageStack(width, height)
    for k in range(1, depth+1):
        ip = stack.getProcessor(k)
        winput[0] = ip.getPixels()
        pixels = w.call()
        ipout = ByteProcessor(width, height)
        ipout.setPixels(pixels)
        stackout.addSlice(ipout)
        imp.setStack(stackout)
开发者ID:UH-LMU,项目名称:lmu-users,代码行数:31,代码来源:adjust_threshold.py

示例7: extractChannel

def extractChannel(imp, nChannel, nFrame):
  	""" Extract a stack for a specific color channel and time frame """
	stack = imp.getImageStack()
	ch = ImageStack(imp.width, imp.height)
	for i in range(1, imp.getNSlices() + 1):
		index = imp.getStackIndex(nChannel, i, nFrame)
		ch.addSlice(str(i), stack.getProcessor(index))
	return ImagePlus("Channel " + str(nChannel), ch)
开发者ID:tischi,项目名称:scripts,代码行数:8,代码来源:2015-04-30--Tischi--KatharinaSonnen--Online_Weka_Metaphase_Detection_.py

示例8: stack_from_list_of_imp

def stack_from_list_of_imp(list_of_imps):
    ''' Returns an ImageStack that contains the images of the given list.
    :param list_of_imp: A list of ImagePlus objects.
    '''
    stack = ImageStack(list_of_imps[0].getWidth(), list_of_imps[0].getHeight())
    for img in list_of_imps:
        stack.addSlice(img.getTitle(), img.getProcessor())
    return stack
开发者ID:m-entrup,项目名称:EFTEMj,代码行数:8,代码来源:Tools.py

示例9: 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

示例10: extractFrames

def extractFrames(imp, interval, offset, nFrames):
 """ Extract a stack containing a subset of frames from a stack """
 stack = imp.getImageStack()
 man = ImageStack(imp.width, imp.height)

 for i in range(0, nFrames):
   index = imp.getStackIndex(0, 1, i * interval + offset)
   man.addSlice(stack.getProcessor(index))
 return ImagePlus("Manual_" + filename, man)
开发者ID:chen-ye,项目名称:Excelsior,代码行数:9,代码来源:Preprocess_for_Manual_Tracking.py

示例11: extract_frame

def extract_frame(imp, frame, channel):
  """ From a VirtualStack that is a hyperstack, contained in imp,
  extract the timepoint frame as an ImageStack, and return it.
  It will do so only for the given channel. """
  stack = imp.getStack() # multi-time point virtual stack
  vs = ImageStack(imp.width, imp.height, None)
  for s in range(1, imp.getNSlices()+1):
    i = imp.getStackIndex(channel, s, frame)
    vs.addSlice(str(s), stack.getProcessor(i))
  return vs
开发者ID:Ghostqiu,项目名称:fiji,代码行数:10,代码来源:Correct_3D_drift.py

示例12: SplitImage

def SplitImage(ip, width, height):
	stack = ImageStack(width, height)

	for x in range(0,ip.width,width):
		for y in range(0,ip.height,height):
			roi = Roi(x,y,width,height)
			ip.setRoi(roi)
			ip2 = ip.crop()
			stack.addSlice(None, ip2)
	return stack
开发者ID:Cersad,项目名称:fiji,代码行数:10,代码来源:Cover_Maker.py

示例13: get_substack

def get_substack(theImage,startSlice,endSlice):
	retStack = ImageStack(theImage.getWidth(),theImage.getHeight())
	
	for i in range(startSlice,endSlice+1):
		theImage.setSliceWithoutUpdate(i)
		ip = theImage.getProcessor()
		newip = ip.duplicate()
		retStack.addSlice(newip)

	return(ImagePlus("dataimage",retStack))
开发者ID:stalepig,项目名称:deep-mucosal-imaging,代码行数:10,代码来源:Resolve_edge_objects.py

示例14: run

def run(title):
    gd = GenericDialog("Record Desktop")
    gd.addNumericField("Max. frames:", 50, 0)
    gd.addNumericField("Milisecond interval:", 300, 0)
    gd.addSlider("Start in (seconds):", 0, 20, 5)
    gd.showDialog()
    if gd.wasCanceled():
        return
    n_frames = int(gd.getNextNumber())
    interval = gd.getNextNumber() / 1000.0  # in seconds
    delay = int(gd.getNextNumber())

    snaps = []

    try:
        while delay > 0:
            IJ.showStatus("Starting in " + str(delay) + "s.")
            time.sleep(1)  # one second
            delay -= 1
        IJ.showStatus("")
        System.out.println("Starting...")
        # start capturing
        robot = Robot()
        box = Rectangle(IJ.getScreenSize())
        start = System.currentTimeMillis() / 1000.0  # in seconds
        last = start
        intervals = []
        real_interval = 0
        # Initial shot
        snaps.append(robot.createScreenCapture(box))
        while len(snaps) < n_frames and last - start < n_frames * interval:
            now = System.currentTimeMillis() / 1000.0  # in seconds
            real_interval = now - last
            if real_interval >= interval:
                last = now
                snaps.append(robot.createScreenCapture(box))
                intervals.append(real_interval)
            else:
                time.sleep(interval / 5)  # time in seconds
                # Create stack
        System.out.println("End")
        awt = snaps[0]
        stack = ImageStack(awt.getWidth(None), awt.getHeight(None), None)
        t = 0
        for snap, real_interval in zip(snaps, intervals):
            stack.addSlice(str(IJ.d2s(t, 3)), ImagePlus("", snap).getProcessor())
            snap.flush()
            t += real_interval

        ImagePlus("Desktop recording", stack).show()
    except Exception, e:
        print "Some error ocurred:"
        print e
        for snap in snaps:
            snap.flush()
开发者ID:Mverp,项目名称:fiji,代码行数:55,代码来源:Record_Desktop.py

示例15: multiply

def multiply(imp, value):
  # check: http://rsb.info.nih.gov/ij/plugins/stack-contrast/index.htm
  stack = imp.getImageStack()
  stack_out = ImageStack(imp.width, imp.height)
  nz = stack.getSize()
  for iz in range(1, nz + 1):
    ip_out = stack.getProcessor(iz).duplicate()
    #print iz, correction
    ip_out.multiply(value) 
    stack_out.addSlice(str(iz), ip_out)
  #segip.invert()
  return ImagePlus("Multiplied", stack_out)
开发者ID:tischi,项目名称:Kaia_Achim_3D_CellCount,代码行数:12,代码来源:ct_analysis_functions.py


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