Fixed gradient
This commit is contained in:
parent
b151e70167
commit
3714389803
|
|
@ -7,7 +7,6 @@ using namespace std;
|
||||||
__device__ Vec3 computeGradient(float* volumeData, const int volW, const int volH, const int volD, int x, int y, int z) {
|
__device__ Vec3 computeGradient(float* volumeData, const int volW, const int volH, const int volD, int x, int y, int z) {
|
||||||
// Finite difference for partial derivatives.
|
// Finite difference for partial derivatives.
|
||||||
// For boundary voxels - clamp to the boundary.
|
// For boundary voxels - clamp to the boundary.
|
||||||
// Normal should point from higher to lower intensities
|
|
||||||
|
|
||||||
int xm = max(x - 1, 0);
|
int xm = max(x - 1, 0);
|
||||||
int xp = min(x + 1, volH - 1);
|
int xp = min(x + 1, volH - 1);
|
||||||
|
|
@ -16,19 +15,11 @@ __device__ Vec3 computeGradient(float* volumeData, const int volW, const int vol
|
||||||
int zm = max(z - 1, 0);
|
int zm = max(z - 1, 0);
|
||||||
int zp = min(z + 1, volD - 1);
|
int zp = min(z + 1, volD - 1);
|
||||||
|
|
||||||
// Note: Assuming data is linearized (idx = z*w*h + y*w + x) TODO: Unlinearize if data not linear
|
|
||||||
// float gx = volumeData[z * volW * volH + y * volW + xp]
|
|
||||||
// - volumeData[z * volW * volH + y * volW + xm];
|
|
||||||
// float gy = volumeData[z * volW * volH + yp * volW + x ]
|
|
||||||
// - volumeData[z * volW * volH + ym * volW + x ];
|
|
||||||
// float gz = volumeData[zp * volW * volH + y * volW + x ]
|
|
||||||
// - volumeData[zm * volW * volH + y * volW + x ];
|
|
||||||
|
|
||||||
// Note: Assuming data is linearized (idx = z * W * H + x * W + y;) TODO: Unlinearize if data not linear
|
// Note: Assuming data is linearized (idx = z * W * H + x * W + y;) TODO: Unlinearize if data not linear
|
||||||
float gx = volumeData[z * volW * volH + x * volW + xp]
|
float gx = volumeData[z * volW * volH + xp * volW + y]
|
||||||
- volumeData[z * volW * volH + x * volW + xm];
|
- volumeData[z * volW * volH + xm * volW + y];
|
||||||
float gy = volumeData[z * volW * volH + y * volW + yp]
|
float gy = volumeData[z * volW * volH + x * volW + yp]
|
||||||
- volumeData[z * volW * volH + y * volW + ym];
|
- volumeData[z * volW * volH + x * volW + ym];
|
||||||
float gz = volumeData[zp * volW * volH + x * volW + y ]
|
float gz = volumeData[zp * volW * volH + x * volW + y ]
|
||||||
- volumeData[zm * volW * volH + x * volW + y ];
|
- volumeData[zm * volW * volH + x * volW + y ];
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,7 @@
|
||||||
#define MAT_H
|
#define MAT_H
|
||||||
|
|
||||||
#include "vec.h"
|
#include "vec.h"
|
||||||
|
#include "consts.h"
|
||||||
|
|
||||||
__device__ Vec3 computeGradient(float* volumeData, const int volW, const int volH, const int volD, int x, int y, int z);
|
__device__ Vec3 computeGradient(float* volumeData, const int volW, const int volH, const int volD, int x, int y, int z);
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue