Again, renamed stuff for consistency's sake

This commit is contained in:
Martin Opat 2024-12-23 22:17:50 +01:00
parent 79d0587d97
commit 7fd6944f53
2 changed files with 11 additions and 11 deletions

View File

@ -1,24 +1,24 @@
#pragma once #pragma once
__device__ Vec3 computeGradient(float* volumeData, const int d_volumeWidth, const int d_volumeHeight, const int d_volumeDepth, 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 // 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, d_volumeWidth - 1); int xp = min(x + 1, volW - 1);
int ym = max(y - 1, 0); int ym = max(y - 1, 0);
int yp = min(y + 1, d_volumeHeight - 1); int yp = min(y + 1, volH - 1);
int zm = max(z - 1, 0); int zm = max(z - 1, 0);
int zp = min(z + 1, d_volumeDepth - 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 // Note: Assuming data is linearized (idx = z*w*h + y*w + x) TODO: Unlinearize if data not linear
float gx = volumeData[z * d_volumeWidth * d_volumeHeight + y * d_volumeWidth + xp] float gx = volumeData[z * volW * volH + y * volW + xp]
- volumeData[z * d_volumeWidth * d_volumeHeight + y * d_volumeWidth + xm]; - volumeData[z * volW * volH + y * volW + xm];
float gy = volumeData[z * d_volumeWidth * d_volumeHeight + yp * d_volumeWidth + x ] float gy = volumeData[z * volW * volH + yp * volW + x ]
- volumeData[z * d_volumeWidth * d_volumeHeight + ym * d_volumeWidth + x ]; - volumeData[z * volW * volH + ym * volW + x ];
float gz = volumeData[zp * d_volumeWidth * d_volumeHeight + y * d_volumeWidth + x ] float gz = volumeData[zp * volW * volH + y * volW + x ]
- volumeData[zm * d_volumeWidth * d_volumeHeight + y * d_volumeWidth + x ]; - volumeData[zm * volW * volH + y * volW + x ];
return Vec3(gx, gy, gz); return Vec3(gx, gy, gz);
} }

View File

@ -81,7 +81,7 @@ __host__ void generateVolume(float* volumeData, int volW, int volH, int volD) {
} }
// Samples the voxel nearest to the given coordinates. TODO: Can be re-used in other places // Samples the voxel nearest to the given coordinates. TODO: Can be re-used in other places
__device__ float sampleVolumeNearest(float* volumeData, int volW, int volH, int volD, int vx, int vy, int vz) { __device__ float sampleVolumeNearest(float* volumeData, const int volW, const int volH, const int volD, int vx, int vy, int vz) {
if (vx < 0) vx = 0; if (vx < 0) vx = 0;
if (vy < 0) vy = 0; if (vy < 0) vy = 0;
if (vz < 0) vz = 0; if (vz < 0) vz = 0;