Fixed mismatch between coordinates indices (rather min/max values thereof)

This commit is contained in:
Martin committed 2025-01-11 13:26:05 +01:00
1 parent 4971d693fd
commit b151e70167
3 files changed
+27 -16

No files matched your search

+16 -8
View File
@@ -10,19 +10,27 @@ __device__ Vec3 computeGradient(float* volumeData, const int volW, const int vol
// Normal should point from higher to lower intensities
int xm = max(x - 1, 0);
int xp = min(x + 1, volW - 1);
int xp = min(x + 1, volH - 1);
int ym = max(y - 1, 0);
int yp = min(y + 1, volH - 1);
int yp = min(y + 1, volW - 1);
int zm = max(z - 1, 0);
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 ];
// 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
float gx = volumeData[z * volW * volH + x * volW + xp]
- volumeData[z * volW * volH + x * volW + xm];
float gy = volumeData[z * volW * volH + y * volW + yp]
- volumeData[z * volW * volH + y * volW + ym];
float gz = volumeData[zp * volW * volH + x * volW + y ]
- volumeData[zm * volW * volH + x * volW + y ];
return Vec3::init(gx, gy, gz);
};
Reference in new issue
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.