Path: news.mathworks.com!newsfeed-00.mathworks.com!newscon02.news.prodigy.net!prodigy.net!news.glorb.com!postnews.google.com!e53g2000hsa.googlegroups.com!not-for-mail
From: ImageAnalyst <imageanalyst@mailinator.com>
Newsgroups: comp.soft-sys.matlab
Subject: Re: Need algorithm help: molecule length from an image
Date: Tue, 13 May 2008 12:27:04 -0700 (PDT)
Organization: http://groups.google.com
Lines: 65
Message-ID: <2c7de16d-ebbf-44c4-90c3-115f85c756b8@e53g2000hsa.googlegroups.com>
References: <g023qb$j0m$1@fred.mathworks.com> <g0couj$np$1@fred.mathworks.com>
NNTP-Posting-Host: 192.44.136.113
Mime-Version: 1.0
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
X-Trace: posting.google.com 1210706825 20970 127.0.0.1 (13 May 2008 19:27:05 GMT)
X-Complaints-To: groups-abuse@google.com
NNTP-Posting-Date: Tue, 13 May 2008 19:27:05 +0000 (UTC)
Complaints-To: groups-abuse@google.com
Injection-Info: e53g2000hsa.googlegroups.com; posting-host=192.44.136.113; 
User-Agent: G2/1.0
X-HTTP-UserAgent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET 
X-HTTP-Via: 1.1 bdci2px (NetCache NetApp/6.0.6)
Xref: news.mathworks.com comp.soft-sys.matlab:468233


On May 13, 3:08=A0pm, "Adrian " <a...@med.unc.edu> wrote:
> Thank you all for your insight into the matter. Sorry for
> the lack of clarification for the image I linked to: the
> squiggly line in the middle is in fact the molecule.
> Everything else is background. The image is a transmission
> electron micrograph, so it's 2D and fixed.
>
> The way that we do length analysis is by manually drawing
> along the molecule using a mouse and some software that came
> with the electron microscope. As you can image, this is
> somewhat inaccurate and tedious, especially if one is
> scoring hundreds of molecules. In addition, for the project
> I am working on, length analysis is the centerpiece, so I
> want to have data as accurate as possible.
>
> I didn't include a scale bar - my apologies. I wanted to
> isolate only one molecule to make the problem easier to
> solve, =A0and forgot to include the scale. There is a scale
> that converts pixel length to actual distance that I know
> how to use, so the only problem is finding the pixel length.
>
> This is a method I have come up with from using your
> suggestions.
>
> 1) Find the average pixel shade (between 0 and 255)
> 2) Remove all pixels that are below the threshold (remove
> the darker background).
> 3) Set the remaining pixels equal to 1; all other pixels
> equal to 0.
> 4) Scan the image from left to right and then "walk" along
> areas that are labeled as "1". If the program finds a pixel
> that is labeled "1", look toward the 8 surrounding pixels to
> find if there is another pixel labeled "1". If so, continue
> to look for pixels labeled "1" (e.g., keep "walking" along
> the molecule), and if possible, continue "walking" in the
> same direction as previously (to prevent the "walker" from
> going back to where it came from). Then, after walking along
> the molecule, label all of the points it walked on as "0" so
> the scanner won't walk there again.
> 5) Output the length measurement as pixel and convert to nm
> by looking at the scale.
>
> Does this seem reasonable? Thank you very much for the
> discussion..

--------------------------------------------------------------------------
Adrian:
Glad you're still monitoring and we're not just wasting our time
here.  You could do what you described with this algorithm:
1. Binarize the image at some threshold.
2. Skeletonize the image - bwmorph(thresholdedImageArray, 'skel',
Inf).  That's what I'm doing but you're essentially doing bwlabel and
then binarizing the labeled image.  Skeletonizing has the advantage
that it will ignore parts of the line that are thicker than one pixel
but it will under count big solid balled up areas.  Your method will
overcount parts of the line that are thicker than one pixel but will
correctly count big balled up areas.
3. Sum the pixels in the image Sum(sum(skeletonizedImageArray))
The only point I might add is that you might want to count triple and
quad points (where the line touches or crosses itself) twice rather
than avoiding counting those pixels like you said.  The molecule would
actually occur twice at those positions.  Think about it and you'll
see why.
Regards,
ImageAnalyst