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


Python ImagePlus.draw方法代码示例

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


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

示例1: SaveCoverFromFs

# 需要导入模块: from ij import ImagePlus [as 别名]
# 或者: from ij.ImagePlus import draw [as 别名]
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,代码行数:31,代码来源:Cover_Maker.py

示例2: SaveCoverFromZip

# 需要导入模块: from ij import ImagePlus [as 别名]
# 或者: from ij.ImagePlus import draw [as 别名]
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,代码行数:44,代码来源:Cover_Maker.py

示例3: CreateCover

# 需要导入模块: from ij import ImagePlus [as 别名]
# 或者: from ij.ImagePlus import draw [as 别名]
def CreateCover(ip, width, height, dbpath):
	# split input image into appropriate tiles
	stackt = SplitImage(ip, width, height)
	impt = ImagePlus("template", stackt)
	nSlicestmp = impt.getNSlices()

	# open the preprocessed database
	print dbpath
	impd = IJ.openImage(dbpath)
	stackd = impd.getImageStack()
	nSlicesdb = impd.getNSlices()

	#associate index with image names
	imageNames = impd.getProperty('Info')
	imageList = imageNames.split(';')

	# set up preview output
	outputip = ColorProcessor(ip.width, ip.height)
	outputimp = ImagePlus("output", outputip)
	outputimp.show()

	cols = ip.width/width
	rows = ip.height/height

	print str(cols) + "," + str(rows)

	x = 0
	y = 0

	arrays = [None, None] # a list of two elements
	cruncher = Inline(arrays)
	tileNames = {}
	tileIndex = {}
	placed = {}
	used = {}

	while len(placed) < nSlicestmp:
		randomTileIndex = random.randint(1, nSlicestmp)
		if randomTileIndex in placed:
			continue
		# transform to row adn column coordinate
		if randomTileIndex%rows == 0:
			y = rows-1
			x = (randomTileIndex/rows)-1
		else:
			y = (randomTileIndex%rows)-1
			x = int(randomTileIndex/rows)

		pixelst = stackt.getPixels(randomTileIndex)
		minimum = Float.MAX_VALUE
		#iterate through database images
		j = 1
		indexOfBestMatch = 0
		arrays[0] = pixelst
		while j < nSlicesdb:
			if j in used:
				j +=1
				continue
			arrays[1] = stackd.getPixels(j)
			diff = cruncher.call()
			if diff < minimum:
				minimum = diff
				indexOfBestMatch = j
			j += 1
		ip = stackd.getProcessor(indexOfBestMatch)
		outputip.copyBits(ip, x*width, y*height, 0)
		used[indexOfBestMatch] = 1
		tileNames[randomTileIndex] = imageList[indexOfBestMatch-1]
		tileIndex[randomTileIndex] = indexOfBestMatch-1
		outputimp.draw()
		placed[randomTileIndex] = 1

	return tileNames, tileIndex, cols, rows
开发者ID:Cersad,项目名称:fiji,代码行数:75,代码来源:Cover_Maker.py


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