Vicky Liau
Vicky Liau

Reputation: 617

implement image segmentation with python generator

Following the last question: read big image file as an array in python

Due to the memory limitation of my laptop, I would like to implement image segmentation algorithm with python generator which can read every pixel at a time, rather than the whole image.

My laptop is Window 7 (64 bit OS) with 4G ram and Intel(R) Core (TM) i7-2860 QM CPU, and the images I am processing are over 2G. The algorithm I want to apply is watershed segmentation: http://scikits-image.org/docs/dev/auto_examples/plot_watershed.html

The only similar example I can find is http://vkedco.blogspot.com/2012/04/rgb-to-gray-level-to-binary-python.html, but what I need is not just converting a pixel value at a time. I need to consider the relations among near pixels. How can I do?

Any idea or hint for me? Thanks in advance!

Upvotes: 1

Views: 768

Answers (1)

tkerwin
tkerwin

Reputation: 9759

Since the RGB to graylevel conversion operation is purely local, a streaming approach is trivial; the position of the pixels is irrelevant. Watershed is a global operation. One pixel can change the output dramatically. You have several options:

  1. Write an implementation of Watershed that works on tiles and iterates on many passes through the image. This sounds difficult to me.
  2. Use a local method to segment (i.e. thresholding).
  3. Get a computer with more RAM. RAM is cheap and you can stick tons of it into a desktop system.

Upvotes: 4

Related Questions