Skip to Main Content Skip to Search
Login
File Exchange
MATLAB Newsgroup
Link Exchange
  Blogs  
 Contest 
MathWorks.com

Thread Subject: Alternative to BWlabel?

Subject: Alternative to BWlabel?

From: Jon Schneider

Date: 5 Dec, 2007 22:08:30

Message: 1 of 3

Hi, not sure if this will yield useful results since there
is already a function (albeit one that I do not have). I
have a logical matrix created from a bandpassed image. This
matrix will have several regions of connected 1's. Is there
any way (other than BWlabel) to identify these areas
independantly? The end goal would be to seperate them into
individual matrixes.
Ex:
[ 0 0 0 0 0 0
  0 1 1 0 0 0
  0 1 1 0 0 0
  0 0 0 0 1 1
  0 0 0 1 1 1 ]
turns into:

[ 0 0 0 0 0 0
  0 1 1 0 0 0
  0 1 1 0 0 0
  0 0 0 0 0 0
  0 0 0 0 0 0 ]
and
[ 0 0 0 0 0 0
  0 0 0 0 0 0
  0 0 0 0 0 0
  0 0 0 0 1 1
  0 0 0 1 1 1 ]

Right now I am dealing with 128 x 128, and the objects will
be irregular shapes. Any ideas are appreciated!

Subject: Alternative to BWlabel?

From: Ken Campbell

Date: 6 Dec, 2007 02:22:52

Message: 2 of 3

"Jon Schneider" <j@yahoo.com> wrote in message
<fj77gu$1q2$1@fred.mathworks.com>...
> Hi, not sure if this will yield useful results since there
> is already a function (albeit one that I do not have). I
> have a logical matrix created from a bandpassed image. This
> matrix will have several regions of connected 1's. Is there
> any way (other than BWlabel) to identify these areas
> independantly? The end goal would be to seperate them into
> individual matrixes.
> Ex:
> [ 0 0 0 0 0 0
> 0 1 1 0 0 0
> 0 1 1 0 0 0
> 0 0 0 0 1 1
> 0 0 0 1 1 1 ]
> turns into:
>
> [ 0 0 0 0 0 0
> 0 1 1 0 0 0
> 0 1 1 0 0 0
> 0 0 0 0 0 0
> 0 0 0 0 0 0 ]
> and
> [ 0 0 0 0 0 0
> 0 0 0 0 0 0
> 0 0 0 0 0 0
> 0 0 0 0 1 1
> 0 0 0 1 1 1 ]
>
> Right now I am dealing with 128 x 128, and the objects will
> be irregular shapes. Any ideas are appreciated!


I bought the image processing toolbox a couple of weeks ago
but I had a quick look on the web just now and found this
'alternative'.

http://www.petercorke.com/Machine%20Vision%20Toolbox.html

There's a nice PDF describing the toolbox available here

http://ieeexplore.ieee.org/xpl/freeabs_all.jsp?arnumber=1577021

Perhaps iblobs and ilabel will do what you need?

Ken

Subject: Alternative to BWlabel?

From: Jon Schneider

Date: 6 Dec, 2007 18:32:45

Message: 3 of 3

"Ken Campbell" <campbeks@gmail.com> wrote in message
<fj7mds$sis$1@fred.mathworks.com>...
> "Jon Schneider" <j@yahoo.com> wrote in message
> <fj77gu$1q2$1@fred.mathworks.com>...
> > Hi, not sure if this will yield useful results since there
> > is already a function (albeit one that I do not have). I
> > have a logical matrix created from a bandpassed image. This
> > matrix will have several regions of connected 1's. Is there
> > any way (other than BWlabel) to identify these areas
> > independantly? The end goal would be to seperate them into
> > individual matrixes.
> > Ex:
> > [ 0 0 0 0 0 0
> > 0 1 1 0 0 0
> > 0 1 1 0 0 0
> > 0 0 0 0 1 1
> > 0 0 0 1 1 1 ]
> > turns into:
> >
> > [ 0 0 0 0 0 0
> > 0 1 1 0 0 0
> > 0 1 1 0 0 0
> > 0 0 0 0 0 0
> > 0 0 0 0 0 0 ]
> > and
> > [ 0 0 0 0 0 0
> > 0 0 0 0 0 0
> > 0 0 0 0 0 0
> > 0 0 0 0 1 1
> > 0 0 0 1 1 1 ]
> >
> > Right now I am dealing with 128 x 128, and the objects will
> > be irregular shapes. Any ideas are appreciated!
>
>
> I bought the image processing toolbox a couple of weeks ago
> but I had a quick look on the web just now and found this
> 'alternative'.
>
> http://www.petercorke.com/Machine%20Vision%20Toolbox.html
>
> There's a nice PDF describing the toolbox available here
>
>
http://ieeexplore.ieee.org/xpl/freeabs_all.jsp?arnumber=1577021
>
> Perhaps iblobs and ilabel will do what you need?
>
> Ken
>

Thanks! That looks like exactly what I need.
This was my eventual solution:
%index is the index to the binary. This program sorts each
%connected region to nindex (then just delete the extra
%zeros that are put in there).

n=1;
m=size(index);
while ~isempty(index)
    newindex=index(1);
    a=[1 2];
    while a(2)>a(1)
        for i=1:size(index)
            if sum(ismember(newindex,index(i)-1)) ||
sum(ismember(newindex,index(i)+1)) ||
sum(ismember(newindex,index(i)-128)) ||
sum(ismember(newindex,index(i)+128))
                newindex=[newindex;index(i)];
            end
        end
        index=index(end:-1:1);
        newindex=unique(newindex);
        a(1)=a(2);
        pop=size(newindex);
        a(2)=pop(1);
    end
nindex(:,n)=zeros(m(1),1);
nindex(1:size(newindex),n)=newindex;
index=setxor(index,newindex);
n=n+1;
end

If anyone has any comments for improvement (efficiency) it
would greatly help out a beginner.

Thanks again.

Tags for this Thread

Everyone's Tags:

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.

Tag Activity for This Thread
Tag Applied By Date/Time
bwlabel Ken Campbell 5 Dec, 2007 21:25:06
rssFeed for this Thread

envelope graphic E-mail this page to a colleague

Public Submission Policy
NOTICE: Any content you submit to MATLAB Central, including personal information, is not subject to the protections which may be afforded information collected under other sections of The MathWorks, Inc. Web site. You are entirely responsible for all content that you upload, post, e-mail, transmit or otherwise make available via MATLAB Central. The MathWorks does not control the content posted by visitors to MATLAB Central and, does not guarantee the accuracy, integrity, or quality of such content. Under no circumstances will The MathWorks be liable in any way for any content not authored by The MathWorks, or any loss or damage of any kind incurred as a result of the use of any content posted, e-mailed, transmitted or otherwise made available via MATLAB Central. Read the complete Disclaimer prior to use.
Related Topics