AForge.NET

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

BlobCounter with monochrome image.

Forum to discuss AForge.NET Framework, its features, API, how-tos, etc.

BlobCounter with monochrome image.

Postby brown11188 » Wed Feb 22, 2017 3:18 am

I'm using class BlobCounter and it works very well, but seems to it just work with BLACK background image. So assume I have a blue monochrome image, do we have any way to convert it into the black and white image that we can use BlobCounter to detect blob.

Note: for now I do it with two step:
- Firstly, I convert it into Grayscale image.
- Secondly, I use threshold to convert it into black-white image

Thank you.

This is my example monochrome image:

Image

https://drive.google.com/file/d/0ByI5I_ ... NwbkE/view
brown11188
 
Posts: 7
Joined: Wed Feb 22, 2017 2:38 am

Re: BlobCounter with monochrome image.

Postby andrew.kirillov » Wed Feb 22, 2017 8:05 am

Hello,

You may try using BackgroundThreshold property. It may not always help however - depends on your image.

In general, your approach is right - image must be pre-processed in one way or another to make it ready for blobs searching.
With best regards,
Andrew


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

Re: BlobCounter with monochrome image.

Postby brown11188 » Wed Feb 22, 2017 9:10 am

Yes but sometimes when I convert from color image to grayscale image, it give me the image with all pixel is higher than 128 (I know we will compare each pixel to 128 than convert it to pure white or pure black, but all that blobs are also higher than 128). So could you give me the solution for this? I think it's also the same with finding a background of an image and convert it to black :D

Anyway, I cannot find BackgroundThreshold in the source code.

Thanks for helping.
brown11188
 
Posts: 7
Joined: Wed Feb 22, 2017 2:38 am

Re: BlobCounter with monochrome image.

Postby andrew.kirillov » Wed Feb 22, 2017 10:33 am

brown11188 wrote:it give me the image with all pixel is higher than 128 (I know we will compare each pixel to 128 than convert it to pure white or pure black, but all that blobs are also higher than 128). So could you give me the solution for this?

You can choose different threshold then. It does not have to be 128.

brown11188 wrote:Anyway, I cannot find BackgroundThreshold in the source code.

Maybe you have wrong code or its version.

Why do you need blue background at all, if it causes you so much pain? Also you can try using some color filters to remove blue background and make it black.
With best regards,
Andrew


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

Re: BlobCounter with monochrome image.

Postby brown11188 » Thu Feb 23, 2017 1:51 am

My input image will have random monochrome color so blue is just an example :(

You can choose different threshold then. It does not have to be 128.


Yes I know but do we have a class that works for all case, I mean it can detect background and object, then convert background to black and object (blob) to white.
brown11188
 
Posts: 7
Joined: Wed Feb 22, 2017 2:38 am

Re: BlobCounter with monochrome image.

Postby brown11188 » Thu Feb 23, 2017 2:14 am

Hey, maybe I found the way. I did calculate the average of all the pixel. Then compare each one with that number. Just test 3, 4 images but it gave me the correct result.

But I got a new issue here. That blob counter just can detect when image have BLACK background and WHITE object, for WHITE background and BLACK image, it can't.
brown11188
 
Posts: 7
Joined: Wed Feb 22, 2017 2:38 am

Re: BlobCounter with monochrome image.

Postby andrew.kirillov » Thu Feb 23, 2017 8:04 am

brown11188 wrote:But I got a new issue here. That blob counter just can detect when image have BLACK background and WHITE object, for WHITE background and BLACK image, it can't.

Of course. It is obvious it will not find black objects on white background.
With best regards,
Andrew


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

Re: BlobCounter with monochrome image.

Postby brown11188 » Wed Mar 01, 2017 3:22 am

Hi again.

Do we have any ways to use Aforge in UWP. :( I tried but there are no luck.
brown11188
 
Posts: 7
Joined: Wed Feb 22, 2017 2:38 am




Return to AForge.NET Framework