Re: IDL crashes using CONTAINSPOINTS (not any more) [message #29196] |
Thu, 07 February 2002 05:32 |
dw
Messages: 10 Registered: February 2001
|
Junior Member |
|
|
OK, with help from Dave Fannings website (as ussual) I've sorted out
my problem.
I had forgotten to destroy my objects and IDL responds by crashing (an
error message would be convenient.....)
D
dw@er.dtu.dk (Dorthe Wildenschild) wrote in message news:<3df19224.0202070132.3b3b23b2@posting.google.com>...
> Hi,
>
> I have a little bit of code that removes background around my
> cylindrical samples by setting the points outside a prescribed circle
> to a non-zero value (I have to do this to stop SEARCH2D from growing
> into the background), but I can only do it for an array of 16x16
> pixels (and need to go to 370x370). Once I let the indices go to 17x17
> or higher it crashes IDL. Any experiences like that out there?
>
> Cheers,
> Dorthe
>
>
> This is my code:
> ************************************
> FUNCTION CIRCLE, xcenter, ycenter, radius
> points = (2 * !PI / 99.0) * FINDGEN(100)
> x = xcenter + radius * COS(points )
> y = ycenter + radius * SIN(points )
> RETURN, TRANSPOSE([[x],[y]])
> END
>
> ;*********************************************************** *********************************
> ;*********************************************************** *********************************
>
> PRO Remove_background
>
> topColor = !D.N_COLORS-1
> LOADCT,0,NCOLORS=!D.N_COLORS-1
>
> ; Read volume file containing 3-D data set
>
>
> vol = read_tomo_volume
> ('d:\recon_volumes\May2001\8_20_I_segm.volume')
>
> ; Extract one 2-d slice
>
> image=vol[*,*,40]
>
> siz = SIZE(image)
> x = siz[1]
> y = siz[2]
>
> ; Remove 'background' outside sample circle
>
> bytimage = BYTSCL(image,min=0,max=10,TOP=topColor)
>
> WINDOW,1,/PIXMAP,XSIZE=x,YSIZE=y
> TV,bytimage
>
> Xcentre = 330
> Ycentre = 330
> Radius = 140
>
> circ_roi= CIRCLE(Xcentre,Ycentre,Radius)
> PLOTS, circ_roi[0,*], circ_roi[1,*],/DEVICE
>
> mask = image * 0
> area = POLYFILLV(circ_roi[0,*],circ_roi[1,*],x,y)
>
> mask[area] =1
> CircleImage = mask * image
> image_display, CircleImage
>
> ; Set pixels outside circle to non-zero value
>
> For i = 0,17 do begin
> For j = 0,17 do begin
>
> inside_circle=obj_new('IDLanROI',circ_roi)
> circleOK=inside_circle -> containspoints([i,j])
> print, 'circleok:', circleOK
>
> If circleok eq 0 then begin
> image[i,j]=30
> endif
>
> endfor
> endfor
>
> image_display, image
>
>
> END
|
|
|