AForge.NET

  :: AForge.NET Framework :: Articles :: Forums ::

Dashed line (unique colour) best technique to join gaps

The forum is to discuss topics related to different areas of image processing and computer vision.

Dashed line (unique colour) best technique to join gaps

Postby JetC » Tue Sep 05, 2017 10:29 pm

Hi,
I have images which have a dashed (tightly) line and am looking for the simplest solution for "joining" the dashes. I understand there are a few options available which could achieve this.
The pixels which are dashed are a unique (ff0000) colour (do not appear anywhere else on the image), some around the edge of the dashes are slightly different but that does not matter as the dashes are mainly made up of pixels with the unique colour.
Unfortunately it is not acceptable to expand all pixels around these pixels to effectively join them so the line is no longer dashed. This would make the new joined line very thick as the gaps between the dashes are 8 or 9 pixels wide. As the end of the dashed lines are 6 pixels wide the resultant joined line could be 24 pixels wide.
However, I wonder if there is a technique which could be implemented to achieve the result shown on the attached image which shows before and after? The "neatness" of the line is not important but if the dashes could be "joined" by changing the colour of the pixels in between the coloured (ff0000) ones that would be great. Aiming to have a complete line of pixels all with the same colour which is at least 2 or 3 pixels wide.

Thank you.
Graham
Attachments
Before_And_After.png
Before_And_After.png (43.69 KiB) Viewed 123 times
JetC
 
Posts: 2
Joined: Tue Sep 05, 2017 9:48 pm

Re: Dashed line (unique colour) best technique to join gaps

Postby andrew.kirillov » Wed Sep 06, 2017 7:21 am

Hello,

Usually line detection is done using Line Hough Transformation. But it is no a simplest tool to use. It does not give a list of all individual lines starting at (X1, Y1) and finishing at (X2, Y2).

Since you say lines of your interest have unique color, you can try isolating them using some color filters. Then using blob counter you can find each individual line. It gives you object's bounding rectangle and center of gravity. Once you have it, you can try going through the list of all found objects/lines and connect each with the closest one.
With best regards,
Andrew


Interested in supporting AForge.NET Framework?
User avatar
andrew.kirillov
Site Admin, AForge.NET Developer
 
Posts: 3218
Joined: Fri Jan 23, 2009 9:12 am
Location: UK

Re: Dashed line (unique colour) best technique to join gaps

Postby JetC » Thu Sep 07, 2017 10:52 pm

Thank you very much for your guidance Andrew!

Using the samples included in the framework installation directory I achieved the following results:
Applied the ColorFiltering Class to isolate the required colour:
http://www.aforgenet.com/framework/docs ... d4b927.htm
See attached file:ColourFilter.png
ColourFilter.png
ColourFilter.png (15.48 KiB) Viewed 104 times

Then the Blobs Explorer example (C:\Program Files (x86)\AForge.NET\Framework\Samples\Imaging\BlobsExplorer)
which effectively "selects" the remaining dashes. See attached file: Blobs.png
Blobs.png
Blobs.png (11.5 KiB) Viewed 104 times


I am blown away by the power and ease of use of this amazing framework.

I can see multiple ways of joining the dashes. Now I just need to improve my skills so I can make it happen.

Will report back so others can benefit once I have a solution.
JetC
 
Posts: 2
Joined: Tue Sep 05, 2017 9:48 pm

Re: Dashed line (unique colour) best technique to join gaps

Postby andrew.kirillov » Fri Sep 08, 2017 7:07 am

You seem to be on the right track. So if you've used Blob Counter, then you should have CoG (center of gravity) for each object, which is X/Y of objects center. Using standard .NET's Graphics class you can draw lines on images with whatever color/thickness you need. Hope it helps.
With best regards,
Andrew


Interested in supporting AForge.NET Framework?
User avatar
andrew.kirillov
Site Admin, AForge.NET Developer
 
Posts: 3218
Joined: Fri Jan 23, 2009 9:12 am
Location: UK




Return to Image Processing and Computer Vision