예제 #1
0
def centralPixelTangentCalculation_bruteForce(img, row, col, sigma, L, M):

    height, width = img.shape
    windowHeight, windowWidth, inita, initb = _utils.getRanges_for_window_with_adjust(
        row, col, height, width, L)

    sum = 0.0
    for a in range(windowHeight + 1):
        for b in range(windowWidth + 1):
            truea = inita + a
            trueb = initb + b
            sum += math.fabs(math.tanh(sigma * (img[truea][trueb] - M)))
    return sum / pow(L, 2)
예제 #2
0
def centralPixelTangentCalculation_bruteForce(img, copy, row, col, alpha, L):
    height, width = img.shape
    windowHeight, windowWidth, inita, initb = \
        _utils.getRanges_for_window_with_adjust(row, col, height, width, L)

    sum = 0.0
    for a in range(windowHeight + 1):
        for b in range(windowWidth + 1):
            truea = inita + a
            trueb = initb + b
            sum += math.fabs(math.tanh(alpha * (img[truea][trueb])))

    copy[row][col] = sum / pow(L, 2)
예제 #3
0
def centralPixelMomentCalculation(img, row, col, W, p, q):

    m_pq = 0.0
    height, width = img.shape
    windowHeight, windowWidth, initm, initn = _utils.getRanges_for_window_with_adjust(
        row, col, height, width, W)
    for m in range(windowHeight + 1):
        for n in range(windowWidth + 1):
            truem = initm + m
            truen = initn + n
            x_m = (truem - row) / math.floor(W / 2)
            y_n = (truen - col) / math.floor(W / 2)
            x_m_p = pow((x_m), p)
            y_n_p = pow((y_n), q)
            m_pq += (img[truem][truen] * x_m_p * y_n_p)

    return m_pq