久久福利_99r_国产日韩在线视频_直接看av的网站_中文欧美日韩_久久一

您的位置:首頁技術文章
文章詳情頁

python實現(xiàn)圖像高斯金字塔的示例代碼

瀏覽:88日期:2022-07-02 14:58:51

import cv2import numpy as npimport matplotlib.pyplot as plt# Grayscaledef BGR2GRAY(img): # Grayscale gray = 0.2126 * img[..., 2] + 0.7152 * img[..., 1] + 0.0722 * img[..., 0] return gray# Bi-Linear interpolationdef bl_interpolate(img, ax=1., ay=1.): if len(img.shape) > 2: H, W, C = img.shape else: H, W = img.shape C = 1 aH = int(ay * H) aW = int(ax * W) # get position of resized image y = np.arange(aH).repeat(aW).reshape(aW, -1) x = np.tile(np.arange(aW), (aH, 1)) # get position of original position y = (y / ay) x = (x / ax) ix = np.floor(x).astype(np.int) iy = np.floor(y).astype(np.int) ix = np.minimum(ix, W-2) iy = np.minimum(iy, H-2) # get distance dx = x - ix dy = y - iy if C > 1: dx = np.repeat(np.expand_dims(dx, axis=-1), C, axis=-1) dy = np.repeat(np.expand_dims(dy, axis=-1), C, axis=-1) # interpolation out = (1-dx) * (1-dy) * img[iy, ix] + dx * (1 - dy) * img[iy, ix+1] + (1 - dx) * dy * img[iy+1, ix] + dx * dy * img[iy+1, ix+1] out = np.clip(out, 0, 255) out = out.astype(np.uint8) return out# make image pyramiddef make_pyramid(gray): # first element pyramid = [gray] # each scale for i in range(1, 6): # define scale a = 2. ** i # down scale p = bl_interpolate(gray, ax=1./a, ay=1. / a) # add pyramid list pyramid.append(p) return pyramid# Read imageimg = cv2.imread('../bird.png').astype(np.float)gray = BGR2GRAY(img)# pyramidpyramid = make_pyramid(gray)for i in range(6): cv2.imwrite('out_{}.jpg'.format(2**i), pyramid[i].astype(np.uint8)) plt.subplot(2, 3, i+1) plt.title(’1/’ + str((i+1)**2) ) plt.imshow(pyramid[i], cmap=’gray’) plt.axis(’off’) plt.xticks(color='None') plt.yticks(color='None')plt.show()

python實現(xiàn)圖像高斯金字塔的示例代碼

python實現(xiàn)圖像高斯金字塔的示例代碼

以上就是python實現(xiàn)圖像高斯金字塔的示例代碼的詳細內(nèi)容,更多關于python 圖像高斯金字塔的資料請關注好吧啦網(wǎng)其它相關文章!

標簽: Python 編程
相關文章:
主站蜘蛛池模板: av片免费看 | a级片网站 | 亚洲青涩在线 | 天天躁日日躁狠狠躁av麻豆 | 国产毛片精品 | 国产精品久久久久国产a级 91福利网站在线观看 | 成人福利网 | 99久久精品免费看国产免费粉嫩 | 最近免费中文字幕大全免费版视频 | 亚洲一区二区在线视频 | 狠狠的日 | 久久密 | 午夜精品久久久久久久 | 亚洲一区中文字幕在线观看 | 日韩无在线 | 色综久久 | 欧美一区二区三区免费观看视频 | 伊人网网站 | 亚洲精品久久久久久久久久 | 精品成人在线 | 可以免费观看的av片 | 午夜www| 综合色爱 | 91精品国产综合久久久久久漫画 | 国产美女黄色片 | 日韩视频在线观看 | 国产精品久久久久久久久免费桃花 | 国产免费av一区二区三区 | 色视频在线播放 | 精产国产伦理一二三区 | 国产成人精品一区二区三区视频 | 男女黄色免费网站 | 久久久久久亚洲精品 | 亚洲欧美日韩在线 | 亚洲精彩视频在线观看 | 影视一区 | 99精品视频一区二区三区 | 一区二区三区视频 | 欧美一区二区三区在线看 | 成人h动漫在线看 | 麻豆一区二区三区 |