This reminds me that we have a whole GUI viewer toolkit that's not seen a lot of love and attention lately. I recently ported it to Qt5, but still have to submit cleaned up patches. That got me thinking that it would be nice to have this in a browser, in a Jupyter notebook.
So I sent an email to the developers, and it looks like they've now more-or- less completed their widgets API, and it should be mostly backward compatible from version 6 onward. Shall we re-open the discussion on writing interactive Javascript widgets? I'm thinking of a Fiji or Gimp-like application that showcases various pieces of functionality. Stéfan On Tue, Oct 25, 2016, at 15:43, Juan Nunez-Iglesias wrote: > Hi Xavi, > > Sorry for the long delay in responding. > > I'm excited about your GUI! If you have it on GitHub somewhere, > please point us to it, as it would be a great template for others to > build from! > > Regarding your black image problem, my guess is that you are having > some issues with the data types in skimage. Your input image is a > uint8 image (?), with range [0, 255], but filters.gaussian runs it > through our conversion to a float image, which results in the range > [0.0, 1.0]. Some displays will still display this as though the full > range is in [0, 255], so the image will appear black. You probably > need to back-convert to int using skimage.img_as_ubyte. > > See: > http://scikit-image.org/docs/dev/user_guide/data_types.html > > I hope that helps. Again, please point us to your repo if you are > happy to share! > > Juan. > > > On 8 October 2016 at 8:12:13 am, xavi barrull > (xavi_barr...@hotmail.com) wrote: >> >> >> >> Hi, I have a question about scikit image. >> I make a GUI in python to processing image, but I will change the >> gaussian Filter in opencv to scikit image, I use this function: >> >> def gaussFilter(self): targetTemp = >> sk.io.imread(self.original_path)# llegir imatge targetTemp a la ruta >> original targetTemp = sk.filters.gaussian(targetTemp, >> sigma=0, mode='reflect', cval=0, multichannel=False) >> #targetTemp = cv2.GaussianBlur(targetTemp,(sigmaX, sigmaY), 0) >> cv2.imwrite(self.target_path,targetTemp) >> self.updateTargetImage() >> >> But, when I press the button of gaussian filter the image to update >> becomes black, what is the problem? I need a solution for this! >> >> My code show bellow: >> >> >> import Tkinter as tk import numpy as np import tkFileDialog import >> tkMessageBox import shutil import os from PIL import Image, ImageTk, >> ImageFilter import cv2 import colormaps import skimage as sk import >> matplotlib.pyplot as plt from matplotlib.colors import ListedColormap >> from matplotlib.figure import Figure from skimage import filters from >> skimage import io from skimage.morphology import disk from >> skimage.filters.rank import median from skimage.filters import >> gaussian from skimage.morphology import watershed from >> matplotlib.backends.backend_tkagg import FigureCanvasTkAgg >> >> class App(tk.Frame): size = 500, 700 >> # get past scale value >> past=1 >> # inicialitzar app >> def __init__(self, master): tk.Frame.__init__(self, master) >> self.grid(row=0) self.columnconfigure(0, weight=1) >> self.rowconfigure(0, weight=1) master.geometry("1024x768") >> self.generateMenu(master) >> # Generacio Menu >> def generateMenu(self, master): >> # crear barra menu, dins de la llibreria TKinter (tk.) >> self.menuBar=tk.Menu(self) >> # creacio arxiu dins de la barra de menu >> self.fileMenu=tk.Menu(self.menuBar, tearoff=0) >> # crear commandes obrir, guardar i tancar, l'estat de >> # guardar esta desactivat mentre no s'obri una imatge >> self.fileMenu.add_command(label="Open", command=self.open) >> self.fileMenu.add_command(label="Save", command=self.save, >> state="disabled") self.fileMenu.add_command(label="Close", >> command=self.exit) >> # Afegim tot aixo la barra de menu en cascada >> self.menuBar.add_cascade(label="File", menu=self.fileMenu) >> # Crear menu de process >> self.processMenu=tk.Menu(self.menuBar, tearoff=0) >> # crear submenu de processs/filter >> self.processFilterSubMenu = tk.Menu(self.processMenu, >> tearoff=0) >> self.processFilterSubMenu.add_command(label="Gaussian >> Filter", command=self.gaussFilter, state="disabled") >> self.processFilterSubMenu.add_command(label="Median Filter", >> command=self.medianFilter, state="disabled") >> self.processMenu.add_cascade(label="Process/Filter", >> menu=self.processFilterSubMenu, underline=0) >> # crear submenu segmentacio >> self.segmentationSubMenu = tk.Menu(self.processMenu, >> tearoff=0) >> self.segmentationSubMenu.add_command(label="Watershed", >> command=self.watershed, state="disabled") >> self.segmentationSubMenu.add_command(label="Random walker", >> command=self.randomwalker, state="disabled") >> self.processMenu.add_cascade(label="Segmentation", >> menu=self.segmentationSubMenu, underline=0) >> # crear submenu edgeDetection >> self.edgeDetectionSubMenu = tk.Menu(self.processMenu, >> tearoff=0) >> self.edgeDetectionSubMenu.add_command(label="Sobel", >> command=self.sobel, state="disabled") >> self.edgeDetectionSubMenu.add_command(label="Laplacian", >> command=self.laplacian, state="disabled") >> self.edgeDetectionSubMenu.add_command(label="Canny", >> command=self.canny, state="disabled") >> self.processMenu.add_cascade(label="Edge Detection", >> menu=self.edgeDetectionSubMenu, underline=0) >> # crear submenu change colormap >> self.colorMapSubMenu = tk.Menu(self.processMenu, tearoff=0) >> self.colorMapSubMenu.add_command(label="None", >> command=self.none, state="disabled") >> self.colorMapSubMenu.add_command(label="Plasma", >> command=self.plasma, state="disabled") >> self.colorMapSubMenu.add_command(label="Inferno", >> command=self.inferno, state="disabled") >> self.colorMapSubMenu.add_command(label="Viridis", >> command=self.viridis, state="disabled") >> self.processMenu.add_cascade(label="Change Colormap", >> menu=self.colorMapSubMenu, underline=0) >> >> self.menuBar.add_cascade(label="Process", >> menu=self.processMenu) master.config(menu=self.menuBar) >> # No colorMap >> def none(self): targetTemp = cv2.imread(self.original_path) >> cv2.imwrite(self.target_path,targetTemp)# guarda imatge >> targetTemp i a la ruta de desti self.updateTargetImage() >> # Plasma colorMap >> def plasma(self): plt.clf()#esborra imatge targetTemp >> targetTemp = cv2.imread(self.original_path) # llegir ruta >> original (carpeta on es troba arxiu py) targetTemp = >> np.fliplr(targetTemp[:,:,0]) # gir esquerra a dreta imatge >> original, segons 3r valor matriu, varia tonalitat >> >> plasma = ListedColormap(colormaps._plasma_data, >> name='plasma') plt.axis('off')#desactiva eixos a la imatge >> plt.register_cmap(name='plasma', cmap=plasma) # registrar >> colormap nou i aplicar-lo imgplot = >> plt.imshow(targetTemp)#mostrar imatge allotjada a targetTemp >> imgplot.set_cmap(plasma)#aplicar colormap >> imgplot.figure.savefig(self.target_path)#guardar imatge com >> a figura a la ruta de desti >> >> self.updateTargetImage() #actualitzar la imatge (amb >> aplicacio del colormap) def viridis(self): plt.clf() >> #esborra imatge targetTemp targetTemp = >> cv2.imread(self.original_path) targetTemp = >> np.fliplr(targetTemp[:,:,0]) >> >> viridis = ListedColormap(colormaps._viridis_data, >> name='viridis') plt.axis('off') >> plt.register_cmap(name='viridis', cmap=viridis) imgplot = >> plt.imshow(targetTemp) imgplot.set_cmap(viridis) >> imgplot.figure.savefig(self.target_path) >> # update target screen >> self.updateTargetImage() def inferno(self): plt.clf() >> targetTemp = cv2.imread(self.original_path) targetTemp = >> np.fliplr(targetTemp[:,:,0]) >> >> inferno = ListedColormap(colormaps._inferno_data, >> name='inferno') plt.axis('off') >> plt.register_cmap(name='inferno', cmap=inferno) imgplot = >> plt.imshow(targetTemp) imgplot.set_cmap(inferno) >> imgplot.figure.savefig(self.target_path) >> self.updateTargetImage() >> >> # funcio per obrir arxius >> def open(self): >> # obrir arxiu des del quadre de dialeg >> self.original_path = >> tkFileDialog.askopenfilename(filetypes=[("Image >> Files","*.jpg;*.jpeg;*.png;*.gif")]) if >> self.original_path!="": # si es selecciona un arxiu, >> s'activen totes les comandes del menu >> self.fileMenu.entryconfig("Save", state="normal") >> self.processFilterSubMenu.entryconfig("Gaussian Filter", >> state="normal") >> self.processFilterSubMenu.entryconfig("Median Filter", >> state="normal") >> self.segmentationSubMenu.entryconfig("Watershed", >> state="normal") >> self.segmentationSubMenu.entryconfig("Random walker", >> state="normal") >> self.edgeDetectionSubMenu.entryconfig("Sobel", >> state="normal") >> self.edgeDetectionSubMenu.entryconfig("Laplacian", >> state="normal") >> self.edgeDetectionSubMenu.entryconfig("Canny", >> state="normal") self.colorMapSubMenu.entryconfig("None", >> state="normal") >> self.colorMapSubMenu.entryconfig("Plasma", state="normal") >> self.colorMapSubMenu.entryconfig("Inferno", state="normal") >> self.colorMapSubMenu.entryconfig("Viridis", state="normal") >> >> saveButton = tk.Button(self, text="Save", >> command=self.save) saveButton.grid(row=7, column=10) >> self.actual_name = self.original_path[self.original_pat- >> h.rfind("/"):self.original_path.rfind(".")] #creacio >> arxiu temporal de la imatge que hem obert >> self.target_path = self.original_path[0:self.original_p- >> ath.rfind(".")]+"imatge."+self.original_path[self.origi- >> nal_path.rfind(".")+1:] shutil.copy2(self.original_path, >> self.target_path) #copia l'arxiu de la ruta original >> #os.popen('attrib +h ' + self.target_path) >> self.originalImg = Image.open(self.original_path) #obrir >> imatge original self.originalImg.thumbnail(App.size, >> Image.ANTIALIAS) #thumbnail-> aplica mida imatge >> escalada a la finestra App.size originalImgCanvas = >> tk.Canvas(self, width= 500, height=380) # aplica la mida >> especificada a la imatge original >> originalImgCanvas.grid(row=3, column=2, columnspan=6) # >> la posiciona dins del grid a la fila 3 i la columna 2, >> abasta 6 columnes tkOriginalImg = >> ImageTk.PhotoImage(self.originalImg) # mostra la imatge >> original self.originalImg.image = tkOriginalImg # >> associa la imatge original a la imatge dins la llibreria >> tkinter originalImgCanvas.create_image(100,100,image=tk- >> OriginalImg, anchor=tk.NW, tags="IMG") # crea la imatge >> anterior amb amplada nord-oest dins del widget de Canvas >> que disposa d'estructures grafiques >> >> self.targetImg = Image.open(self.target_path)# obrir >> imatge a procesar self.targetImg.thumbnail(App.size, >> Image.ANTIALIAS) #thumbnail-> aplica mida imatge >> escalada a la finestra App.size self.targetImgCanvas = >> tk.Canvas(self, width= 500, height=380) >> self.targetImgCanvas.grid(row=3, column=8, columnspan=6) >> self.tkTargetImg = ImageTk.PhotoImage(self.targetImg) >> self.targetImg.image = self.tkTargetImg self.targetImgC- >> anvas.create_image(100,100,image=self.tkTargetImg, >> anchor=tk.NW) >> # source histogram >> #originalCvImg = cv2.imread(self.original_path) >> #plt.figure(figsize=(2,2)) #color = ('b','g','r') #for >> channel,col in enumerate(color): >> # histr = cv2.calcHist([originalCvImg],[channel],Non- >> # e,[256],[0,256]) plt.plot(histr,color = col) >> # plt.xlim([0,256]) if( col == 'b'): >> # originalB=plt.imshow(histr).figure elif( col == >> # 'g'): originalG=plt.imshow(histr).figure else: >> # originalR=plt.imshow(histr).figure >> #self.NewCanvas = tk.Canvas(self, width= 30, height=50) >> #self.canvas = FigureCanvasTkAgg(originalR, >> master=self.NewCanvas) #self.NewCanvas.grid(row=4, >> column=0) #self.canvas.show() >> #self.canvas.get_tk_widget().grid(row=0, column=0) >> >> # target histogram >> #targetCvImg = cv2.imread(self.target_path) >> #plt.figure(figsize=(2,2)) #color = ('b','g','r') #for >> channel,col in enumerate(color): >> # histr = cv2.calcHist([targetCvImg],[channel],None,[- >> # 256],[0,256]) plt.plot(histr,color = col) >> # plt.xlim([0,256]) if( col == 'b'): >> # targetB=plt.imshow(histr).figure elif( col == 'g'): >> # targetG=plt.imshow(histr).figure else: >> # targetR=plt.imshow(histr).figure >> #self.NewTargetCanvas = tk.Canvas(self, width= 30, >> height=50) #self.canvasTarget = >> FigureCanvasTkAgg(targetR, master=self.NewTargetCanvas) >> #self.NewTargetCanvas.grid(row=4, column=1) >> #self.canvasTarget.show() >> #self.canvasTarget.get_tk_widget().grid(row=0, column=0) >> # to have only odd value in scale >> def fix(self, xy, n): #no entenc que fa aquesta funcio! >> global past n = int(n) if not n % 2: if xy=="sx": >> scale = self.gaussianSigmaXScale elif xy=="sy": >> scale = self.gaussianSigmaYScale elif xy=="median": >> scale = self.medianSizeScale else: scale = >> self.kernelSizeScale scale.set(n+1 if n > self.past else >> n-1) self.past = scale.get() >> # funcio per guardar imatges procesades >> def save(self): if tkMessageBox.askokcancel("Save", "Do you >> want to save?"): os.remove(self.original_path)# esborra >> arxiu original de la ruta de desti os.popen('attrib -h -s >> ' + self.target_path)# obre arxiu target de >> # la ruta de desti, correspon imatge a processar >> os.rename(self.target_path, self.original_path) >> #renombra >> # la imatge original i la imatge a processar >> shutil.copy2(self.original_path, self.target_path) >> #copia l'arxiu >> # de la ruta original i tambe la imatge a processar >> # (target) >> os.popen('attrib +h ' + self.target_path) >> # sortir del GUI >> def exit(self): if tkMessageBox.askokcancel("Quit", "Do you >> want to quit?"): try: >> # esborrar arxiu temporal >> os.remove(self.target_path) finally: >> self.master.destroy() >> >> def updateTargetImage(self): # funcio per actualitzar les >> diferents accio a la imatge a procesar self.targetImg = >> Image.open(self.target_path) # obre la imatge a procesar, en la >> ruta on es troba self.targetImg.thumbnail(App.size, >> Image.ANTIALIAS) #thumbnail-> aplica mida imatge escalada a la >> finestra App.size self.tkTargetImg = >> ImageTk.PhotoImage(self.targetImg)# mostra la imatge a procesar >> self.targetImg.image = self.tkTargetImg # associa la imatge a >> procesar a la imatge dins la llibreria Tkinter (que allotja tot >> el referent al GUI) self.targetImgCanvas.create_image(5,5,im- >> age=self.tkTargetImg, anchor=tk.NW, tags="IMG") # crea la >> #imatge a procesar quan se li aplica algun canvi (colormap, >> filtres, etc) targetCvImg = cv2.imread(self.target_path) # >> llegeix la imatge de la ruta de desti >> plt.figure(figsize=(4,4)) # crea una figura per allotjar >> histograma color = ('b','g','r') for i,col in >> enumerate(color): histr = >> cv2.calcHist([targetCvImg],[i],None,[256],[0,256]) >> plt.plot(histr,color = col) plt.xlim([0,256]) >> targetR=plt.imshow(histr).figure self.NewTargetCanvas = >> tk.Canvas(self, width= 30, height=50) #crea un nou >> # Canvas de la mida indicada >> self.canvasTarget = FigureCanvasTkAgg(targetR, >> master=self.NewTargetCanvas) #crea una figura dins del >> Canvas on s'allotja el histograma >> self.NewTargetCanvas.grid(row=4, column=1)# defineix posicio >> del grid dins el >> # Canvas >> self.canvasTarget.show() # mostra el canvas >> self.canvasTarget.get_tk_widget().grid(row=0, column=0) >> >> def gaussFilter(self): targetTemp = >> sk.io.imread(self.original_path)# llegir imatge targetTemp a la >> ruta original targetTemp = sk.filters.gaussian(targetTemp, >> sigma=0, mode='reflect', cval=0, multichannel=False) >> #targetTemp = cv2.GaussianBlur(targetTemp,(sigmaX, sigmaY), >> 0)#aplicar filtre cv2.imwrite(self.target_path,targetTemp) >> # actualitzar imatge Target >> self.updateTargetImage() >> >> My code is so long (There are another functions or filters (Sobel, >> Canny, etc...) I paste the finally: >> >> def on_closing(app, root): if tkMessageBox.askokcancel("Quit", >> "Do you want to quit?"): try: >> os.remove(app.target_path) except: print("error") >> finally: root.destroy() >> # inicialitzar llibreria Tkinter per creacio widget >> root=tk.Tk() app = App(root) >> # renderitzar GUI, to accept events >> root.protocol("WM_DELETE_WINDOW", lambda: on_closing(app, root)) >> app.mainloop() >> >> >> I attached image about my problema >> >> I need help, it's so urgent! >> >> Thanks in advance. >> >> Xavi. >> _______________________________________________ >> scikit-image mailing list scikit-image@python.org >> https://mail.python.org/mailman/listinfo/scikit-image >> > _________________________________________________ > scikit-image mailing list > scikit-image@python.org > https://mail.python.org/mailman/listinfo/scikit-image
_______________________________________________ scikit-image mailing list scikit-image@python.org https://mail.python.org/mailman/listinfo/scikit-image