From c78b2ff4da257c3f0e5724491c6fbbbf5104c6b0 Mon Sep 17 00:00:00 2001 From: Jiaming Guo Date: Wed, 1 Mar 2017 17:48:25 -0600 Subject: [PATCH] add some function in order to get grid work --- stim/grids/image_stack.h | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/stim/grids/image_stack.h b/stim/grids/image_stack.h index e43d1c6..fdd0ebf 100644 --- a/stim/grids/image_stack.h +++ b/stim/grids/image_stack.h @@ -147,6 +147,7 @@ public: R[3] = depth; ptr = (T*)malloc(sizeof(T) * samples()); + memset(ptr, 0, sizeof(T) * samples()); } ///Saves the entire stack to a set of images @@ -170,12 +171,22 @@ public: /// Returns the world-space position at an index point (i, j, k) vec3 p(size_t i, size_t j, size_t k){ vec3 result; - result[0] = (F)i * S[0]; - result[1] = (F)j * S[1]; - result[2] = (F)j * S[2]; + result[0] = (F)i * S[1]; + result[1] = (F)j * S[2]; + result[2] = (F)k * S[3]; return result; } + // set the pixel at the specified point + void set(size_t i, size_t j, size_t k, T value, size_t c = 0){ + ptr[k * R[0] * R[1] * R[2] + j * R[0] * R[1] + i * R[0] + c] = value; + } + void set(T* Ptr, size_t k) { + + for (unsigned i = 0; i < R[0] * R[1] * R[2]; i++) + ptr[i + k * R[0] * R[1] * R[2]] = Ptr[i]; + } + void read(std::string file, unsigned int X, unsigned int Y, unsigned int Z, unsigned int C = 1, unsigned int header = 0){ read(file, stim::vec(C, X, Y, Z), header); } -- libgit2 0.21.4