comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » Re: Clsuter analysis wiht IDL
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Switch to threaded view of this topic Create a new topic Submit Reply
Re: Clsuter analysis wiht IDL [message #23847] Fri, 23 February 2001 08:20 Go to next message
Craig Markwardt is currently offline  Craig Markwardt
Messages: 1869
Registered: November 1996
Senior Member
dw@isva.dtu.dk (Dorthe Wildenschild) writes:

> I am trying to use the cluster analysis utility in IDL, and I can't work it
> out. Perhaps due to my lack of knowledge in the statistical field.....
>
> I have a 2D-image (658x658) with a single band of info (CT x-ray
> intentities) that I want to classify (into three classes) using cluster
> analysis. I assume I have to use the CLUST_WTS function first and then the
> CLUSTER function, but I can't work it out.
> The on-line help isn't very helpful on this topic....
>
> If I use
> weights = clust_wts(image, n_clusters=3), with image= intarr(658x658) I get
> alot of floating errors.
> Do I need to reform the image to (658x658,1) before using the clust_wts
> function? Doesn't seem to work either, though. Also how do I get the
> cluster numbers back as an overlay of my image? so that I can actually see
> the result of the classification.

I am by no means a statistics or clusters analysis expert, but from
looking at the documentation it seems that both CLUST_WTS and CLUSTER
require the n-dimensional *positions* of the data points, and not an
intensity map. It is pretty clear that the cluster functions are
based on an unweighted set of scatter-points. If you want to use your
intensity information as a weighting, you may be out of luck.

Perhaps you could achieve what you desire with this code, which simply
finds the non-zero pixels:

wh = where(image GT 0, ct)
if ct EQ 0 then message, 'ERROR: the image is blank!'
x = wh MOD 658 ; form x pixel positions
y = floor(wh / 658) ; form y pixel positions

xy = transpose([[x],[y]]) ; compute the 2-d scatter positions
weights = clust_wts(xy, n_clusters=3)
etc.

I haven't tried this, so it may take some tweaking. Good luck,
Craig

--
------------------------------------------------------------ --------------
Craig B. Markwardt, Ph.D. EMAIL: craigmnet@cow.physics.wisc.edu
Astrophysics, IDL, Finance, Derivatives | Remove "net" for better response
------------------------------------------------------------ --------------
Re: Re: Clsuter analysis wiht IDL [message #24014 is a reply to message #23847] Thu, 01 March 2001 03:20 Go to previous messageGo to next message
dw is currently offline  dw
Messages: 10
Registered: February 2001
Junior Member
<html>
&lt;Craig writes:<br>
<br>
&lt;I am by no means a statistics or clusters analysis expert, but
from<br>
&lt;looking at the documentation it seems that both CLUST_WTS and
CLUSTER<br>
&lt;require the n-dimensional *positions* of the data points, and not
an<br>
&lt;intensity map.&nbsp; It is pretty clear that the cluster functions
are<br>
&lt;based on an unweighted set of scatter-points.&nbsp; If you want to
use your<br>
&lt;intensity information as a weighting, you may be out of luck.<br>
<br>
&lt;Perhaps you could achieve what you desire with this code, which
simply<br>
&lt;finds the non-zero pixels:<br>
<br>
wh = where(image GT 0, ct)<br>
if ct EQ 0 then message, 'ERROR: the image is blank!'<br>
x = wh MOD 658&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ; form x pixel
positions<br>
y = floor(wh / 658) ; form y pixel positions<br>
<br>
xy = transpose([[x],[y]]) ; compute the 2-d scatter positions<br>
weights = clust_wts(xy, n_clusters=3)<br>
etc.<br>
<br>
&lt;I haven't tried this, so it may take some tweaking.&nbsp; Good
luck,<br>
&lt;Craig<br>
<br>
I'm such a beginner at this I don't know what the MOD function does? (no
on-line help listing for it)<br>
When trying to transpose, IDL corrects me with <br>
<font face="MS Sans Serif, Geneva" size=1>Arrays are allowed 1 - 8
dimensions<br>
<br>
thanks for trying to help!<br>
BTW I'm not a Mr. :-)<br>
D<br>
</font></html>
Re: Re: Clsuter analysis wiht IDL [message #24015 is a reply to message #23847] Thu, 01 March 2001 02:57 Go to previous messageGo to next message
dw is currently offline  dw
Messages: 10
Registered: February 2001
Junior Member
<html>
Benno,<br>
<br>
Thanks for the input.<br>
You suggested:<br>
&nbsp;<br>
use something like<br>
ref_img=REFORM(image,1,658*658)<br>
weights = clust_wts(ref_img, n_clusters=3)<br>
cls=cluster(ref_img,weights,n_cluster=3)<br>
tvscl,reform(cls,658,658)<br>
<br>
but when computing the weights it goes bad <br>
<font face="MS Sans Serif, Geneva" size=1>Program caused arithmetic
error: Floating underflow<br>
</font>and I get an array that is [1,3] and the values are<br>
<font face="MS Sans Serif, Geneva" size=1>5.60519e-045<br>
5.60519e-045<br>
5.60519e-045<br>
<br>
</font>tried converting to float before calculating weights, but same
result. Any suggestions anyone? realize per Craig's post that cluster
analysis isn't what IDL has been used most for...<br>
D<br>
<br>
</html>
Re: Re: Clsuter analysis wiht IDL [message #24061 is a reply to message #23847] Mon, 05 March 2001 00:26 Go to previous message
dw is currently offline  dw
Messages: 10
Registered: February 2001
Junior Member
<html>
<br>
Hi Gonzalo,<br>
<br>
you wrote:<br>
&lt;what is the difference between the obsolete IDL procedure
&quot;kmeans&quot; and the<br>
&lt;new &quot;cluster&quot; ?... In theory, with this procedures we get
the same results, but<br>
&lt;I tested it with the same input parameters (same image, quantity of
clusters,<br>
&lt;etc, etc), and we got different results...<br>
<br>
I haven't responded to your earlier post of this question because I don't
know the answer. In the last few days, I've managed to solve my problems
with the CLUSTER function by not using it! I've downloaded a program
written by Vincent Schmithorst called CCHIPS/IDL and there's a procedure
in this program package called ksegment.pro which I've modified and am
now using for my cluster analysis. And it works well!!<br>
<br>
CHIPS is Copyright 2001 by<br>
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; The Imaging
Research Center<br>
<x-tab> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp; </x-tab>Children's
Hospital Medical Center<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; 3333 Burnet Ave.
Suite R056<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; Cincinnati,
OH&nbsp; 45229<br>
and can be downloaded from their web site: <br>
<font color="#0000FF"><u>http://www.irc.chmcc.org<br>
<br>
</u></font>Good luck,<br>
Dorthe<br>
&nbsp;<br>
</html>
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: widget_control from call_external
Next Topic: Plotting values in a map.

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Wed Oct 08 19:14:20 PDT 2025

Total time taken to generate the page: 0.00714 seconds