from PyQt5.QtCore import QSize, Qt from PyQt5.QtWidgets import QApplication, QWidget, QTextBrowser, QLineEdit, QVBoxLayout, QLabel, QPushButton, QVBoxLayout, QHBoxLayout, QFileDialog, QComboBox from PyQt5.QtGui import QPixmap import sys, os, os.path import os import numpy as np import skimage as sk import skimage.io as io import numpy.linalg as lin import matplotlib.pyplot as plt import scipy as spy class fenetre(QWidget): def __init__(self, parent = None): super(self, changcanal).__init__(parent) # Création de la fenêtre Vertical self.vLayout = QVBoxLayout() #Titre de la fenêtre # Création du champ d'affichage self.label = QLabel() self.label.setScaledContents(True) # Création du bouton charger self.button = QPushButton('Charger') self.button.clicked.connect(self.charger) self.button.setDefault(True) # Bouton de taille fixe, centré self.button.setFixedSize(self.button.sizeHint()) hLayout = QHBoxLayout() hLayout.addWidget(self.button, Qt.AlignHCenter) #Création du menu de changement de canal layout = QHBoxLayout() self.cb = QComboBox() self.cb.addItems(["Rouge", "Vert", "Bleu", "Infrarouge"]) self.cb.currentIndexChanged.connect(self.selectionchange) layout.addWidget(self.cb) self.setLayout(layout) def selectionchange(self, i): print("Les canaux possibles sont :") for count in range(self.cb.count()): print self.cb.itemText(count) print("Canal", i, "Canal changé", self.cb.currentText()) def main(): app = QApplication(sys.argv) ex = fenetre(QWidget) fenetre.show() sys.exit(app.exec_()) if __name__ == '__main__': main() # Création du bouton OK self.button1 = QPushButton('OK') self.button1.clicked.connect(self.OK) self.button1.setDefault(True) # Bouton de taille fixe, centré self.button1.setFixedSize(self.button.sizeHint()) hLayout = QHBoxLayout() hLayout.addWidget(self.button, Qt.AlignHCenter) # Aligner la zone Verticalement self.vLayout.addWidget(self.label) # self.vLayout.addWidget (self.button) self.vLayout.addLayout(hLayout) # Creation de la zone self.pixmap = QPixmap() self.setWindowTitle('Images') self.setLayout(self.vLayout) # Memorisation du chemin courant self.path = None def charger(self): # Demande le nom du fichier à charger fileToOpen, _ = QFileDialog.getOpenFileName(None, 'Open a File', self.path, '*.png *.jpg *.gif *.bmp *.Tif *.Tiff') # Isole le chemin memorisé pour la prochaine fois self.path = os.path.dirname(fileToOpen) # Charge le fichier image self.pixmap.load(fileToOpen) # Calcule le Zoom pour tenir dans les limites de la fenêtre width = self.pixmap.size().width() height = self.pixmap.size().height() if width > 1000 or height > 600: factor = max(width / 1000, height / 600) self.label.setFixedSize(QSize(width / factor, height / factor)) else: self.label.setFixedSize(QSize(width, height)) # Affiche l'image self.label.setPixmap(self.pixmap) # Redimensionne self.setFixedSize(self.vLayout.sizeHint()) # def OK(self): # if VisuLandSat.cb == "Bleu": # ##-----------------Import de l'image-------------- # # img = io.imread('etm_29aout1999_ssb.tif') # # ncan = np.size(img, 0) # ny = np.size(img, 1) # nx = np.size(img, 2) # N = ny * nx # # # # --- Tableau des observations multi-spectrales --- # X = np.zeros((ny, nx, ncan), float) # for i in range(ncan): # X[:, :, i] = img[i, :, :] # # # # --- Affichage du canal bleu # img3cp = np.zeros((np.size(img, 1), np.size(img, 2), 3), dtype=np.uint8) # img3cp[:, :, 0] = (X[:, :, 2]) # img3cp[:, :, 1] = (X[:, :, 1]) # img3cp[:, :, 2] = (X[:, :, 0]) # # # fig = plt.figure() # image = io.imshow(img3cp) # fig.set_tight_layout(True) # plt.savefig('etm_29aout1999_ssb_RGB.png', dpi=300) # --- Image RGB --- # plt.show(image) app = QApplication(sys.argv) dialogue = displayJPEG() dialogue.show() app.exec_() ## # # --- Lecture de la donnée multi-spectrale Landsat --- # # ## # #---- Fin du programme : Visu_Landsat ---- #