File Exchange

image thumbnail

Draw Bounding Box

version 1.0 (1.46 KB) by

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

15 Downloads

Updated

View License

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.

Comments and Ratings (15)

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

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

sindhu bijjal

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

Siddarth

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

nausheen

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

RaviTeja

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

danitop

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;

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

nurul

nurul (view profile)

Hi,

I'm also getting error.

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

Can anyone help me???

Thanks a lot for your code

Uni A

Uni A (view profile)

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?

sanjay

sanjay (view profile)

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

lana

lana (view profile)

thank you very much for your amazing code

Alisha

Alisha (view profile)

MATLAB Release
MATLAB 7.4 (R2007a)

Download apps, toolboxes, and other File Exchange content using Add-On Explorer in MATLAB.

» Watch video