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

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 close merge delete

Sort by ยป oldest newest most voted

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

more

And how to calculate gradient in arbitrary direction?

( 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))

( 2012-08-29 01:01:44 -0600 )edit