Thread Subject: object detection

Subject: object detection

From: westclox

Date: 20 Dec, 2006 05:47:14

Message: 1 of 4

Im trying to write some code to detect objects in an image, I have
come up with some psuedocode but I dont know how good this is, would
like some advice on whether I could optimise it, also I dont know how
to implement the repeat until loop i want in matlab, as well as not
knowing how to find the m-connectivity of a pixel in the most
efficient manner, at the step shown below, so would appreciate any
help on how this can be done thanks

Open image
Get image size (Rows,Cols)
Convert image to binary

Objects = 1
For M=1:Rows
For N=1:Cols
If (M,N)=1
Objects = Objects + 1
Record object start point (M,N)

Repeat
startpoint = M,N
Check M-Connectivity
If connected pixel found
set startpoint = this pixel
record this pixel into a matrix containing all points for this
object
Until no connectivity found
%end of object
end
end
end

Subject: object detection

From: westclox

Date: 21 Dec, 2006 12:47:32

Message: 2 of 4

is anybody able to help me out on this? tnx

westclox wrote:
>
>
> Im trying to write some code to detect objects in an image, I have
> come up with some psuedocode but I dont know how good this is,
> would
> like some advice on whether I could optimise it, also I dont know
> how
> to implement the repeat until loop i want in matlab, as well as not
> knowing how to find the m-connectivity of a pixel in the most
> efficient manner, at the step shown below, so would appreciate any
> help on how this can be done thanks
>
> Open image
> Get image size (Rows,Cols)
> Convert image to binary
>
> Objects = 1
> For M=1:Rows
> For N=1:Cols
> If (M,N)=1
> Objects = Objects + 1
> Record object start point (M,N)
>
> Repeat
> startpoint = M,N
> Check M-Connectivity
> If connected pixel found
> set startpoint = this pixel
> record this pixel into a matrix containing all points for this
> object
> Until no connectivity found
> %end of object
> end
> end
> end

Subject: object detection

From: Joseph

Date: 21 Dec, 2006 17:00:50

Message: 3 of 4

The process can be optimized by first choosing an optimal threshold
for converting you image to binary. That can only be done through
playing around. Assuming everything works in your algorithm, all
you're doing is finding pixel connectivity...then what? Now how many
objects are you trying to find? Is this known? Will they be the
same size? HOw many pixels^2 area are these objects? All these
questions have to be answered before picking out an algorithm.

Have you looked at the image processing toolbox?

 westclox wrote:
>
>
> is anybody able to help me out on this? tnx
>
> westclox wrote:
>>
>>
>> Im trying to write some code to detect objects in an image, I
> have
>> come up with some psuedocode but I dont know how good this is,
>> would
>> like some advice on whether I could optimise it, also I dont
know
>> how
>> to implement the repeat until loop i want in matlab, as well as
> not
>> knowing how to find the m-connectivity of a pixel in the most
>> efficient manner, at the step shown below, so would appreciate
> any
>> help on how this can be done thanks
>>
>> Open image
>> Get image size (Rows,Cols)
>> Convert image to binary
>>
>> Objects = 1
>> For M=1:Rows
>> For N=1:Cols
>> If (M,N)=1
>> Objects = Objects + 1
>> Record object start point (M,N)
>>
>> Repeat
>> startpoint = M,N
>> Check M-Connectivity
>> If connected pixel found
>> set startpoint = this pixel
>> record this pixel into a matrix containing all points for this
>> object
>> Until no connectivity found
>> %end of object
>> end
>> end
>> end

Subject: object detection

From: vihang

Date: 22 Dec, 2006 05:25:47

Message: 4 of 4

westclox wrote:
>
>
> Im trying to write some code to detect objects in an image, I have
> come up with some psuedocode but I dont know how good this is,
> would
> like some advice on whether I could optimise it, also I dont know
> how
> to implement the repeat until loop i want in matlab, as well as not
> knowing how to find the m-connectivity of a pixel in the most
> efficient manner, at the step shown below, so would appreciate any
> help on how this can be done thanks
>
> Open image
> Get image size (Rows,Cols)
> Convert image to binary
>
> Objects = 1
> For M=1:Rows
> For N=1:Cols
> If (M,N)=1
> Objects = Objects + 1
> Record object start point (M,N)
>
> Repeat
> startpoint = M,N
> Check M-Connectivity
> If connected pixel found
> set startpoint = this pixel
> record this pixel into a matrix containing all points for this
> object
> Until no connectivity found
> %end of object
> end
> end
> end

Hello
If you have the Image Processing ToolBox it will make your life much
more simpler. It has all the builtin function to accomplish your
requirement.

ex:
I = imread('rgb.jpg');
gray = rgb2gray(I);
bw = im2bw(gray,graythresh(gray));
L = bwlabel(bw);
stats = regionprops(L,'All');

Play around the stats and you got all the binary object properties
you can think of.

HTH
Vihang

Tags for this Thread

Add a New Tag:

Separated by commas
Ex.: root locus, bode

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

rssFeed for this Thread

Contact us at files@mathworks.com