Discussion:
[ITK-users] Casting Point to SizeType and vice versa
Jonas Teuwen
2017-05-27 07:34:04 UTC
Permalink
Hi all,

I want to extract patches around points using CropImageFilter. To do this,
I need to calculate the correct bounds.
The point itself is an itk::Point object, and then I calculate the
lower_crop and upper_crop. It can be possible these are negative in some
components, which is checked later on and compensated with
ConstantPadImageFilter.

So I need to switch between a Size and Point, which apparently cannot be
implicitly casted.
I am using a for loop to do this, but this is probably not the right way to
do it. So what is the proper way to do this in ITK?
I understand this question is probably very elementary, but your help would
be greatly appreciated.

itk::Size<3> image_size = image->GetBufferedRegion().GetSize();
std::cout << "Input size: " << image_size << std::endl;

* itk::Vector<double, 3> image_size2;*
* for(int i=0; i<3; ++i)*
* {*
* image_size2[i] = image_size[i];*
* }*


itk::Vector<double, 3> lower_crop = point - crop_size;
itk::Vector<double, 3> upper_crop = image_size2 - (point + crop_size) - 1;


Best,
Jonas Teuwen
Dženan Zukić
2017-05-29 12:47:03 UTC
Permalink
Hi Jonas,

what you probably need is TransformPhysicalPointToIndex
<https://itk.org/Doxygen/html/classitk_1_1ImageBase.html#af4a7c9c3787e9fdafbaaade2e02efa25>
method
or one of its friends.

Regards,
DÅŸenan Zukić, PhD, Senior R&D Engineer, Kitware (Carrboro, N.C.)
Post by Jonas Teuwen
Hi all,
I want to extract patches around points using CropImageFilter. To do this,
I need to calculate the correct bounds.
The point itself is an itk::Point object, and then I calculate the
lower_crop and upper_crop. It can be possible these are negative in some
components, which is checked later on and compensated with
ConstantPadImageFilter.
So I need to switch between a Size and Point, which apparently cannot be
implicitly casted.
I am using a for loop to do this, but this is probably not the right way
to do it. So what is the proper way to do this in ITK?
I understand this question is probably very elementary, but your help
would be greatly appreciated.
itk::Size<3> image_size = image->GetBufferedRegion().GetSize();
std::cout << "Input size: " << image_size << std::endl;
* itk::Vector<double, 3> image_size2;*
* for(int i=0; i<3; ++i)*
* {*
* image_size2[i] = image_size[i];*
* }*
itk::Vector<double, 3> lower_crop = point - crop_size;
itk::Vector<double, 3> upper_crop = image_size2 - (point + crop_size) - 1;
Best,
Jonas Teuwen
_____________________________________
Powered by www.kitware.com
Visit other Kitware open-source projects at
http://www.kitware.com/opensource/opensource.html
http://www.kitware.com/products/protraining.php
http://www.itk.org/Wiki/ITK_FAQ
http://public.kitware.com/mailman/listinfo/insight-users
Loading...