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

Home » Public Forums » archive » Re: Masking using user defined ROIs
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
Re: Masking using user defined ROIs [message #32682 is a reply to message #32681] Thu, 31 October 2002 08:22 Go to previous messageGo to previous message
j.dickson is currently offline  j.dickson
Messages: 2
Registered: October 2002
Junior Member
Thanks David, your code worked beautifully. Just to help me understand
the code a bit better, how would I change the code to mask everything
outside the roi to zero.

Regards

John Dickson


David Fanning <david@dfanning.com> wrote in message news:<MPG.18285cdf16be84119899f0@news.frii.com>...
> John Dickson (j.dickson@rfc.ucl.ac.uk) writes:
>
>> I have a 2D medical image which has several cold lesions. I want to
>> draw around each of these cold lesions and mask everything inside the
>> ROIs to be zero.
>>
>> As a self-taught IDL bod with limited experience, any example code
>> which will help me achieve my aim would be greatly appreciated.
>
> There are any number of ways to do this. Here is
> one way, using XROI to create your ROIs. You can
> draw your ROIs in several ways with this tool (for
> example, select the pencil tool for drawing freehand
> ROIs). When you are finished drawing, click the Quit
> button. The image mask will be calculated, and the
> masked image will be returned to you.
>
> IDL> TV, ExampleROIMask(image)
>
> Cheers,
>
> David
>
> --
> David W. Fanning, Ph.D.
> Fanning Software Consulting, Inc.
> Phone: 970-221-0438, E-mail: david@dfanning.com
> Coyote's Guide to IDL Programming: http://www.dfanning.com/
> Toll-Free IDL Book Orders: 1-888-461-0155
>
> ;*********************************************************** *******
> FUNCTION ExampleROIMask, image
>
>
> IF N_Elements(image) EQ 0 THEN BEGIN
>
> ; Get an image, if needed.
>
> filename = Filepath(Subdir=['examples','data'], 'mr_knee.dcm')
> image = Read_DICOM(filename)
> ENDIF
>
> ; Draw ROI's on image. (Use the freehand PENCIL tool, for example.)
>
> XROI, image, Regions_Out=rois, /Block
>
> ; Create an image mask from the ROIs you just created.
>
> dim = Size(image, /Dimensions)
> mask = BytArr(dim[0], dim[1]) + 1B
>
> ; Cycle through the ROIs.
>
> FOR j=0, N_Elements(rois)-1 DO BEGIN
> thisROI = rois[j]
> IF Obj_Valid(thisROI) THEN BEGIN
> thisROI -> GetProperty, Data=polygon
> indices = PolyFillV(polygon[0,*], polygon[1,*], dim[0], dim[1])
> IF indices[0] NE -1 THEN mask[indices] = 0
> Obj_Destroy, thisROI
> ENDIF
> ENDFOR
>
> ; Apply the mask to the image and return it.
>
> RETURN, image * mask
> END
> ;*********************************************************** *******
[Message index]
 
Read Message
Read Message
Read Message
Previous Topic: IDL dynamical widget resizing bugs under linux
Next Topic: Re: How to transfer variables between files

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

Current Time: Sat Oct 11 23:21:45 PDT 2025

Total time taken to generate the page: 0.48017 seconds