1

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!

1
  • 3
    ISTM you might as well reduce the image size (by which I mean downsample the pixel count or the palette, not clipping) so that it's small enough to work with. If the segmentation is robust enough to be reliable it'll work as well with a 200M image anyway. Commented Jul 27, 2012 at 14:34

1 Answer 1

4

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.
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.