Newer
Older
DeepTIAS / Features / DeepLearning / Reference / Tang's / edge_overlappingforFindContours.py
@ke96 ke96 on 2 Nov 2020 2 KB Refactor
from PIL import Image
import os


for filename in os.listdir(r"D:/result_contract/Otherkind/Tongue/20191119/ioulabel2_edge_find_contours6/"):
    print(filename)
    # img_mix = Image.new("RGB", (256, 256), (255, 255, 255))
    img1 = Image.open("D:/result_contract/Otherkind/Tongue/20191119/ioulabel2_edge_find_contours6/" + filename)
    img1_L = img1.convert('RGB')
    # for i in range(0, 256):
    #     for j in range(0, 256):
    #         data1 = img1_L.getpixel((i, j))
    #         if data1 < 128:
    #             img1_L.putpixel((i, j), 0)
    #         else:
    #             img1_L.putpixel((i, j), 255)
    img2 = Image.open("D:/result_contract/Otherkind/Tongue/20191119/50_SRG_edge_find_contours6/" + filename)
    img2_L = img2.convert('RGB')
    # for i in range(0, 256):
    #     for j in range(0, 256):
    #         data2 = img2_L.getpixel((i, j))
    #         if data2 < 128:
    #             img2_L.putpixel((i, j), 0)
    #         else:
    #             img2_L.putpixel((i, j), 255)
    img_mix = Image.blend(img1_L, img2_L, 0.5)
    img3 = Image.open("D:/result_contract/Otherkind/Tongue/20191119/86_SRG_edge_find_contours6/" + filename)
    img3_L = img3.convert('RGB')
    img_mix2 = Image.blend(img_mix, img3_L, 0.4)
    # for i in range(0, 256):
    #     for j in range(0, 256):
    #         data3 = img3_L.getpixel((i, j))
    #         if data3 < 128:
    #             img3_L.putpixel((i, j), 0)
    #         else:
    #             img3_L.putpixel((i, j), 255)

    # data = img_mix.load()
    # for i in range(0, 256):
    #     for j in range(0, 256):
    #         if img1_L.getpixel((i, j)) >= 128:
    #             data[i, j] = (255, 0, 0)
    #         if img2_L.getpixel((i, j)) >= 128:
    #             data[i, j] = (0, 255, 0)
    #         if img3_L.getpixel((i, j)) >= 128:
    #             data[i, j] = (0, 0, 255)
    # img_mix.save('D:/result_contract/Otherkind/Tongue/20191119/edge_mixed3/' + filename)

    img_mix2.save('D:/result_contract/Otherkind/Tongue/20191119/edge_mixed3_86_6/' + filename)

    # img_mix2 = Image.open('D:/result_contract/Otherkind/Tongue/20191119/edge_mixed/' + filename)
    # data = img_mix2.load()
    # for i in range(0, 256):
    #     for j in range(0, 256):
    #         if (data[i, j][0] <= 100) and (data[i, j][1] <= 100) and (data[i, j][2] <= 100):
    #             data[i, j] = (250, 250, 250)
    # img_mix2.save('D:/result_contract/Otherkind/Tongue/20191119/edge_mixed2/' + filename)