Binary region analysis and labeling - blobs - connected components

classic Classic list List threaded Threaded
9 messages Options
Reply | Threaded
Open this post in threaded view
|

Binary region analysis and labeling - blobs - connected components

dgrossman2
I have just uploaded BlobAnalysis.zip to the Yahoo Groups OpenCV files
section. It
contains a set of programs that I wrote for binary region analysis and
labeling.  
 
Binary region analysis (also known as connected component analysis) takes a
binary
image as input and generates a list of all connected regions (blobs). For
each region,
it provides the color, parent, area, perimeter, centroid, 2nd moments, and
bounding
box. Parameters allow the user to specify the color of the border, the
minimum blob
area below which the blob is merged with its parent, and the ROI.
 
Labeling (which is optional) generates a new gray level image in which each
blob is
represented by pixels all of which have that region number, from 0 to 255.
Any regions
beyond 255 are also assigned 255. However, this limitation does not affect
the binary
region analysis ,  which can cope with thousands of regions.
 
The programs I have provided include a file that embodies the two algorithms
and a file
that can be used to demo its operation on a variety of test images. I also
included a
large number of test images that I received from many OpenCV users over the
past
five years. I have used these images to do quality assurance of the region
analysis
process. The labeling algorithm has not been as extensively tested, but
since it is
simple and it piggy-backs on region analysis, it requires little testing.
 
Instructions for use: Unzip the file into the directory of your choice. Then
create an
Images subdirectory, and move all the images into that subdirectory.
 
The algorithms have #define statements that can be used to configure them
either for
C or C++. They have been optimized to be fast, making them suitable for
images
with a large number of regions. One of the test images has 257 disjoint
regions.
 
Also uploaded is a short explanation of the user interface. This
documentation is in
the form of an html page similar to those in the OpenCV manual.
 
Finally, there is a documentation file in MS Word that explains binary
region analysis.
It discusses the specifics of the implementation, including some of its
limitations.
 
As usual with OpenCV, I am putting this code in the public domain. Anyone is
free to
use it however they wish. About 20 people are already using earlier versions
of this
software, and in fact blobslib was based on an earlier version of my code.
At least
one of these earlier uses was embedded in a manufacturing tool that has run
in
production successfully for over a year.
 
- Dave Grossman
 
 
 


[Non-text portions of this message have been removed]

Reply | Threaded
Open this post in threaded view
|

Re: Binary region analysis and labeling - blobs - connected components

roguex360
I have downloaded your Blob Analysis code and tried to make it run (in
Visual Studio 2008 with OpenCV 1.0 on 64 Bit Vista) but I keep getting
errors.  

The main one that keeps popping up is:

"Windows has triggered a breakpoint in Blob Analysis Demo.exe.

This may be due to a corruption of the heap, which indicates a bug in
Blob Analysis Demo.exe or any of the DLLs it has loaded.

This may also be due to the user pressing F12 while Blob Analysis
Demo.exe has focus.

The output window may have more diagnostic information."

I do not understand what this means, and each time it pops up, it
opens the file "free.c" within Visual Studio.

This happens when I try it for any of the test images you supply, and
I have been unable to make the supplied Demo work successfully.  

Please could you help me work out why it's not working?

I really need to be able to identify and label regions (blobs) from
binary images, and your code here seems to be the simplest way to do
this.  

I have tried to install cvBlobsLib and cvBlob, but I can't understand
the instructions for either, so can't make them work.

Please help, thanks,
--rogue--


--- In [hidden email], "Dave Grossman" <dgrossman2@...> wrote:
>
> I have just uploaded BlobAnalysis.zip to the Yahoo Groups OpenCV files
> section. It
> contains a set of programs that I wrote for binary region analysis and
> labeling.  
>  
> Binary region analysis (also known as connected component analysis)
takes a
> binary
> image as input and generates a list of all connected regions
(blobs). For
> each region,
> it provides the color, parent, area, perimeter, centroid, 2nd
moments, and
> bounding
> box. Parameters allow the user to specify the color of the border, the
> minimum blob
> area below which the blob is merged with its parent, and the ROI.
>  
> Labeling (which is optional) generates a new gray level image in
which each
> blob is
> represented by pixels all of which have that region number, from 0
to 255.
> Any regions
> beyond 255 are also assigned 255. However, this limitation does not
affect
> the binary
> region analysis ,  which can cope with thousands of regions.
>  
> The programs I have provided include a file that embodies the two
algorithms
> and a file
> that can be used to demo its operation on a variety of test images.
I also
> included a
> large number of test images that I received from many OpenCV users
over the
> past
> five years. I have used these images to do quality assurance of the
region
> analysis
> process. The labeling algorithm has not been as extensively tested, but
> since it is
> simple and it piggy-backs on region analysis, it requires little
testing.
>  
> Instructions for use: Unzip the file into the directory of your
choice. Then
> create an
> Images subdirectory, and move all the images into that subdirectory.
>  
> The algorithms have #define statements that can be used to configure
them

> either for
> C or C++. They have been optimized to be fast, making them suitable for
> images
> with a large number of regions. One of the test images has 257 disjoint
> regions.
>  
> Also uploaded is a short explanation of the user interface. This
> documentation is in
> the form of an html page similar to those in the OpenCV manual.
>  
> Finally, there is a documentation file in MS Word that explains binary
> region analysis.
> It discusses the specifics of the implementation, including some of its
> limitations.
>  
> As usual with OpenCV, I am putting this code in the public domain.
Anyone is
> free to
> use it however they wish. About 20 people are already using earlier
versions
> of this
> software, and in fact blobslib was based on an earlier version of my
code.
> At least
> one of these earlier uses was embedded in a manufacturing tool that
has run

> in
> production successfully for over a year.
>  
> - Dave Grossman
>  
>  
>  
>
>
> [Non-text portions of this message have been removed]
>


Reply | Threaded
Open this post in threaded view
|

RE: Re: Binary region analysis and labeling - blobs - connected components

Dave Grossman
I don't know what the problem is.  However, when I run the program I have
CV.dll, cv.lib, cvaux.dll, cvaux.lib, and HighGUI.dll in the same directory
as my .cpp and .h files. So maybe it's a linking problem. I'm still on MS
Visual C++ 6.0 and OpenCV 1. But other people using other operating systems,
development systems, and versions of OpenCV have gotten it to run. Someone
please help this guy!
 

  _____  

From: [hidden email] [mailto:[hidden email]] On Behalf Of
roguex360
Sent: Monday, January 05, 2009 1:56 PM
To: [hidden email]
Subject: [OpenCV] Re: Binary region analysis and labeling - blobs -
connected components



I have downloaded your Blob Analysis code and tried to make it run (in
Visual Studio 2008 with OpenCV 1.0 on 64 Bit Vista) but I keep getting
errors.

The main one that keeps popping up is:

"Windows has triggered a breakpoint in Blob Analysis Demo.exe.

This may be due to a corruption of the heap, which indicates a bug in
Blob Analysis Demo.exe or any of the DLLs it has loaded.

This may also be due to the user pressing F12 while Blob Analysis
Demo.exe has focus.

The output window may have more diagnostic information."

I do not understand what this means, and each time it pops up, it
opens the file "free.c" within Visual Studio.

This happens when I try it for any of the test images you supply, and
I have been unable to make the supplied Demo work successfully.

Please could you help me work out why it's not working?

I really need to be able to identify and label regions (blobs) from
binary images, and your code here seems to be the simplest way to do
this.

I have tried to install cvBlobsLib and cvBlob, but I can't understand
the instructions for either, so can't make them work.

Please help, thanks,
--rogue--

--- In OpenCV@yahoogroups. <mailto:OpenCV%40yahoogroups.com> com, "Dave
Grossman" <dgrossman2@...> wrote:
>
> I have just uploaded BlobAnalysis.zip to the Yahoo Groups OpenCV files
> section. It
> contains a set of programs that I wrote for binary region analysis and
> labeling.
>
> Binary region analysis (also known as connected component analysis)
takes a
> binary
> image as input and generates a list of all connected regions
(blobs). For
> each region,
> it provides the color, parent, area, perimeter, centroid, 2nd
moments, and
> bounding
> box. Parameters allow the user to specify the color of the border, the
> minimum blob
> area below which the blob is merged with its parent, and the ROI.
>
> Labeling (which is optional) generates a new gray level image in
which each
> blob is
> represented by pixels all of which have that region number, from 0
to 255.
> Any regions
> beyond 255 are also assigned 255. However, this limitation does not
affect
> the binary
> region analysis , which can cope with thousands of regions.
>
> The programs I have provided include a file that embodies the two
algorithms
> and a file
> that can be used to demo its operation on a variety of test images.
I also
> included a
> large number of test images that I received from many OpenCV users
over the
> past
> five years. I have used these images to do quality assurance of the
region
> analysis
> process. The labeling algorithm has not been as extensively tested, but
> since it is
> simple and it piggy-backs on region analysis, it requires little
testing.
>
> Instructions for use: Unzip the file into the directory of your
choice. Then
> create an
> Images subdirectory, and move all the images into that subdirectory.
>
> The algorithms have #define statements that can be used to configure
them

> either for
> C or C++. They have been optimized to be fast, making them suitable for
> images
> with a large number of regions. One of the test images has 257 disjoint
> regions.
>
> Also uploaded is a short explanation of the user interface. This
> documentation is in
> the form of an html page similar to those in the OpenCV manual.
>
> Finally, there is a documentation file in MS Word that explains binary
> region analysis.
> It discusses the specifics of the implementation, including some of its
> limitations.
>
> As usual with OpenCV, I am putting this code in the public domain.
Anyone is
> free to
> use it however they wish. About 20 people are already using earlier
versions
> of this
> software, and in fact blobslib was based on an earlier version of my
code.
> At least
> one of these earlier uses was embedded in a manufacturing tool that
has run

> in
> production successfully for over a year.
>
> - Dave Grossman
>
>
>
>
>
> [Non-text portions of this message have been removed]
>



 


[Non-text portions of this message have been removed]

Reply | Threaded
Open this post in threaded view
|

Re: Binary region analysis and labeling - blobs - connected components

nesher_hh
In reply to this post by dgrossman2
How would I give each blob a fixed id and track this blob in each
following frame?


--- In [hidden email], "Dave Grossman" <dgrossman2@...> wrote:
>
> I have just uploaded BlobAnalysis.zip to the Yahoo Groups OpenCV
files
> section. It
> contains a set of programs that I wrote for binary region analysis
and
> labeling.  
>  
> Binary region analysis (also known as connected component analysis)
takes a
> binary
> image as input and generates a list of all connected regions
(blobs). For
> each region,
> it provides the color, parent, area, perimeter, centroid, 2nd
moments, and
> bounding
> box. Parameters allow the user to specify the color of the border,
the
> minimum blob
> area below which the blob is merged with its parent, and the ROI.
>  
> Labeling (which is optional) generates a new gray level image in
which each
> blob is
> represented by pixels all of which have that region number, from 0
to 255.
> Any regions
> beyond 255 are also assigned 255. However, this limitation does not
affect
> the binary
> region analysis ,  which can cope with thousands of regions.
>  
> The programs I have provided include a file that embodies the two
algorithms
> and a file
> that can be used to demo its operation on a variety of test images.
I also
> included a
> large number of test images that I received from many OpenCV users
over the
> past
> five years. I have used these images to do quality assurance of the
region
> analysis
> process. The labeling algorithm has not been as extensively tested,
but
> since it is
> simple and it piggy-backs on region analysis, it requires little
testing.
>  
> Instructions for use: Unzip the file into the directory of your
choice. Then
> create an
> Images subdirectory, and move all the images into that subdirectory.
>  
> The algorithms have #define statements that can be used to
configure them
> either for
> C or C++. They have been optimized to be fast, making them suitable
for
> images
> with a large number of regions. One of the test images has 257
disjoint
> regions.
>  
> Also uploaded is a short explanation of the user interface. This
> documentation is in
> the form of an html page similar to those in the OpenCV manual.
>  
> Finally, there is a documentation file in MS Word that explains
binary
> region analysis.
> It discusses the specifics of the implementation, including some of
its
> limitations.
>  
> As usual with OpenCV, I am putting this code in the public domain.
Anyone is
> free to
> use it however they wish. About 20 people are already using earlier
versions
> of this
> software, and in fact blobslib was based on an earlier version of
my code.
> At least
> one of these earlier uses was embedded in a manufacturing tool that
has run

> in
> production successfully for over a year.
>  
> - Dave Grossman
>  
>  
>  
>
>
> [Non-text portions of this message have been removed]
>


Reply | Threaded
Open this post in threaded view
|

RE: Re: Binary region analysis and labeling - blobs - connected components

Dave Grossman
The numbering of the blobs is based on a raster scan, so if a particular
blob is moving, its index will change from frame to frame. However, many of
its properties won't change (color, area, perimeter, 2nd moments), while
other properties will change slowly (centroid, bounding box). You would
therefore have to write a simple routine that for each frame would figure
out which new index has the blob that corresponds to the blob in the prior
frame.

  _____  

From: [hidden email] [mailto:[hidden email]] On Behalf Of
nesher_hh
Sent: Tuesday, January 06, 2009 12:35 PM
To: [hidden email]
Subject: [OpenCV] Re: Binary region analysis and labeling - blobs -
connected components



How would I give each blob a fixed id and track this blob in each
following frame?

--- In OpenCV@yahoogroups. <mailto:OpenCV%40yahoogroups.com> com, "Dave
Grossman" <dgrossman2@...> wrote:
>
> I have just uploaded BlobAnalysis.zip to the Yahoo Groups OpenCV
files
> section. It
> contains a set of programs that I wrote for binary region analysis
and
> labeling.
>
> Binary region analysis (also known as connected component analysis)
takes a
> binary
> image as input and generates a list of all connected regions
(blobs). For
> each region,
> it provides the color, parent, area, perimeter, centroid, 2nd
moments, and
> bounding
> box. Parameters allow the user to specify the color of the border,
the
> minimum blob
> area below which the blob is merged with its parent, and the ROI.
>
> Labeling (which is optional) generates a new gray level image in
which each
> blob is
> represented by pixels all of which have that region number, from 0
to 255.
> Any regions
> beyond 255 are also assigned 255. However, this limitation does not
affect
> the binary
> region analysis , which can cope with thousands of regions.
>
> The programs I have provided include a file that embodies the two
algorithms
> and a file
> that can be used to demo its operation on a variety of test images.
I also
> included a
> large number of test images that I received from many OpenCV users
over the
> past
> five years. I have used these images to do quality assurance of the
region
> analysis
> process. The labeling algorithm has not been as extensively tested,
but
> since it is
> simple and it piggy-backs on region analysis, it requires little
testing.
>
> Instructions for use: Unzip the file into the directory of your
choice. Then
> create an
> Images subdirectory, and move all the images into that subdirectory.
>
> The algorithms have #define statements that can be used to
configure them
> either for
> C or C++. They have been optimized to be fast, making them suitable
for
> images
> with a large number of regions. One of the test images has 257
disjoint
> regions.
>
> Also uploaded is a short explanation of the user interface. This
> documentation is in
> the form of an html page similar to those in the OpenCV manual.
>
> Finally, there is a documentation file in MS Word that explains
binary
> region analysis.
> It discusses the specifics of the implementation, including some of
its
> limitations.
>
> As usual with OpenCV, I am putting this code in the public domain.
Anyone is
> free to
> use it however they wish. About 20 people are already using earlier
versions
> of this
> software, and in fact blobslib was based on an earlier version of
my code.
> At least
> one of these earlier uses was embedded in a manufacturing tool that
has run

> in
> production successfully for over a year.
>
> - Dave Grossman
>
>
>
>
>
> [Non-text portions of this message have been removed]
>



 


[Non-text portions of this message have been removed]

Reply | Threaded
Open this post in threaded view
|

Re: Binary region analysis and labeling - blobs - connected components

yair_movshovitz
In reply to this post by Dave Grossman
Had the same problem
The line: cvReleaseImage(&LabeledImage);
in BlobDemo.cpp produces the error, when I commented it out the demo
worked fine.

I also use the .h file in something I do and that works well.

Hope This helps a little.
Yair

--- In [hidden email], "Dave Grossman" <dgrossman2@...> wrote:
>
> I don't know what the problem is.  However, when I run the program I
have
> CV.dll, cv.lib, cvaux.dll, cvaux.lib, and HighGUI.dll in the same
directory
> as my .cpp and .h files. So maybe it's a linking problem. I'm still
on MS
> Visual C++ 6.0 and OpenCV 1. But other people using other operating
systems,
> development systems, and versions of OpenCV have gotten it to run.
Someone
> please help this guy!
>  
>
>   _____  
>
> From: [hidden email] [mailto:[hidden email]] On
Behalf Of

> roguex360
> Sent: Monday, January 05, 2009 1:56 PM
> To: [hidden email]
> Subject: [OpenCV] Re: Binary region analysis and labeling - blobs -
> connected components
>
>
>
> I have downloaded your Blob Analysis code and tried to make it run (in
> Visual Studio 2008 with OpenCV 1.0 on 64 Bit Vista) but I keep getting
> errors.
>
> The main one that keeps popping up is:
>
> "Windows has triggered a breakpoint in Blob Analysis Demo.exe.
>
> This may be due to a corruption of the heap, which indicates a bug in
> Blob Analysis Demo.exe or any of the DLLs it has loaded.
>
> This may also be due to the user pressing F12 while Blob Analysis
> Demo.exe has focus.
>
> The output window may have more diagnostic information."
>
> I do not understand what this means, and each time it pops up, it
> opens the file "free.c" within Visual Studio.
>
> This happens when I try it for any of the test images you supply, and
> I have been unable to make the supplied Demo work successfully.
>
> Please could you help me work out why it's not working?
>
> I really need to be able to identify and label regions (blobs) from
> binary images, and your code here seems to be the simplest way to do
> this.
>
> I have tried to install cvBlobsLib and cvBlob, but I can't understand
> the instructions for either, so can't make them work.
>
> Please help, thanks,
> --rogue--
>
> --- In OpenCV@yahoogroups. <mailto:OpenCV%40yahoogroups.com> com, "Dave
> Grossman" <dgrossman2@> wrote:
> >
> > I have just uploaded BlobAnalysis.zip to the Yahoo Groups OpenCV files
> > section. It
> > contains a set of programs that I wrote for binary region analysis and
> > labeling.
> >
> > Binary region analysis (also known as connected component analysis)
> takes a
> > binary
> > image as input and generates a list of all connected regions
> (blobs). For
> > each region,
> > it provides the color, parent, area, perimeter, centroid, 2nd
> moments, and
> > bounding
> > box. Parameters allow the user to specify the color of the border, the
> > minimum blob
> > area below which the blob is merged with its parent, and the ROI.
> >
> > Labeling (which is optional) generates a new gray level image in
> which each
> > blob is
> > represented by pixels all of which have that region number, from 0
> to 255.
> > Any regions
> > beyond 255 are also assigned 255. However, this limitation does not
> affect
> > the binary
> > region analysis , which can cope with thousands of regions.
> >
> > The programs I have provided include a file that embodies the two
> algorithms
> > and a file
> > that can be used to demo its operation on a variety of test images.
> I also
> > included a
> > large number of test images that I received from many OpenCV users
> over the
> > past
> > five years. I have used these images to do quality assurance of the
> region
> > analysis
> > process. The labeling algorithm has not been as extensively
tested, but

> > since it is
> > simple and it piggy-backs on region analysis, it requires little
> testing.
> >
> > Instructions for use: Unzip the file into the directory of your
> choice. Then
> > create an
> > Images subdirectory, and move all the images into that subdirectory.
> >
> > The algorithms have #define statements that can be used to configure
> them
> > either for
> > C or C++. They have been optimized to be fast, making them
suitable for
> > images
> > with a large number of regions. One of the test images has 257
disjoint
> > regions.
> >
> > Also uploaded is a short explanation of the user interface. This
> > documentation is in
> > the form of an html page similar to those in the OpenCV manual.
> >
> > Finally, there is a documentation file in MS Word that explains binary
> > region analysis.
> > It discusses the specifics of the implementation, including some
of its

> > limitations.
> >
> > As usual with OpenCV, I am putting this code in the public domain.
> Anyone is
> > free to
> > use it however they wish. About 20 people are already using earlier
> versions
> > of this
> > software, and in fact blobslib was based on an earlier version of my
> code.
> > At least
> > one of these earlier uses was embedded in a manufacturing tool that
> has run
> > in
> > production successfully for over a year.
> >
> > - Dave Grossman
> >
> >
> >
> >
> >
> > [Non-text portions of this message have been removed]
> >
>
>
>
>  
>
>
> [Non-text portions of this message have been removed]
>


Reply | Threaded
Open this post in threaded view
|

Re: Binary region analysis and labeling - blobs - connected components

Witek Czajewski - Czajnik
In reply to this post by dgrossman2
Perhaps I'm just stupid, but please explain the header of your blobs.h file:

//***************************************************************//
//* Blob analysis package  Version1.8 4 May 2008                *//
//* History:                                                    *//
//* - Version 1.0 8 August 2003                                 *//
//* - Version 1.2 3 January 2008                                *//
//* - Version 1.3 5 January 2008 Add BLOBCOLOR                  *//
//* - Version 1.4 13 January 2008 Add ROI function              *//
//* - Version 1.5 13 April 2008 Fix perimeter on Region 0       *//
//* - Version 1.6 1 May 2008 Reduce size of working storage     *//
//* - Version 1.7 2 May 2008 Speed up run code initialization   *//
//* - Version 1.8 4 May 2008 Fix bugs in perimeter comp & Reg 0 *//
//* - Version 2.0 3 Jan 2009 Add labeling functionality         *//
//*                                                             *//
//* Input: IplImage* binary image                               *//
//* Output: attributes of each connected region                 *//
//* Author: Dave Grossman                                       *//
//* Email: [hidden email]                             *//
//* Acknowledgement: the algorithm has been around > 30 yrs     *//
//***************************************************************//


What version is this? 1.8? 2.0?

Witek

Reply | Threaded
Open this post in threaded view
|

Re: Binary region analysis and labeling - blobs - connected components

Witek Czajewski - Czajnik
In reply to this post by yair_movshovitz
Yes, that's right, same case here. I'm not an expert, but I have noticed a few times, that when you access image data directly (and this is the case of LabeledImage in function Fill) OpenCV for some reason will crash trying to release the image. I have no idea if this is a bug or something. Not releasing such an image usually helps, and I BELIEVE it does not cause memory leak, but I did not check it in this case.
I'm using MS Visual Studio 2008 by the way.

Witek

--- In [hidden email], "yair_movshovitz" <yairmov@...> wrote:

>
> Had the same problem
> The line: cvReleaseImage(&LabeledImage);
> in BlobDemo.cpp produces the error, when I commented it out the demo
> worked fine.
>
> I also use the .h file in something I do and that works well.
>
> Hope This helps a little.
> Yair


Reply | Threaded
Open this post in threaded view
|

RE: Re: Binary region analysis and labeling - blobs - connected components

diyuqingjie
In reply to this post by Dave Grossman
Hi Dave,
    Could you send me the lastest code of BlobAnalysis please, thank you very much !
My Email: xiaomin111190@yahoo.cn