1

I am looking for a C library that given an image of size x, it will split the image into multiple images so that I can send every subimage to a dedicated CPU to do detect segments on it using region growing or what ever.

ob_dev
  • 2,756
  • 1
  • 18
  • 25
  • 2
    This depends heavily on your imaging library and the image representation. In most cases, it is a trivial task: Adjust the base pointer & stride for the image data. – thiton Feb 12 '13 at 14:30
  • If you want to do it easy and quickly, you'd better do it yourself. If not — use libraries, for example, ImageMagick. – Eddy_Em Feb 12 '13 at 14:51
  • Just beware that if your segments are some kinds of feature of the image that needs neighborhood information you'll have boundary issues and consequent artifacts. – SteakOverflow Feb 21 '13 at 11:39

4 Answers4

4

Do you really want to split the image?

  1. If you are using multi-core CPUs, it's better to load the image once, then run processing threads on it (I assume, the processing only reads the image) with x,y,width,height parameters.

  2. If you have more hosts, there are a dispatcher, and it is doing several operations with the image: decompress, split, compress parts, transmit parts. I think, the processing hosts are on the same local network. If you can send the image to this local network as broadcast, I mean that all the hosts receives the image at once, it would be a performance gain: the displathcer has not to split and re-send parts, processing tasks should just pick the appropiate part of the whole image received (x,y,width,height). I don't know what image format are you using, but I'm pretty sure that you don't have to decompress the whole image, at least vertically you should skip unwanted regions. (You should split image to full-width regions avoid decompressing unneeded areas.)

ern0
  • 3,062
  • 23
  • 35
1

Merging the results from the separate segmentation outputs will be the hard part. What if you happen to split right through a segment? You'd get a segment from each split image, and you'd have to merge them together. There will be uncertain cases, so you'll have to pick a metric to decide when to merge two regions.

If this is a concern, you might want to try out the Seam Carving algorithm to generate splits that aren't likely to intersect a region edge. Photoshop's Content-Aware Resize tool uses seam carving to find horizontal and vertical paths in an image that are not visually important.

japreiss
  • 10,583
  • 2
  • 31
  • 76
1

As pointed by japresis merging the resulting segmentation results may be your hardest part. If you are using graph-cut based image segmentation algorithm, you may augment your code with this approach that provides a principled way for performing parallel operations and combine them in an optimal way.

Community
  • 1
  • 1
Shai
  • 93,148
  • 34
  • 197
  • 325
1

While agreeing with Shai and japreiss, and underlying that since your goal is image segmentation you'll have boundary issues (because you need neighborhood information), for the image manipulation part I'd suggest something like

libpng: http://www.libpng.org/pub/png/libpng.html

And take a look to these StackOverflow questions:

  1. How to encode PNG to buffer using libpng?
  2. Using libpng to "split" an image into segments (this isn't properly answered yet)

When you have your buffer filled with the image values, reading and writing portions of it should not be tricky at all.

Community
  • 1
  • 1
SteakOverflow
  • 4,517
  • 1
  • 30
  • 49