In article < XXXX@XXXXX.COM >,
That's an algorithm, which could be implemented in most any language.
It is not a C specific question, so you should ask in an
algorithms newsgroup, or possibly a graphics newsgroup.
The "most efficient way" is going to depend upon the size of the images,
upon whether you assume constant density, and upon the complexity
of the outlier segments (e.g., simplier if you know they are
strictly convext); also upon how you determine whether a segment
is connected or not (if it only touches on a single diagnonal, is
The "most efficient way" may also depend upon architecture details
of the computer system being used to solve the problem. For example,
if the entire image easily fits within primary cache, then the efficient
algorithms available are going to differ from situations in which the
images are large and all of the data for one row (or column) is
consequative in memory, and are going to differ again from situations
in which the images are large but are stored as "tiles" in memory.
Thus the "most efficient way" is going to depend greatly on the details
of the assumptions you can make about your images and their internal
representation and about the characteristics of your computer system.
Finding "the most efficient way" could potentially be a matter of weeks
or months of research.
You'd probably have more success if instead you asked about
"reasonably efficient ways" instead of "the most efficient way".
All is vanity. -- Ecclesiastes