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

Home » Public Forums » archive » create oval shape
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
create oval shape [message #91737] Tue, 18 August 2015 09:41 Go to next message
g.nacarts is currently offline  g.nacarts
Messages: 148
Registered: November 2013
Senior Member
Hi

I want to create two oval shapes where the enclosed pixels have fixed values. I tried the following but are rectangles, as expected of course.

Im = fltarr(300,300)

A[19:68,40:115] = 2.
A[40:55,62:82] = 1.

Can anyone help with this? Instead of rectangles creating oval shapes with fixed values.
Re: create oval shape [message #91738 is a reply to message #91737] Tue, 18 August 2015 10:11 Go to previous messageGo to next message
Jeremy Bailin is currently offline  Jeremy Bailin
Messages: 618
Registered: April 2008
Senior Member
On Tuesday, August 18, 2015 at 11:41:13 AM UTC-5, g.na...@gmail.com wrote:
> Hi
>
> I want to create two oval shapes where the enclosed pixels have fixed values. I tried the following but are rectangles, as expected of course.
>
> Im = fltarr(300,300)
>
> A[19:68,40:115] = 2.
> A[40:55,62:82] = 1.
>
> Can anyone help with this? Instead of rectangles creating oval shapes with fixed values.

I would use DIST_ELLIPSE from the idl astronomy library to get the distances from the center of the ellipse to each point in the image, and then use that distance to decide whether to set it or not.

I.e. to fill in an ellipse with an axis ratio of 2:1 centered at (x_center, y_center) with a semi-major axis length of length "radius":

dist_ellipse, ellipse_distances, [300,300], x_center, y_center, 2.0
A = ellipse_distances le radius

-Jeremy.
Re: create oval shape [message #91739 is a reply to message #91738] Tue, 18 August 2015 11:35 Go to previous messageGo to next message
g.nacarts is currently offline  g.nacarts
Messages: 148
Registered: November 2013
Senior Member
I am using an old version of IDL and I can't use the DIST_ELLIPSE function
Re: create oval shape [message #91740 is a reply to message #91739] Tue, 18 August 2015 12:40 Go to previous messageGo to next message
wlandsman is currently offline  wlandsman
Messages: 743
Registered: June 2000
Senior Member
I am certain that having an old version of IDL has nothing to do with not being able to run the DIST_ELLIPSE function (it was written in 1992 and runs fine in IDL 5.0). But you do have to download it (it is not included with IDL).

http://idlastro.gsfc.nasa.gov/ftp/pro/image/dist_ellipse.pro

On Tuesday, August 18, 2015 at 2:35:20 PM UTC-4, g.na...@gmail.com wrote:
> I am using an old version of IDL and I can't use the DIST_ELLIPSE function
Re: create oval shape [message #91741 is a reply to message #91740] Tue, 18 August 2015 13:12 Go to previous messageGo to next message
g.nacarts is currently offline  g.nacarts
Messages: 148
Registered: November 2013
Senior Member
Yes yes, I've already found it. Thanks.
Re: create oval shape [message #91742 is a reply to message #91741] Tue, 18 August 2015 13:45 Go to previous messageGo to next message
g.nacarts is currently offline  g.nacarts
Messages: 148
Registered: November 2013
Senior Member
I didn't understand how to use the DIST_ELLIPSE though.

I typed
> IDL dist_ellipse, ellipse_distances, [300,300], x_center, y_center, 2.0

And I got the following:

Syntax - DIST_ELLIPSE, im, n, xc, yc, ratio, pos_ang, /DOUBLE
im - output elliptical mask image array
n - size of output image mask, scalar or 2 element vector
xc,yc - coordinates of ellipse center, scalars
ratio - ratio of major to minor axis of ellipse, scalar
pos_ang - position angle, counterclockwise from up

I didn't see how I'll get the distances from center using this function.
Re: create oval shape [message #91744 is a reply to message #91742] Tue, 18 August 2015 20:10 Go to previous message
Jeremy Bailin is currently offline  Jeremy Bailin
Messages: 618
Registered: April 2008
Senior Member
On Tuesday, August 18, 2015 at 3:45:46 PM UTC-5, g.na...@gmail.com wrote:
> I didn't understand how to use the DIST_ELLIPSE though.
>
> I typed
>> IDL dist_ellipse, ellipse_distances, [300,300], x_center, y_center, 2.0
>
> And I got the following:
>
> Syntax - DIST_ELLIPSE, im, n, xc, yc, ratio, pos_ang, /DOUBLE
> im - output elliptical mask image array
> n - size of output image mask, scalar or 2 element vector
> xc,yc - coordinates of ellipse center, scalars
> ratio - ratio of major to minor axis of ellipse, scalar
> pos_ang - position angle, counterclockwise from up
>
> I didn't see how I'll get the distances from center using this function.

It looks like the pos_ang parameter is required (Wayne: the documentation says it is optional), so use 0 for that to align the axes of the ellipse with the x and y axes.

What you will get after running it is a 300x300 array where the value of each element is the semi-major axis of the ellipse that goes through that element and is centered at (x_center, y_center).

-Jeremy.
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: calling C++ from within IDL
Next Topic: Apply a shapefile to raster images in IDL

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

Current Time: Wed Oct 08 13:31:45 PDT 2025

Total time taken to generate the page: 0.00466 seconds