I havent used VTK in decades, so bear with me. It was a lot simpler C++ in the 90s! Or I am just too old!
Trying to read a series of BMP images into a volume and isosurface it. Somehow its seg faulting. So I want to look at the pixels in the individual BMP images. I can get the reader to work, but how do you go from the reader’s output to an ImageData object?
First, please, edit your post by encolsing your code between two ```, one above the first line and another after the last line. By doing this, you won’t have the templates (those tag-like thingies such as vtkSmartPointer<vtkStructureGrid>) trimmed. So we can better read your code.
But the first suspicious line in your code is a static cast of a smart pointer. Generally you don’t do or need that.
I suggest trying image->GetScalarComponentAsFloat( k, 0, 0, <number of component>). There is also GetScalarAsDouble(...) if you want to get the values as doubles.
GetScalarPointer() returns a void*. Thus, you have to know beforehand what is the underlying scalar type in the vtkImageData object. Perhaps casting it into int* is not an adequate cast. You could reverse back to using GetScalarPonter() and cast it to float* or double* and see which works instead of int*.
You could use GetScalarSize() to get the size of the scalar type in bytes. If it returns 4, scalars are float; 8 means double and 16 means long double.
Well, according to yourself the solution was actually given by me (6th post). It is important to give credit to the people that spend their free time helping you as a way to stimulate more people to help.
You’re quite welcome! Feel free to ask more questions. But keep in mind that answers in open source communities often don’t come so fast, or even don’t come at all. So, if your business depend on fast responses, please consider purchasing services from Kitware: https://vtk.org/services/.