elhacker.net cabecera Bienvenido(a), Visitante. Por favor Ingresar o Registrarse
¿Perdiste tu email de activación?.

 

 


Tema destacado: Trabajando con las ramas de git (tercera parte)


  Mostrar Temas
Páginas: [1]
1  Programación / Scripting / Problema con cargar una imagen- Python en: 7 Septiembre 2017, 17:32 pm
Hola, mi problema es luego de cargar la imagen y mostrarla en la interfaz ocurre que quiero modificarlo a operador identidad pero no se como enviar la imagen desde el metodo abre() hacia el metodo identidad() luego mostrarlo ya cambiado necesito hacer el mismo procedimiento para los otros operadores puntuales.
este es el avance que pude hacer
Código
  1. from tkinter import *
  2. from PIL import ImageTk, Image
  3. from tkinter import filedialog
  4. import  tkinter as tk
  5.  
  6. ancho = 200
  7. alto = 0
  8. ventana=Tk()
  9. ventana.geometry("700x600+100+100")
  10. ventana.title("Ejercicio 2")
  11. def abre():
  12.    pic=filedialog.askopenfilename()
  13.    img=Image.open(pic)
  14.    o_size=img.size
  15.    f_size=(200,200)
  16.    factor = min(float(f_size[1])/o_size[1], float(f_size[0])/o_size[0])
  17.    width = int(o_size[0] * factor)
  18.    height = int(o_size[1] * factor)
  19.    rImg= img.resize((width, height), Image.ANTIALIAS)
  20.    rImg = ImageTk.PhotoImage(rImg)
  21.    lblImage=Label(ventana,image=rImg).place(x=150,y=150)
  22.    ventana.mainloop()
  23.    return rImg
  24.  
  25. def identidad(img):
  26.    img=abre()
  27.    salida = Image.new("L",(ancho,alto))
  28.    for i in range(img.size[0]):
  29.        for j in range(img.size[1]):
  30.            p = img.getpixel((i,j))
  31.            q = p
  32.            salida.putpixel((i,j),q)
  33.    return salida
  34.  
  35.    imgGray = Image.open(filedialog.askopenfilename()).convert("L")
  36.    ancho,alto = imgGray.size
  37.    resultado = identidad(imgGray)
  38.    resultado.show()
  39.  
  40. ##label
  41. lbldes=Label(text="Crear en python un menu para seleccionar el tipo de operador puntual a mostrar.",font=("Agency FB",16)).place(x=10,y=45)
  42. lblimang=Label(text="Pulse para cargar imagen",font=("Agency FB",14)).place(x=25,y=80)
  43. #botones##
  44. btnImag=Button(ventana,text="cargar Imagen",command=abre,font=("Agency FB",14),width=15).place(x=200,y=80)
  45. btnImag=Button(ventana,text="Operador Identidad",command=identidad,font=("Agency FB",14),width=15).place(x=30,y=370)
  46.  
  47.  
  48.  
Páginas: [1]
WAP2 - Aviso Legal - Powered by SMF 1.1.21 | SMF © 2006-2008, Simple Machines