# coding=utf-8
import cv2
import numpy as np
from matplotlib import pyplot as plt
def calcV(window1, window2):
# 用于计算窗口间的差异
win1 = np.int32(window1)
win2 = np.int32(window2)
diff = win1 - win2
diff = diff * diff
return np.sum(diff)
def getWindow(img, i, j, win_size):
# 获得指定范围、大小的窗口内容
if win_size % 2 == 0:
win = None
return win
half_size = int(win_size / 2)
start_x = i - half_size
start_y = j - half_size
end_x = i + half_size + 1
end_y = j + half_size + 1
win = img[start_x:end_x, start_y:end_y]
return win
def getWindowWithRange(img, i, j, win_size):
# 获取指定范围、大小的窗口内容以及坐标
if win_size % 2 == 0:
win = None
return win
half_size = int(win_size / 2)
start_x = i - half_size
start_y = j - half_size
end_x = i + half_size + 1
end_y = j + half_size + 1
win = img[start_x:end_x, start_y:end_y]
return win, start_x, end_x, start_y, end_y
def get8directionWindow(img, i, j, win_size, win_offset):
# 获取