[英]How to get index from itertools.product
# loop through every NxN cell in the target image
for (blk_row, blk_col) in itertools.product(xrange(0, height -
(cell_size - 1), cell_size), xrange(0, width - (cell_size - 1), cell_size)):
其中 N = cellsize,除以 cellsize 以獲得索引是否有效?
要獲取任何迭代器的索引,請使用enumerate
:
for index, (blk_row, blk_col) in enumerate(itertools.product(
xrange(0, height - (cell_size - 1), cell_size),
xrange(0, width - (cell_size - 1), cell_size))):
除以 cell_size 似乎有效,手指交叉。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.