Extract ROI to python variable

43 views
Skip to first unread message

G M

unread,
May 13, 2016, 4:04:52 AM5/13/16
to guidata/guiqwt
Hi all,
I have embeded a 2d array viewer as a method (viewer) of my class so when I need to plot 2d array data of an instsance of the class let's say "a" I can call a.viewer(), I would like to be able to extract a ROI (sub matrix)  to save in a python variable inside my class e.g. a.ROI  instead to save the ROI as .npy and then reopen it with np.load. Is there any way to do it ?

Thanks for your help!

Best regards,
Giacomo


 
def viewer(self):
       
#Based on PythonQwt https://pypi.python.org/pypi/guiqwt
       
from guiqwt.plot import ImageDialog
       
from guiqwt.builder import make
       
       
def create_window():
            win
= ImageDialog(edit=True, toolbar=True, wintitle=self.name,
                      options
=dict(show_contrast=True,show_xsection=True, show_ysection=True, xlabel='stage res.= %s mm x' %(self.resolution), xunit='mm', ylabel="y",yunit='mm',zlabel='Distance',zunit='mm',
                                   show_itemlist
=True))
            win
.resize(800, 600)
           
return win
       


       
import guidata
        _app
= guidata.qapplication()
       
# --
        win
= create_window()
        image2
= make.image(a.array, title="Data",xdata=[0,self.array.shape[1]*self.resolution],ydata=[0,self.array.shape[0]*self.resolution],interpolation="nearest")
        plot
= win.get_plot()
        plot
.add_item(image2, z=1)
        win
.exec_()



    
Reply all
Reply to author
Forward
0 new messages