Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

alternative to bwlabel command / bounding box?

110 views
Skip to first unread message

ZK

unread,
Nov 20, 2008, 10:07:02 PM11/20/08
to
Hey guys. As usual, I'm having a little difficultly and really would appreciate your help. In order to try and be more clear in the problem I'm having, I've tried to include some code and background on the project at hand.

Background on my project:
---------------------------------------
So I'm making an object tracking program in Matlab and right now how the program figures out how many objects are in the frame is: it takes the color image, thresholds it to black and white, then usese bwlabel to figure out how many separate objects there are. Then, using the labeled regions, i can use the .boundingbox and .centroid commands to find the center point of each region and draw a bounding box around it.
The code looks something like this...

[imLabeled numOfRegions] = bwlabel(BWimage, 8);
data = regionprops(imLabeled,'basic');
boundingBox = data(i).BoundingBox;
center = data(i).Centroid;

NOTE: in the above code there is an 'i' when getting the centroid and boundingbox properties because the grabbing of that data is actually done later on in a for loop using the variable i.

As you can imagine, the bwlabel command (pretty much by itself) cuts the framerate in which i can acquire data from about 9/10fps to about 4/5fps. This 50% reduction sometimes causes significant problems in the tracking of the objects.


The question:
--------------------
Is there another, much faster way, without having to actually label every region, to figure out the number of separate regions in a given black and white image, and the center point/bounding box properties for every region.


I really appreciate all your support and help, not just with this problem but with all the problems I've had over the years. With your help on these forums I've been able to create some pretty neat stuff. Thanks !!

--Zac

ZK

unread,
Nov 21, 2008, 10:38:02 AM11/21/08
to
"ZK " <zs...@hotmail.com> wrote in message <gg58km$qo4$1...@fred.mathworks.com>...

ZK

unread,
Nov 21, 2008, 10:39:02 AM11/21/08
to
bump


"ZK " <zs...@hotmail.com> wrote in message <gg58km$qo4$1...@fred.mathworks.com>...

usha kiran peddala

unread,
Oct 18, 2010, 3:23:03 PM10/18/10
to
i have a small doubt after using the labeled regions, .boundingbox and .centroid commands to find the center point of each region how can u draw a bounding box around it. can u give the command of how you are drawing or marking the centroid on the image for every image/frame in the video.

"ZK " <zs...@hotmail.com> wrote in message <gg58km$qo4$1...@fred.mathworks.com>...

David Young

unread,
Oct 18, 2010, 4:06:04 PM10/18/10
to
In recent versions of the IPT, you can give the binary image (BWimage in your case) directly to regionprops, without first creating a labelled image. If you have a regionprops that supports this, it may give you some speedup, but possibly not a large one.

ImageAnalyst

unread,
Oct 18, 2010, 5:09:48 PM10/18/10
to
On Oct 18, 3:23 pm, "usha kiran peddala" <kiran8...@gmail.com> wrote:
> i have a small doubt after using the labeled regions, .boundingbox and .centroid commands to find the center point of each region how can u draw a bounding box around it. can u give the command of how you are drawing or marking the centroid on the image for every image/frame in the video.
-----------------------------------------------------------------
Look how I do it here:
http://www.mathworks.com/matlabcentral/fileexchange/25157
I calculate the centroid and bounding box (among other things) for
every object. You just need to replicate that code (or the subset of
it that you want) and apply it to every frame of your video.

Bruce Tannenbaum

unread,
Oct 19, 2010, 11:21:49 AM10/19/10
to
Zac,

Try using video.BlobAnalysis in "Video and Image Processing Blocsket". It
is a System object, so be sure to read documentation on how to use these.
You can configure it to give you the centroid and bounding boc of each blob
and a count of the number of blobs in your video frame, all in one line of
code. It is also more computationally efficient than the Image Processing
Toolbox functions you are using.

Hope this helps,
Bruce

"usha kiran peddala" <kira...@gmail.com> wrote in message
news:i9i6qn$ruh$1...@fred.mathworks.com...

0 new messages