Re: Clsuter analysis wiht IDL [message #23847] |
Fri, 23 February 2001 08:20  |
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   |
dw
Messages: 10 Registered: February 2001
|
Junior Member |
|
|
<html>
<Craig writes:<br>
<br>
<I am by no means a statistics or clusters analysis expert, but
from<br>
<looking at the documentation it seems that both CLUST_WTS and
CLUSTER<br>
<require the n-dimensional *positions* of the data points, and not
an<br>
<intensity map. It is pretty clear that the cluster functions
are<br>
<based on an unweighted set of scatter-points. If you want to
use your<br>
<intensity information as a weighting, you may be out of luck.<br>
<br>
<Perhaps you could achieve what you desire with this code, which
simply<br>
<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 ; 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>
<I haven't tried this, so it may take some tweaking. Good
luck,<br>
<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   |
dw
Messages: 10 Registered: February 2001
|
Junior Member |
|
|
<html>
Benno,<br>
<br>
Thanks for the input.<br>
You suggested:<br>
<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  |
dw
Messages: 10 Registered: February 2001
|
Junior Member |
|
|
<html>
<br>
Hi Gonzalo,<br>
<br>
you wrote:<br>
<what is the difference between the obsolete IDL procedure
"kmeans" and the<br>
<new "cluster" ?... In theory, with this procedures we get
the same results, but<br>
<I tested it with the same input parameters (same image, quantity of
clusters,<br>
<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>
The Imaging
Research Center<br>
<x-tab> </x-tab>Children's
Hospital Medical Center<br>
3333 Burnet Ave.
Suite R056<br>
Cincinnati,
OH 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>
<br>
</html>
|
|
|