예제 #1
0
    def charger_image(self):
        path = filedialog.askopenfilename(parent=self.view,
                                          initialdir=self.config.datadir,
                                          title="Please select a file:",
                                          filetypes=[('all files', '.*'),
                                                     ('text files', '.txt')])
        img = Image.open(path)

        for bu in self.view.buttons:
            bu.enable()
        self.view.afficher_valeur.config(state=tk.NORMAL)
        self.view.histogramme.config(state=tk.NORMAL)
        self.view.spectre.config(state=tk.NORMAL)

        self.original = img.copy()
        self.old = img.copy()
        self.resultat = img.copy()

        afficher_image(self.original,
                       self.config.figure,
                       1,
                       3,
                       1,
                       title="Original",
                       clear=True)
        plt.show()
예제 #2
0
 def annuler(self):
     self.resultat = self.old.copy()
     afficher_image(self.resultat,
                    self.config.figure,
                    1,
                    3,
                    3,
                    title="Résultat précédent")
     plt.show()
예제 #3
0
 def reinitialiser(self):
     self.old = self.original.copy()
     self.resultat = self.original.copy()
     afficher_image(self.original,
                    self.config.figure,
                    1,
                    3,
                    1,
                    title="Original",
                    clear=True)
     plt.show()
예제 #4
0
 def afficher_resultat(self, name):
     afficher_image(self.old,
                    self.config.figure,
                    1,
                    3,
                    2,
                    title="Résultat précédent")
     afficher_image(self.resultat,
                    self.config.figure,
                    1,
                    3,
                    3,
                    title="Résultat " + str(name))
     plt.show()
예제 #5
0
 def spectre(self):
     spectre = filtre._to_freq(self.resultat)
     afficher_image(normalize(np.log10(abs(spectre))), "Spectre", 1, 1, 1,
                    "Spectre")
     plt.show()
예제 #6
0
def main():

    # l = [1,5,3,2,11,7,8,4]

    image = np.array(Image.open(IMAGE[sys.argv[1]]))
    I = np.array(image)
    M = len(I)
    N = len(I[0])

    # P = ddp_cumule(image)
    # J = normalize(opt(image, egalisation, P=P, excluded=["P"]), 255, dtype=np.uint8)

    # afficher_image(image, "Figure", 1, 2, 1, "Original")
    # afficher_image(J, "Figure", 1, 2, 2, "Resultat")
    # plot_fig(P, "Info", 1, 2, 1, "Plot")
    # plot_fig(ddp_cumule(J), "Info", 1, 2, 2, "Resultat")
    # plt.show()

    # # img = filtre_median(image, N8)
    # bruite = bruit_s_p(image, prob=0.05)
    # bruite = bruit_gauss(bruite, s=10)
    # # print(LAPLACIEN)
    # # print(masque_moyenneur(3))
    # img = filtre(bruite, masque_moyenneur(5))
    # med = filtre(img, masque_moyenneur(5))
    # r = laplacien(med, LAPLACIEN)
    # sobel = op_sobel(r)

    # afficher_image(image, "Figure", 2, 3, 1, "Original")
    # afficher_image(bruite, "Figure", 2, 3, 2, "Bruité")
    # afficher_image(img, "Figure", 2, 3, 3, "Moyenne")
    # afficher_image(med, "Figure", 2, 3, 4, "Median")
    # afficher_image(r, "Figure", 2, 3, 5, "Réhaussé")
    # afficher_image(sobel, "Figure", 2, 3, 6, "Réhaussé")
    # plt.show()

    # afficher_image(image, "Figure", 1, 3, 1, "Original")
    # # H = 1-passe_bas_gaussien(len(image), len(image[0]), 10)
    # H = filtre_pum(passe_bas_butterworth, 0.5, 2, M, N, 20)
    # afficher_image(H, "Figure", 1, 3, 2, "Filtre")
    # rehausse, spectre, j_h = filtre_freq(image, H)
    # # afficher_image(normalize(np.log10(abs(spectre)), 255, np.uint8), "Figure", 1, 4, 3, "Spectre")
    # afficher_image(normalize(abs(rehausse), 255, np.uint8), "Figure", 1, 3, 3, "Resultat")
    # plt.show()

    # i_sp = bruit(bruit(I, poivre, 0.05), sel, 0.05)
    # i_gauss = bruit_gauss(image, u=0, s=50)
    i_uniforme = bruit_uniform(image, 2, 80)
    # i_rayleigh = normalize(bruit(I, rayleigh, a=1, b=10000))
    # i_exp = normalize(bruit(I, exponentiel, a=0.01))
    # i_periodique = bruit_periodique(image, 0.2, 0.2, A=30)

    # afficher_image(image, "Bruit", 2, 3, 1, "Original")
    # afficher_image(i_periodique, "Bruit", 2, 3, 2, "Periodique")
    # afficher_image(i_gauss, "Bruit", 2, 3, 3, "Gauss")
    afficher_image(i_uniforme, "Bruit", 2, 3, 4, "Uniforme")
    # afficher_image(i_sp, "Bruit", 2, 3, 5, "Rayleigh")
    # afficher_image(i_exp, "Bruit", 2, 3, 6, "Erland")

    # afficher_image(i_exp, "Bruit2", 2, 3, 1, "Original")
    # afficher_image(image, "Bruit2", 2, 3, 2, "Exponentiel")
    # afficher_image(image, "Bruit2", 2, 3, 3, "PS+Gauss+Uniforme")
    # afficher_image(image, "Bruit2", 2, 3, 4, "")
    # afficher_image(image, "Bruit2", 2, 3, 5, "")
    # afficher_image(image, "Bruit2", 2, 3, 6, "")

    plt.show()