Intercepting an ImageIO Factory Read to modify data in the buffer


(Gabriel A. Devenyi) #1

Continuing my work on the MINCIO code, I’ve realized that the coordinate system corrections I do to vectors in TransformMINC should really be happening right at file loading.

My current implementation is this code:

Which utilizes multithreaded ITK iterators.

Unfortunately, if I want to modify the incoming data off disk and into the buffers during Read, I think I can’t rely on such code anymore.

Looking at the NIFTIO it seems that a similar correction done regarding upper vs lower triangular for tensors here

Is this implementation a reasonable way to go? Allocate a local buffer, loop over it and modify the values and then copy the final results into the Read buffer?


(Dženan Zukić) #2

It is not the most efficient way, but many implementations do that when type casting is required. For example, the file on disk is ushort but the user code is requiring uchar. But the same read buffer can be re-used if the requested type is the same size as on-disk type. In that case, you would process the read buffer in-place.


(Gabriel A. Devenyi) #3

Ah great, thanks @dzenanz . I don’t have a need to convert types so I can work directly on the buffer. Now I’ll just need to figure how how step around it in the right order to touch only the values I’m interested in.