Hi, I'm working on the v4 metrics. Currently they use and Image object to store virtual domain information, and to provide mapping methods such as TransformPhysicalPointToIndex(). But this isn't very safe because I don't allocate memory for the image in order to safe memory, and thus the user can cause a bad access by inappropriately accessing the image memory in some way.
I'd like to switch the virtual domain representation to use ImageBase. But it's complicated by the fact that the metrics iterate over the virtual domain in different ways (region iterator, random iterator and neighborhood iterator in different cases). In all cases the iteration is only performed to get virtual indecies, which are transformed into physical points in fixed and moving domains, and then transformed into indecies again to access valid memory in either fixed or moving data. 1) One option is to create new iterators that don't allow any image memory access. So for example a new class ImageRegionConstIteratorWithOnlyIndex. Mainly because the iterators rely on being templated over an itkImage (they need the pixel type), I think it's easisest and cleanest to create wrapper iterators for index-only access. Such a wrapper would contain a separate iterator (not be derived from it) and provide a limited interface that only allows memory-safe operations. Otherwise a parallel tree of index-only iterators would need to be created, which seems overly redundant. 2) Another option is a new VirtualImage type derived from ImageBase that has a pixel type to satisfy the iterators, but no memory and doesn't have memory-access mehtods like GetPixel. It'd be tricky to work with the current iterators w/out changing them in ways that would decrease efficiency, because they directly de-ref the image memory buffer. Maybe the iterator methods that directly or indirectly access memory could be template-specialized to have do-nothing methods when used with a VirtualImage type? Or they could throw an exception to alert the programmer. But generally a compile-time error would be better if the progammer tried to use the iterator incorreclty, which is what option 1 provides. Any thoughts or techniques I'm missing? Thanks. -M _______________________________________________ Powered by www.kitware.com Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html Kitware offers ITK Training Courses, for more information visit: http://kitware.com/products/protraining.php Please keep messages on-topic and check the ITK FAQ at: http://www.itk.org/Wiki/ITK_FAQ Follow this link to subscribe/unsubscribe: http://www.itk.org/mailman/listinfo/insight-developers
