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

Home » Public Forums » archive » 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
Clsuter analysis wiht IDL [message #23851] Fri, 23 February 2001 07:09 Go to next message
dw is currently offline  dw
Messages: 10
Registered: February 2001
Junior Member
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.

Has anybody worked on cluster analysis using IDL?

Thanks for any help!
Dorthe


--
Posted from mail.isva.dtu.dk [192.38.88.3]
via Mailgate.ORG Server - http://www.Mailgate.ORG
Re: Clsuter analysis wiht IDL [message #23936 is a reply to message #23851] Wed, 28 February 2001 09:09 Go to previous messageGo to next message
Benno Puetz is currently offline  Benno Puetz
Messages: 16
Registered: March 2000
Junior Member
Dorthe Wildenschild wrote:

> 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.

What you want is probably REFORM the image to (1,658x658), one variable
(intensity) and 432964 observations (pixels)

Using three clusters you will (likely) end up with one for background and two
for low and high intensities in the CT image, respectively, ...

> 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.

use something like

ref_img=REFORM(image,1,658*658)
weights = clust_wts(ref_img, n_clusters=3)
cls=cluster(ref_img,weights,n_cluster=3)
tvscl,reform(cls,658,658)

and you should have the clusters in different grays (or colors, depending on
your settings)

>
>
> Has anybody worked on cluster analysis using IDL?
>

Your question showed me that such a command exists in IDL ...

--
Benno Puetz
Kernspintomographie
Max-Planck-Institut f. Psychiatrie Tel.: +49-89-30622-413
Kraepelinstr. 10 Fax : +49-89-30622-520
80804 Muenchen, Germany
Re: Clsuter analysis wiht IDL [message #23979 is a reply to message #23851] Fri, 02 March 2001 09:45 Go to previous message
Gonzalo Rojas is currently offline  Gonzalo Rojas
Messages: 14
Registered: February 2001
Junior Member
Hi Dorthe:

what is the difference between the obsolete IDL procedure "kmeans" and the
new "cluster" ?... In theory, with this procedures we get the same results, but
I tested it with the same input parameters (same image, quantity of clusters,
etc, etc), and we got different results...

could you please send me the answers to my e-mail to, because I don't read
this newsgroup very often...

thanks in advance...

Gonzalo Rojas


Dorthe Wildenschild wrote:

> 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.
>
> Has anybody worked on cluster analysis using IDL?
>
> Thanks for any help!
> Dorthe
>
> --
> Posted from mail.isva.dtu.dk [192.38.88.3]
> via Mailgate.ORG Server - http://www.Mailgate.ORG
  • Attachment: grojasy.vcf
    (Size: 0.31KB, Downloaded 102 times)
Re: Clsuter analysis wiht IDL [message #24007 is a reply to message #23851] Thu, 01 March 2001 09:43 Go to previous message
Craig Markwardt is currently offline  Craig Markwardt
Messages: 1869
Registered: November 1996
Senior Member
dw@isva.dtu.dk (Dorthe Wildenschild) writes:

> --=====================_524776338==_.ALT
> Content-Type: text/plain; charset="us-ascii"; format=flowed
>
> <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
>
> I'm such a beginner at this I don't know what the MOD function does? (no
> on-line help listing for it)
> When trying to transpose, IDL corrects me with
> Arrays are allowed 1 - 8 dimensions

MOD is documented as the "modulo" function. You may have to scroll to
see the documentation entry in the index. Since WHERE "pretends" that
your array is 1-d, you have to reconstruct the x and y positions by
dividing by the number of columns, and taking the remainder (=x) and
quotient (=y).

Here is an example with some simulated data. The TRANSPOSE command
works as advertised. The GAUSS2 simply generates a 2-d gaussian
function, and is available from my web page
http://cow.physics.wisc.edu/~craigm/idl/idl.html

This script finds all three clusters successfully, but it shows that
the routine is not optimal since it doesn't find the cluster centers.

Would you consider conferring with Mr. Rojas on his question about
clusters and kmeans?

Craig


;; Simulate some data. Three clusters at (2,3), (-3,1), (1,-2)
x = findgen(100)*0.1 - 5. & y = x
xx = x # (y*0 + 1)
yy = (x*0 + 1) # y
z = 30 * gauss2(xx, yy, [2D, 3D, .2, 1]) + $
10 * gauss2(xx, yy, [-3D, 1D, .2, 1]) + $
20 * gauss2(xx, yy, [1D, -2D, .2D, 1])
zi = floor(z) ;; Convert to integer

;; Find the positions of significant data points
wh = where(z GT 5, ct)
if ct EQ 0 then message, 'ERROR: no signif points!'
xi = x(wh MOD 100)
yi = y(floor(wh/100))
xy = transpose([[xi],[yi]])
weights = clust_wts(xy, n_clusters=3)

plot, xi, yi, psym=3
oplot, weights(0,*), weights(1,*), psym=1, symsize=3


--
------------------------------------------------------------ --------------
Craig B. Markwardt, Ph.D. EMAIL: craigmnet@cow.physics.wisc.edu
Astrophysics, IDL, Finance, Derivatives | Remove "net" for better response
------------------------------------------------------------ --------------
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Communication between different widget bases
Next Topic: Re: JULDAY 5.4 not same as 5.3?

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

Current Time: Wed Oct 08 19:46:17 PDT 2025

Total time taken to generate the page: 0.00600 seconds