婷婷综合国产,91蜜桃婷婷狠狠久久综合9色 ,九九九九九精品,国产综合av

主頁 > 知識庫 > opencv實現(xiàn)回形遍歷像素算法

opencv實現(xiàn)回形遍歷像素算法

熱門標簽:北京外呼電銷機器人招商 crm電銷機器人 南京crm外呼系統(tǒng)排名 電銷機器人 金倫通信 賓館能在百度地圖標注嗎 汕頭電商外呼系統(tǒng)供應商 云南地圖標注 400電話 申請 條件 鄭州智能外呼系統(tǒng)中心

本文實例為大家分享了opencv實現(xiàn)回形遍歷像素算法的具體代碼,供大家參考,具體內(nèi)容如下

代碼實現(xiàn)

# -*- coding:utf-8 -*-
import cv2
import numpy as np
 
cv2.namedWindow('img', 0)
 
 
def traversePixelByCycloidLine(image):
 """
 從一副灰度圖像的中心開始向邊緣按回形線的方式遍歷所有像素,每個像素只能訪問一次。
 我目前實現(xiàn)了基本的算法, 但存在以下問題:
 1) 只支持方陣, 且行列為奇數(shù)
 2) 只實現(xiàn), 代碼沒整理
 """
 
 h, w = image.shape[:2]
 
 assert h == w and h % 2 == 1, '只支持方陣, 且行列為奇數(shù)'
 
 center_x, center_y = [w // 2, h // 2]
 
 traverse_num = h * w
 
 cycloid_num = 0
 value = 1
 while True:
 
  for i in range(cycloid_num * 2 + 1):
   if value >= traverse_num:
    return image
   center_x = center_x + 1
   image[center_y, center_x] = 255
   value += 1
   cv2.imshow('img', image)
   cv2.waitKey(33)
 
  for i in range(cycloid_num * 2 + 1):
   if value >= traverse_num:
    return image
   center_y = center_y + 1
   image[center_y, center_x] = 255
   value += 1
   cv2.imshow('img', image)
   cv2.waitKey(33)
 
  for i in range(cycloid_num * 2 + 2):
   if value >= traverse_num:
    return image
   center_x = center_x - 1
   image[center_y, center_x] = 255
   value += 1
   cv2.imshow('img', image)
   cv2.waitKey(33)
 
  for i in range(cycloid_num * 2 + 2):
   if value >= traverse_num:
    return image
   center_y = center_y - 1
   image[center_y, center_x] = 255
   value += 1
   cv2.imshow('img', image)
   cv2.waitKey(33)
  cycloid_num += 1
 
 
image_wh = 11
 
while True:
 image = np.zeros((image_wh, image_wh, 3), dtype=np.uint8)
 traversePixelByCycloidLine(image)

效果展示

以上就是本文的全部內(nèi)容,希望對大家的學習有所幫助,也希望大家多多支持腳本之家。

您可能感興趣的文章:
  • python3實現(xiàn)二叉樹的遍歷與遞歸算法解析(小結(jié))
  • Python數(shù)據(jù)結(jié)構(gòu)與算法之二叉樹結(jié)構(gòu)定義與遍歷方法詳解
  • Python二叉樹的定義及常用遍歷算法分析
  • Python算法之圖的遍歷
  • python實現(xiàn)的二叉樹定義與遍歷算法實例

標簽:懷化 昆明 西寧 文山 浙江 梅州 錫林郭勒盟 石家莊

巨人網(wǎng)絡通訊聲明:本文標題《opencv實現(xiàn)回形遍歷像素算法》,本文關(guān)鍵詞  opencv,實現(xiàn),回形,遍歷,像素,;如發(fā)現(xiàn)本文內(nèi)容存在版權(quán)問題,煩請?zhí)峁┫嚓P(guān)信息告之我們,我們將及時溝通與處理。本站內(nèi)容系統(tǒng)采集于網(wǎng)絡,涉及言論、版權(quán)與本站無關(guān)。
  • 相關(guān)文章
  • 下面列出與本文章《opencv實現(xiàn)回形遍歷像素算法》相關(guān)的同類信息!
  • 本頁收集關(guān)于opencv實現(xiàn)回形遍歷像素算法的相關(guān)信息資訊供網(wǎng)民參考!
  • 推薦文章
    主站蜘蛛池模板: 昭通市| 建平县| 黄平县| 平罗县| 安岳县| 绍兴县| 鹤山市| 黎城县| 伽师县| 瑞金市| 兴文县| 且末县| 台东县| 潞城市| 新宾| 望都县| 定日县| 乡宁县| 虞城县| 鹤壁市| 乾安县| 通化县| 白水县| 都安| 贵南县| 唐河县| 崇仁县| 志丹县| 德江县| 临潭县| 鸡西市| 乐安县| 鄢陵县| 益阳市| 新蔡县| 汾阳市| 紫金县| 济宁市| 乌拉特中旗| 玉屏| 招远市|