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

Home » Public Forums » archive » Re: Calculate gradient
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
Re: Calculate gradient [message #70082] Sat, 13 March 2010 00:35
James[2] is currently offline  James[2]
Messages: 44
Registered: November 2009
Member
You could use the SOBEL operator. This convolves the image with
kernels like so:

-1 0 1 1 2 1
-2 0 2 0 0 0
-1 0 1 -1 -2 -1

to get approximations of the x and y gradient respectively. IDL's
built-in SOBEL routine returns the magnitude, i.e. the sum of the
absolute values of each of these convolutions. It would be simple to
make the kernels yourself and use CONVOL if you want to keep the x and
y gradients separate.

I don't know much about contour plotting in IDL, but the CONTOUR
function is probably a good place to start...



On Mar 12, 1:41 pm, mslarkin <enhlw...@gmail.com> wrote:
> Hi IDL experts,
> I have a 2-D array (2708x4060), containing reflectance data. Is it
> possible to calculate the reflectance gradient (i.e. the rate of
> reflectance change over distance or array grid) throughout the array,
> and then draw lines of equal gradient (note that they’re NOT contour
> lines)?
> Thank you very much for your help!
> IDL beginner
Re: Calculate gradient [message #70084 is a reply to message #70082] Fri, 12 March 2010 14:40 Go to previous message
R.G.Stockwell is currently offline  R.G.Stockwell
Messages: 163
Registered: October 2004
Senior Member
Perhaps it would be better to use Deriv() or something like that,
instead of differences.

cheers,
bob

>
> "Paolo" <pgrigis@gmail.com> wrote in message
> news:b7420af6-f104-4e00-968c-28afc378f8ac@g26g2000yqn.google groups.com...
> Hi,
>
> the simpler solution would be to use the "shift" function
> to calculate the dx and dy component of the gradient (whose
> norm is sqrt(dx^2+dy^2) - similarly to the one-dimensional
> case when you can compute the numerical derivative of x
> as (x-shift(x,-1))/dx.
>
> However you should be careful doing that with non-smooth
> datasets.
>
> Ciao,
> Paolo
>
>
>
> On Mar 12, 4:41 pm, mslarkin <enhlw...@gmail.com> wrote:
>> Hi IDL experts,
>> I have a 2-D array (2708x4060), containing reflectance data. Is it
>> possible to calculate the reflectance gradient (i.e. the rate of
>> reflectance change over distance or array grid) throughout the array,
>> and then draw lines of equal gradient (note that they�re NOT contour
>> lines)?
>> Thank you very much for your help!
>> IDL beginner
Re: Calculate gradient [message #70085 is a reply to message #70084] Fri, 12 March 2010 14:37 Go to previous message
pgrigis is currently offline  pgrigis
Messages: 436
Registered: September 2007
Senior Member
Hi,

the simpler solution would be to use the "shift" function
to calculate the dx and dy component of the gradient (whose
norm is sqrt(dx^2+dy^2) - similarly to the one-dimensional
case when you can compute the numerical derivative of x
as (x-shift(x,-1))/dx.

However you should be careful doing that with non-smooth
datasets.

Ciao,
Paolo



On Mar 12, 4:41 pm, mslarkin <enhlw...@gmail.com> wrote:
> Hi IDL experts,
> I have a 2-D array (2708x4060), containing reflectance data. Is it
> possible to calculate the reflectance gradient (i.e. the rate of
> reflectance change over distance or array grid) throughout the array,
> and then draw lines of equal gradient (note that they’re NOT contour
> lines)?
> Thank you very much for your help!
> IDL beginner
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Proper Map Label Clipping
Next Topic: rejecting a few pixel values from an array of pixel values

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

Current Time: Wed Oct 08 11:40:27 PDT 2025

Total time taken to generate the page: 0.20149 seconds