国产成人精品久久免费动漫-国产成人精品天堂-国产成人精品区在线观看-国产成人精品日本-a级毛片无码免费真人-a级毛片毛片免费观看久潮喷

您的位置:首頁技術(shù)文章
文章詳情頁

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

瀏覽:93日期: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)容,更多關(guān)于python 圖像高斯金字塔的資料請關(guān)注好吧啦網(wǎng)其它相關(guān)文章!

標簽: Python 編程
相關(guān)文章:
主站蜘蛛池模板: 日本一区二区不卡久久入口 | 另类专区国产在线视频 | 狼人 成人 综合 亚洲 | 亚洲国产精品自在现线让你爽 | 国产一区2区 | 一区二区不卡视频在线观看 | 久久精品爱国产免费久久 | 一区欧美 | 久久91亚洲精品中文字幕 | 99精品国产兔费观看久久99 | 国产欧美日韩一区 | 欧美牲| 国模午夜写真福利视频在线 | 国产精品久久国产精品99盘 | 国产在线观看高清精品 | 国产成年 | 久久精品国产免费看久久精品 | 欧美日韩高清在线观看一区二区 | 日韩一区二区免费看 | 日韩一级视频在线观看播放 | 国产午夜精品理论片 | 成人观看的视频三级 | 一本色道久久88加勒比—综合 | 黄色三级毛片网站 | a毛片免费在线观看 | 热re91久久精品国产91热 | 成人99国产精品 | 国产精品成人一区二区三区 | 一级毛片真人不卡免费播 | 一级做a爰片久久毛片潮喷 一级做a爰片久久毛片美女 | 美女午夜影院 | 国产网红自拍 | 99青青| 日韩欧美在线一级一中文字暮 | 国产精品yjizz视频网一二区 | 亚洲欧美激情精品一区二区 | 日韩精品免费一区二区三区 | 久久免费精品国产视频 | 亚洲精品社区 | 天堂8中文在线最新版在线 天堂8资源8在线 | 欧美一线高本道高清在线 |