I am a new ITK user. I have to read a .nrrd file into C++ and then calculate the gradient of the values using C++. I was able to read the .nrrd file based on the following code:
Hello @keyurs19, and welcome into the ITK community!
As you are new to ITK, I strongly recommend that you take a quick look at the ITK Software Guide. This will give you an insight about how processing is done.
Usually for basic processing like gradient, ITK use the concept of filter to which you connect your image to get the expected output, and you combine further filters to do a pipeline. Thus you don’t need to manipulate the buffer of pixels values.
See this example for instance.
HTH,
Edit: Nonetheless, should you access the pixel values, there are multiple ways, by pointer to buffer (GetBufferPointer static method), by direct access (GetPixel method), or by using image iterators (refer to software guide)
Thank you for your prompt reply. For my application, I have to compute the gradient in each x,y and z directions. Would you know if there’s a specific way to do that using the concept of filter in ITK?
I also tried exploring the GetPixel method as per your suggestion. I tried accessing a specific pixel and tried to display its intensity, but was not really able to see value in the output window. Here’s the code that I used: