欧美三区_成人在线免费观看视频_欧美极品少妇xxxxⅹ免费视频_a级毛片免费播放_鲁一鲁中文字幕久久_亚洲一级特黄

雙線性插值理解與Python實現

系統 2213 0

轉載自https://blog.csdn.net/sinat_37011812/article/details/81842957
雙線性插值
雙線性插值理解與Python實現_第1張圖片
雙線性插值理解與Python實現_第2張圖片
公式就是這么推來的,主要就是在x方向和y方向上都進行線性插值,利用臨近點進行計算

在計算的時候利用了幾何中心對齊來優化原來的直接縮放

            
              __author__ = 'Alex Wang'
 
import numpy as np
import cv2
import time
 
 
'''
python implementation of bilinear interpolation
'''
 
 
def bilinear_interpolation(img,out_dim):
    src_h, src_w, channel = img.shape
    dst_h, dst_w = out_dim[1], out_dim[0]
    if src_h == dst_h and src_w == dst_w:
        return img.copy()
    dst_img = np.zeros((dst_h,dst_w,3),dtype=np.uint8)
    scale_x, scale_y = float(src_w) / dst_w, float(src_h) / dst_h
    for i in range(3):
        for dst_y in range(dst_h):
            for dst_x in range(dst_w):
 
                # find the origin x and y coordinates of dst image x and y
                # use geometric center symmetry
                # if use direct way, src_x = dst_x * scale_x
                src_x = (dst_x + 0.5) * scale_x - 0.5
                src_y = (dst_y + 0.5) * scale_y - 0.5
 
                # find the coordinates of the points which will be used to compute the interpolation
                src_x0 = int(np.floor(src_x))
                src_x1 = min(src_x0 + 1 ,src_w - 1)
                src_y0 = int(np.floor(src_y))
                src_y1 = min(src_y0 + 1, src_h - 1)
 
                # calculate the interpolation
                temp0 = (src_x1 - src_x) * img[src_y0,src_x0,i] + (src_x - src_x0) * img[src_y0,src_x1,i]
                temp1 = (src_x1 - src_x) * img[src_y1,src_x0,i] + (src_x - src_x0) * img[src_y1,src_x1,i]
                dst_img[dst_y,dst_x,i] = int((src_y1 - src_y) * temp0 + (src_y - src_y0) * temp1)
 
    return dst_img
 
 
if __name__ == '__main__':
    img = cv2.imread('data/cat1.jpg')
    start = time.time()
    dst = bilinear_interpolation(img,(100,100))
    print 'cost %f seconds' % (time.time() - start)
    cv2.imshow('result',dst)
    cv2.waitKey()

            
          

References:
https://blog.csdn.net/xbinworld/article/details/65660665

https://blog.csdn.net/wudi_X/article/details/79782832

https://en.wikipedia.org/wiki/Bilinear_interpolation


更多文章、技術交流、商務合作、聯系博主

微信掃碼或搜索:z360901061

微信掃一掃加我為好友

QQ號聯系: 360901061

您的支持是博主寫作最大的動力,如果您喜歡我的文章,感覺我的文章對您有幫助,請用微信掃描下面二維碼支持博主2元、5元、10元、20元等您想捐的金額吧,狠狠點擊下面給點支持吧,站長非常感激您!手機微信長按不能支付解決辦法:請將微信支付二維碼保存到相冊,切換到微信,然后點擊微信右上角掃一掃功能,選擇支付二維碼完成支付。

【本文對您有幫助就好】

您的支持是博主寫作最大的動力,如果您喜歡我的文章,感覺我的文章對您有幫助,請用微信掃描上面二維碼支持博主2元、5元、10元、自定義金額等您想捐的金額吧,站長會非常 感謝您的哦!!!

發表我的評論
最新評論 總共0條評論
主站蜘蛛池模板: 亚洲综合视频网 | 一区二区免费在线观看 | 欧美一级片免费看 | 欧美成人免费午夜全 | 亚洲精品高清视频 | 噜噜噜天天躁狠狠躁夜夜精品 | 热99re久久精品2久久久 | 刑事侦缉档案1 | 天天夜夜骑 | 久久精品视频5 | 亚洲欧美日韩一区二区 | 日韩精品一区二区三区中文字幕 | 精品视频一区二区三区在线播放 | 99re在线| 六月丁香婷婷天天在线 | 一本色道久久综合 | 色亚洲视频 | 亚洲精品一区在线观看 | 国产午夜三级一区二区三桃花影视 | 操一操日一日 | 爱爱视频在线观看 | 九九99久久 | 天天摸天天操天天干 | 青娱乐免费| 国产日韩欧美在线 | 狠狠躁夜夜躁人人爽天天段 | 日韩不卡免费视频 | 日韩欧美一区二区在线观看 | 又大又紧又硬又湿a视频 | 亚洲一级视频在线观看 | 99精品免费久久久久久久久日本 | 午夜小视频在线 | 五月色开心婷婷丁香在线 | 欧美aⅴ | asian gaysex | 久热久热| 日本高清不卡一区久久精品 | 久久狠狠一本精品综合网 | 精品国产AV色一区二区深夜久久 | 九九热精 | 在线日韩精品视频 |