Being more specific would depend on what your bitmap looked like and how
you wanted to segment it before vectorizing.

I assume you would want to do this in a purely OSG/OpenGL/GLSL environment
without going to OpenCL or CUDA. So, this is defined in terms of multiple
OSG-like rendering passes, each with a single simple operation.

>From my imagination:

1. Run a later pass on the RTT rasterizing a fullscreen quad and using the
RTT output texture as an input. Here, you perform any downsampling and
per-pixel computation necessary to process the input values into a pure
binary segmentation of 0 or 1 values. Optimally, at this point you could
also compute the XY screen space bounding box of the 0 and 1 regions to
restrict the regions the later passes run on.

2. Run a second pass on a screen-sized quad which uses the output of the
first pass as an input texture (nearest neighbor sampling mode) and has a
fragment shader which examines the corresponding pixel in the input
texture, comparing it to eight of its neighbors. If the center pixel
differs from any of the eight neighbors, it could be an 'edge' pixel, and
the orientation of a short edge segment at this location should be
determined based on the 8 surrounding pixels, and recorded in a Transform
Feedback output buffer. Each output segment will represent a one-pixel long
fraction of the edge boundary between 1 and 0 regions. You'll probably need
to handle edges that reach the sides of the screen by closing the loop
around the screen edge somehow, depending on whether you need a closed line
loop or an open line segment as the final product.

3. Run a third pass (this might be easier with looping constructs on the
CPU side, but maybe the GPU can do it still) on the single-pixel-long edge
segments to assemble the fragments, in order, to complete a line segment.
This will be output as another Transform Feedback buffer.

4. Optionally, run a 4th pass using the line string from the 3rd pass, to
optimize/simplify the segments based on merging them together using length
and turning radius rules to coalesce small features or long straight
1-pixel segments into one longer, multi-pixel-long segment.

Extract the final line string from the transform feedback buffer into CPU
space for use.

I've been trying to find you an example, but my search terms are colliding
with other synonymous words like "tracing" and "vectorizing" and turning up
the wrong info.


On Fri, Jul 5, 2019 at 4:03 PM Trajce Nikolov NICK <
trajce.nikolov.n...@gmail.com> wrote:

> Thanks Chris!
>
> any links? I am interested
>
> On Fri, Jul 5, 2019 at 2:43 PM Chris Hanson <xe...@alphapixel.com> wrote:
>
>> Sorry, Nick, I missed this query of yours!
>>
>> I could have given you some suggestions. If your OpenCV solution ever is
>> inadequate, you could probably make something really fast in GPU using
>> transform feedback. Could even do simplification in-GPU too.
>>
>> On Fri, Jul 5, 2019 at 2:11 PM Trajce Nikolov NICK <
>> trajce.nikolov.n...@gmail.com> wrote:
>>
>>> Hi Community,
>>>
>>> just if someone else will need this:
>>>
>>> I was able to work it with OpenCV. But if you really want to exercise it
>>> here is a nice link with different algorithms explained in big detail:
>>> https://www.ncbi.nlm.nih.gov/pmc/articles/PMC4813928/
>>>
>>> Cheers,
>>> Nick
>>>
>>> On Tue, Jul 2, 2019 at 1:03 PM Trajce Nikolov NICK <
>>> trajce.nikolov.n...@gmail.com> wrote:
>>>
>>>> Hi Community,
>>>>
>>>> This is a bit more CG question rather then OSG related, but I think
>>>> there are lots of CG folks in this community so I dare to ask
>>>>
>>>> I am after processing of a rendering outline of a scene (which is a
>>>> bitmap as a result of RTT in OSG) and then having this outline as an array
>>>> of 2D coordinates. And preferable close to real time. Anyone with some
>>>> suggestions?
>>>>
>>>> Thanks a bunch as always! Meanwhile I am googling this one
>>>>
>>>> Cheers,
>>>> Nick
>>>>
>>>> --
>>>> trajce nikolov nick
>>>>
>>>
>>>
>>> --
>>> trajce nikolov nick
>>> _______________________________________________
>>> osg-users mailing list
>>> osg-users@lists.openscenegraph.org
>>> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
>>>
>>
>>
>> --
>> Chris 'Xenon' Hanson, omo sanza lettere. xe...@alphapixel.com
>> http://www.alphapixel.com/
>> Training • Consulting • Contracting
>> 3D • Scene Graphs (Open Scene Graph/OSG) • OpenGL 2 • OpenGL 3 • OpenGL 4
>> • GLSL • OpenGL ES 1 • OpenGL ES 2 • OpenCL
>> Legal/IP • Forensics • Imaging • UAVs • GIS • GPS •
>> osgEarth • Terrain • Telemetry • Cryptography • LIDAR • Embedded • Mobile •
>> iPhone/iPad/iOS • Android
>> @alphapixel <https://twitter.com/alphapixel> facebook.com/alphapixel (775)
>> 623-PIXL [7495]
>> _______________________________________________
>> osg-users mailing list
>> osg-users@lists.openscenegraph.org
>> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
>>
>
>
> --
> trajce nikolov nick
> _______________________________________________
> osg-users mailing list
> osg-users@lists.openscenegraph.org
> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
>


-- 
Chris 'Xenon' Hanson, omo sanza lettere. xe...@alphapixel.com
http://www.alphapixel.com/
Training • Consulting • Contracting
3D • Scene Graphs (Open Scene Graph/OSG) • OpenGL 2 • OpenGL 3 • OpenGL 4 •
GLSL • OpenGL ES 1 • OpenGL ES 2 • OpenCL
Legal/IP • Forensics • Imaging • UAVs • GIS • GPS •
osgEarth • Terrain • Telemetry • Cryptography • LIDAR • Embedded • Mobile •
iPhone/iPad/iOS • Android
@alphapixel <https://twitter.com/alphapixel> facebook.com/alphapixel (775)
623-PIXL [7495]
_______________________________________________
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Reply via email to