Пример #1
0
def demoThreshold(fname, threshold):
    image = Image.open(fname).convert("L")
    print("Image de départ (niveau de gris) :")
    plt.imshow(image, cmap='gray', vmin=0, vmax=255)
    plt.show()

    img = np.array(image)

    imgThreshold = func.threshold_high(img, threshold)
    print("Image binarisée :")
    plt.imshow(imgThreshold, cmap='gray', vmin=0, vmax=1)
    plt.show()
Пример #2
0
def demoErosionImage(fname, threshold, elemStruct):
    image = Image.open(fname).convert("L")
    print("Image de départ (niv. gris):")
    plt.imshow(image, cmap='gray', vmin=0, vmax=255)
    plt.show()

    img = np.array(image)
    imgBin = func.threshold_high(img, threshold)
    if (fname != './ressource/bin2.png' and fname != './ressource/bin1.png'):
        imgBin = func.invert(imgBin)
    print("Image binariser avec un seuil de ", threshold, ".")
    plt.imshow(imgBin, cmap='gray', vmin=0, vmax=1)
    plt.show()

    print("img érodée")
    imgEro = func.erosion(imgBin, elemStruct)
    plt.imshow(imgEro, cmap='gray', vmin=0, vmax=1)
    plt.show()
Пример #3
0
def demoSqAminHomothophiqueImg(fname, threshold):
    image = Image.open(fname).convert("L")
    print("Image de départ (niv. gris):")
    plt.imshow(image, cmap='gray', vmin=0, vmax=255)
    plt.show()

    img = np.array(image)
    imgBin = func.threshold_high(img, threshold)
    if (fname != './ressource/bin2.png' and fname != './ressource/bin1.png'):
        imgBin = func.invert(imgBin)
    print("Image binariser avec un seuil de ", threshold, ".")
    plt.imshow(imgBin, cmap='gray', vmin=0, vmax=1)
    plt.show()

    print("img squelette [Amin. Homothopique]:")
    imgSq = func.squeletteWithThinHomothopique(imgBin)
    plt.imshow(imgSq, cmap='gray', vmin=0, vmax=1)
    plt.show()
Пример #4
0
def demoEpaississementImage(fname, threshold):
    image = Image.open(fname).convert("L")
    print("Image de départ (niv. gris):")
    plt.imshow(image, cmap='gray', vmin=0, vmax=255)
    plt.show()

    img = np.array(image)
    imgBin = func.threshold_high(img, threshold)
    if (fname != './ressource/bin2.png' and fname != './ressource/bin1.png'):
        imgBin = func.invert(imgBin)
    print("Image binariser avec un seuil de ", threshold, ".")
    plt.imshow(imgBin, cmap='gray', vmin=0, vmax=1)
    plt.show()

    print("img épaissie")
    imgThick = func.epaississement(imgBin)
    plt.imshow(imgThick, cmap='gray', vmin=0, vmax=1)
    plt.show()
Пример #5
0
def testDilatation():
    file3 = './ressource/logo_couleur.jpg'
    fname = file3
    image = Image.open(fname).convert("L")
    print("Image de départ :")
    plt.imshow(image, cmap='gray', vmin=0, vmax=255)
    plt.show()

    img = np.array(image)
    threshold = 124
    imgBin = f.threshold_high(img, threshold)
    print("Image binariser avec un seuil de ", threshold)
    plt.imshow(imgBin, cmap='gray', vmin=0, vmax=1)
    plt.show()

    elemStruct = np.ones((3, 3))

    imgDilate = f.dilatation(imgBin, elemStruct)
    print("dilatation : ")
    plt.imshow(imgDilate, cmap='gray', vmin=0, vmax=1)
    plt.show()
Пример #6
0
def testFinalPart1():
    file2 = './ressource/bin2.png'
    fname = file2
    image = Image.open(fname).convert("L")
    print("Image de départ :")
    plt.imshow(image, cmap='gray', vmin=0, vmax=255)
    plt.show()

    img = np.array(image)
    threshold = 124
    imgBin = f.threshold_high(img, threshold)
    print("Image binariser avec un seuil de ", threshold)
    plt.imshow(imgBin, cmap='gray', vmin=0, vmax=1)
    plt.show()

    elemStruct = np.ones((7, 7))

    imgDilate = f.dilatation(imgBin, elemStruct)
    print("dilatation : ")
    plt.imshow(imgDilate, cmap='gray', vmin=0, vmax=1)
    plt.show()

    imgErosion = f.erosion(imgBin, elemStruct)
    print("erosion : ")
    plt.imshow(imgErosion, cmap='gray', vmin=0, vmax=1)
    plt.show()

    imgOpen = f.ouverture(imgBin, elemStruct)
    print("Open : ")
    plt.imshow(imgOpen, cmap='gray', vmin=0, vmax=1)
    plt.show()

    imgClose = f.fermeture(imgBin, elemStruct)
    print("Close : ")
    plt.imshow(imgClose, cmap='gray', vmin=0, vmax=1)
    plt.show()
Пример #7
0
#
#elemStruct = np.ones((3,3))
#
#imgDilatation = f.dilatation(img, elemStruct)
#plt.imshow(imgDilatation, cmap='gray', vmin=0, vmax=1)
#plt.show()

imgBin = np.zeros((16, 16))
imgBin[4:13, 4:13] = 1
plt.imshow(imgBin, cmap='gray', vmin=0, vmax=1)
plt.show()

fname = file3
image = Image.open(fname).convert("L")
print("Image de départ :")
plt.imshow(image, cmap='gray', vmin=0, vmax=255)
plt.show()

img = np.array(image)
threshold = 200
imgBin = f.threshold_high(img, threshold)
imgBin = f.invert(imgBin)
print("Image binariser avec un seuil de ", threshold)
plt.imshow(imgBin, cmap='gray', vmin=0, vmax=1)
plt.show()

print("img sq lantuejoul")
imgSq = f.erosion(imgBin, np.ones((3, 3)))
plt.imshow(imgSq, cmap='gray', vmin=0, vmax=1)
plt.show()