Example #1
0
    fix_tag(gray1, xx, yy)

gray_clone = gray1.copy()
gray_clone_find_guodu = gray1.copy()
for i in range(0, gray.shape[0] - 5, 5):
    for j in range(0, gray.shape[1] - 5, 5):
        verify_close(gray, i, j, gray_clone, raw2)

for i in range(3, gray.shape[0] - 5, 5):
    for j in range(3, gray.shape[1] - 5, 5):
        verify_close(gray, i, j, gray1, raw2)

gray1 = p6rgb.merge_tag(gray_clone, gray1)

noise_num = 1
a, b, guodu, d, e = modify.noise_array(raw2_Filter, noise_num)


def merge_guodu(gray_clone_find_guodu, gray1, x, y):
    for i in range(x, x + 9):
        for j in range(y, y + 9):
            if gray_clone_find_guodu[i, j] == 1:
                gray1[i, j] = 1


for i in range(0, gray.shape[0] - 5, 5):
    for j in range(0, gray.shape[1] - 5, 5):
        if is_transition(guodu, i, j, 10):
            merge_guodu(gray_clone_find_guodu, gray1, i, j)

# x, y = p6MyMarchingSquares.traverse_new(double_edge,gray1)
Example #2
0
for l in range(ge):
    temp = guodu.copy()
    for i in range(guodu.shape[0]):
        for j in range(guodu.shape[1]):
            if temp[i, j] == 0:
                temp[i, j] = -1
    # smooth_edge_gray_guodu(temp, raw2_Filter)
    for k in range(50):
        smooth_mid_gray(temp, raw2_Filter)
cv2.imwrite(
    outpath + "4__raw" + str(th) + "noisenum" + str(noise_num) + "____" + src +
    ".jpg", raw2_Filter)

# raw = cv2.imread(outpath + "4__raw" + str(th) + "noisenum" + str(noise_num) + "____" + src + ".jpg")
# raw22 = cv2.cvtColor(raw, cv2.COLOR_BGR2GRAY)
# a, inner, guodu, edge_big, edge_small = modify_rgb.noise_array(raw22, raw, noise_num, th)
a, inner, guodu, edge_big, edge_small = modify.noise_array(
    raw2_Filter, noise_num, th)
for i in range(guodu.shape[0]):
    for j in range(guodu.shape[1]):
        if guodu[i, j] == 1:
            guodu[i, j] = 255
cv2.imwrite(outpath + "newguodu" + str(th) + "____" + src + ".jpg", guodu)

for i in range(guodu.shape[0]):
    for j in range(guodu.shape[1]):
        if edge_big[i, j] == 1 or edge_small[i, j] == 1:
            edge_big[i, j] = 255

cv2.imwrite(outpath + "newedge" + str(th) + "____" + src + ".jpg", edge_big)
Example #3
0
raw2 = cv2.cvtColor(raw, cv2.COLOR_BGR2GRAY)
raw2 = cv2.bilateralFilter(raw2, 7, 50, 50)

print(0)
# np.savetxt("D:\\noise\\gray.csv", raw2, fmt="%d", delimiter=',')

# cv2.imwrite("D:\\noise\\Canny.jpg", cv2.Canny(raw2, 100, 200))
# np.savetxt("D:\\noise\\Canny.csv", cv2.Canny(raw2, 100, 200), fmt="%d", delimiter=',')

# raw2_Filter = cv2.bilateralFilter(raw2, 7, 50, 50)
# cv2.imwrite(outpath + src + "_grayBil" + ".jpg", raw2_Filter)
# np.savetxt(outpath + src + '__grayBil' + '.csv', raw2_Filter, fmt="%d", delimiter=',')
# raw2 = raw2_Filter
start1 = time.clock()
noise_num = 1
a, b, c, d, e = modify.noise_array(raw2, noise_num)
end1 = time.clock()

# np.savetxt("D:\\noise\\noise.csv", a, fmt="%d", delimiter=',')

# raw3 = change.fix_noise(raw2, a, 1)
# cv2.imwrite("D:\\noise\\Canny_fix_noise.jpg", cv2.Canny(raw3, 100, 200))
# np.savetxt("D:\\noise\\re.csv", raw3, fmt="%d", delimiter=',')
#
# rows = raw2.shape
start2 = time.clock()

re = np.zeros((c.shape[0], c.shape[1], 3))
print(1)
# 矛盾点
for i in range(c.shape[0]):