Code covered by the BSD License  

3.5

3.5 | 4 ratings Rate this file 35 Downloads (last 30 days) File Size: 1.46 KB File ID: #26296

Draw Bounding Box

by

 

This function draws bounding boxes around blobs in a binary image.

| Watch this File

File Information
Description

Input is a binary image, and output is another binary image holding the rectangles over the detected blobs. Its not a superimposition of a rectangle over an image.

DRAWBOUNDINGBOX draws the bounding boxes around the blobs in a binary image image is the binary image input supplied by the user. This function extracts the coordinates and dimension values of each blob from stats.BoundingBox structure one by one and draws the rectangle around them. To store an image you can further use IMWRITE function on the output of the function DRAWBOUNDINGBOX. the new image stored will have the rectangles marked over the blobs since it is not a superimposition.

MATLAB release MATLAB 7.4 (R2007a)
Tags for This File   Please login to tag files.
Please login to add a comment or rating.
Comments and Ratings (15)
20 Oct 2013 prakash dhandhukiya

if sir you are helping in matlan contect me on prakashdhandhukiya@ymail.com

01 Feb 2013 Jack Sparrow

Sir,
I am getting error if I use this code to draw bounding box

"Attempted to access g(0,0); index must be a positive integer

g(y1,i) = 1;

There is an error there

29 Apr 2012 sindhu bijjal

im getting error as
Undefined function or method 'bounding' for input arguments
of type 'char'.
plz help..

19 Mar 2012 Siddarth

plz send code to draw bounding boxes around text lines.......

29 Feb 2012 nausheen

my program is running but i m not getting a rectangle on the region i want blobs

17 Feb 2012 RaviTeja

@YANNICK : Thanks! Itz working.. but how do I see the output ?

30 Aug 2011 danitop  
04 Aug 2011 Yannick

Handy submission, but not very well documented and a little inaccurate. For example, should the inner or the outer boundary of the blobs be drawn? Also, the outline is off by one on the top and left edges:

A = [0 0 0 0 0 0; 0 0 1 1 0 0; 0 1 1 1 1 0; 0 0 1 1 0 0; 0 0 0 0 0 0]
B = drawboundingbox(A)

A =

0 0 0 0 0 0
0 0 1 1 0 0
0 1 1 1 1 0
0 0 1 1 0 0
0 0 0 0 0 0

>> B = drawboundingbox(A)

B =

1 1 1 1 1 0
1 0 1 1 1 0
1 1 1 1 1 0
1 1 1 1 1 0
0 0 0 0 0 0

This can be fixed by replacing some floor by ceil (4 times, 2 in the lower loop limits, 2 in the loop body) and by changing lines 18 and 20 to this:

g(y1 + stats(k).BoundingBox(4) - 1, i) = 1;
g(j, x1 + stats(k).BoundingBox(3) - 1) = 1;

06 May 2011 Jorge Lewinnek

Hi, I like this code, but can you do it without for?, it takes a lot of time to work.

08 Mar 2011 nurul

Hi,

I'm also getting error.

''Undefined function or method 'bounding' for input arguments of type 'char'''.

Can anyone help me???

26 Feb 2011 Naeem Nematollahi

Thanks a lot for your code

29 Dec 2010 Uni A

Hello.

I am getting an error too. It says:
>> drawboundingbox(Ip)
??? Error using ==> drawboundingbox
Too many input arguments.

Error in ==> drawboundingbox at 11
DRAWBOUNDINGBOX [image1] = bwlabel(image);

Any ideas, please?

17 Nov 2010 sanjay

Sir,
I am getting error if I use this code to draw bounding box

"Attempted to access g(0,0); index must be a positive integer

g(y1,i) = 1;

pls suggest me what to be done

24 Mar 2010 lana

thank you very much for your amazing code

02 Feb 2010 Alisha  

Contact us