AForge.NET

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

Finding horizontal bars

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

Finding horizontal bars

Postby JerryNixon » Mon Sep 16, 2019 12:33 am

Hi, my goal is to locate the horizontal bars in the attached image. I want to use their location, horizontal length, and vertical thickness to infer their part of the label. That's the goal.

I started by using BlobCounter since they look like rectangles to me. But this is unreliable. It tends to miss them. Perhaps the text is too close.

I thought about the horizontal edge and somehow using that to identify the horizontal bars. Not sure that's a good approach or not, but I'm a little stuck. Not quite sure how.

Thank you for any help you can offer.

Jerry
Attachments
Aw.Nutrition.Sample2.jpg
Aw.Nutrition.Sample2.jpg (237.15 KiB) Viewed 220 times
JerryNixon
 
Posts: 5
Joined: Sun Sep 15, 2019 10:24 pm

Re: Finding horizontal bars

Postby andrew.kirillov » Mon Sep 16, 2019 11:42 am

Hello,

May not be perfect but here is what I got quickly in IPLab. Just as a starting idea ...

Steps are:
1) Grayscaling
2) Edge detection (Homogenity)
3) Thresholding
4) Morphology Hit-and-Miss, used 3x3 kernel (0,0,0,1,1,1,-1,-1,-1) to detect horizontal elements.
5) Blob filtering by size to remove short line.

Image 5.png
Image 5.png (1.96 KiB) Viewed 207 times
With best regards,
Andrew


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

Re: Finding horizontal bars

Postby JerryNixon » Mon Sep 16, 2019 2:59 pm

This is very nice. I will need to install IPLab and see what you mean. If you have any code samples, I eagerly welcome them, esp. #4. /Jerry
JerryNixon
 
Posts: 5
Joined: Sun Sep 15, 2019 10:24 pm

Re: Finding horizontal bars

Postby N3rd007 » Wed Sep 18, 2019 9:46 pm

Hello Andrew,
I am working with Jerry on a project, and I am trying to reproduce your results using your too IPLabs. I am struggling to figure out what settings you used for two of the steps and was wondering if you could share your thoughts.

In the steps thresholding and "blob filtering by size to remove short line" what settings did you use to get such great results?

Thanks for any thoughts!

Best regards,
Travis
N3rd007
 
Posts: 1
Joined: Wed Sep 18, 2019 9:42 pm

Re: Finding horizontal bars

Postby andrew.kirillov » Thu Sep 19, 2019 7:06 am

Hello,

There is preview area, you can always play with the settings.

For thresholding I used something like 64. For blob filtering I think I set min width to ~40 and min height kept as is (1).
With best regards,
Andrew


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




Return to Image Processing and Computer Vision