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


Python Block.getNumPixelsInBlock方法代码示例

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


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

示例1: CalculateBlocks

# 需要导入模块: from block import Block [as 别名]
# 或者: from block.Block import getNumPixelsInBlock [as 别名]
def CalculateBlocks(video_image):
	start = time.time()
        orig_image = video_image
	# orig_image = cv2.imread("block_test.jpg")
	# orig_image = cv2.imread("Picture 11.jpg") # Picture 6-11
	# cv2.imshow("Original", orig_image)
	image = cv2.resize(orig_image, (0,0), fx=0.25, fy=0.25) # half x and y axes
	height, width, channels = image.shape
	# BGR
	# for y in range(0, width):
	# 	for x in range(0, height):
	# 		red = image.item(x,y,2) 
	# 		green = image.item(x,y,1)
	# 		blue = image.item(x,y,0)
	# 		if red > 1.3 * green and red > 1.3 * blue:
	# 			image.itemset((x,y,2),0)
	# 			image.itemset((x,y,1),0)
	# 			image.itemset((x,y,0),0)

	blocks = []
	for x in xrange(10,width-10,10):
		for y in xrange(10,height-10,10):
			block = Block(x,y);

			# print("x,y:", x,",",y)
			FloodFill(x,y,image,block)

			# print("numPixels: ", block.getNumPixelsInBlock())
			if block.getNumPixelsInBlock() > 500:
                                block.meanX = block.accumulatedX / block.getNumPixelsInBlock()
				blocks.append(block)
                                # x, y = block.getBlockBottomPixel()
				# print(x,y)
                                # print (block.meanX == x)
                                # image.itemset((y, x, 0),0)
                                # image.itemset((y, x, 1),255)
                                # image.itemset((y, x, 2),0)

	# print("Blocks: ", len(blocks))
	end = time.time()
	# print("Time: ", (end - start))
	return blocks
开发者ID:Pdgraham,项目名称:MASLAB-2016-Team-2,代码行数:44,代码来源:red_detector.py


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