0

I need a way to iterate quickly through image files and ask for user input at each image. This is for the development of a binary classification training set. Hopefully I will import the images as pims frames such as

frames = pims.ImageSequence("*.jpg",as_grey=True)

Then maybe I can load all of the image files in some kind of sequence with maybe some kind of structure along the lines of (obviously this won't work):

images = [plt.imshow(f) for f in frames]

So that I can do something along the lines of:

classification = []
for i in images: 
    magic_function_which_plots_image_without_a_delay(i)
    value = input()
    if value==1: 
        classification.append(True)
    else: 
        classification.append(False)

So I can have an array of True and False values, one associated with each image. If I do this some thousands of times I hope to have a training set for my binary classification problem. Does anyone know how to view images quickly? Any help is very much appreciated !!

kevinkayaks
  • 2,636
  • 1
  • 14
  • 30
  • 1
    [`cv2.imshow`](http://docs.opencv.org/2.4/modules/highgui/doc/user_interface.html#imshow), [`cv2.waitKey`](http://docs.opencv.org/2.4/modules/highgui/doc/user_interface.html#waitkey). That should be plenty fast for something that needs user input after every frame. From a brief look at `pims`, it seems it loads on demand -- I can't see why that should be an issue in this scenario, but if you measure it and find it slow, just put the image loading into another thread and pre-buffer. – Dan Mašek May 30 '17 at 23:38
  • @DanMašek I agree this should be sufficient for the purpose I mentioned, but I should have mentioned another-- I would like to scroll through images in python the way I can with a program like streampix. I have 190fps videos rendered into collections of images and would like to be able to get a feel for what is happening in a 10s period or so without leaving my tasks in a jupyter notebook. It might be optimistic. – kevinkayaks May 31 '17 at 01:04
  • Oh, so this is in jupyter? You should mention that. In that case using the OpenCV display functions is not a good idea -- it may kinda work if you run the server on the same machine as the client. I haven't tried this, but perhaps you could render using [this IPython API](https://ipython.org/ipython-doc/3/api/generated/IPython.display.html#IPython.display.Image)? | 190 fps is quite fast -- most monitors are a lot slower. To show it in jupyter (excluding user feedback per frame -- that's half hour for the 1900 frames if you take second per image)... make it a video and show that. – Dan Mašek May 31 '17 at 01:13
  • ... related to the last point: https://stackoverflow.com/questions/18019477/how-can-i-play-a-local-video-in-my-ipython-notebook | Or maybe you can render mosaics of groups of downsized frames? | Maybe do the human processing client side, and export results as CSV or JSON to your jupyter project? – Dan Mašek May 31 '17 at 01:14

0 Answers0