Ask Your Question
1

formula of gradient direction

asked 2012-08-13 13:05:08 -0600

Papercut gravatar image

updated 2012-08-28 06:08:23 -0600

Kirill Kornyakov gravatar image

Hi I have found a good paper about Upsampling and been trying to understand formula in the paper. Here's a part of it.

image description

Based on the formula in the screen shot,

I have wrote some c++ codes but I am not sure it is right. Would you guys please tell me if I doing in right way? And Please give me some tips about getting Px..

double Ix, Iy, dI, Nx, Px, t;
t = 3;
Ix = getValueAt(&imageBGR, x+1, y, 0) - getValueAt(&imageBGR, x-1, y, 0);
Iy = getValueAt(&imageBGR, x, y+1, 0) - getValueAt(&imageBGR, x, y-1, 0);
if(Ix == 0) Ix = 0.001;
dI = Iy/Ix;

Nx = sqrt( (Ix*Ix) + (Iy*Iy) );
Px = ??
edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
2

answered 2012-08-13 14:02:49 -0600

Michael Burdinov gravatar image

updated 2012-08-13 14:03:55 -0600

This is the most common way to calculate gradient and its direction (although not the only one, there plenty of others).

edit flag offensive delete link more

Comments

And how to calculate gradient in arbitrary direction?

mrgloom gravatar imagemrgloom ( 2012-08-28 06:17:15 -0600 )edit

Calculate direction and magnitude of gradient and then calculate its projection to direction you need. It should be magnitude*square(cos(angle_between_directions))

Michael Burdinov gravatar imageMichael Burdinov ( 2012-08-29 01:01:44 -0600 )edit

Question Tools

Stats

Asked: 2012-08-13 13:05:08 -0600

Seen: 1,340 times

Last updated: Aug 28 '12