With matplotlib you can have interaction with a plotted image for instance for annotation. You then get after the interaction some data that you usually like to save. I would like to incorporate that all in a function, but I don't know how to do this. The spectral module illustrates my problem, but I encountered this before.
Here is some code:
import spectral as spy
class Annotator:
def __init__(self, filename):
self.filename = filename
self.classes = list(zip(range(5), ['unknown','background','tape','healthy','infected']))
def img(self):
img=spy.open_image(self.filename)
return img
def viewer(self):
img = self.img()
print(self.classes)
viewer = spy.imshow(img)
annotation = viewer.classes
return annotation
If I call an Annotator An=Annotator(some data file)
, and then call the viewer and annotate
results = An.viewer
then python parses right away to the end, and gives as results an empty none type object. I would like the code to break, such that I can get the annotation and save it in the same function call.
So my question is, how do I do that?