Discussion:
[ITK-users] Rotating image results in last slices being half empty
Matias
2017-04-08 22:08:22 UTC
Permalink
Hi,I'm rotating a volume (Using the Euler3DTransform) and the final set of
slices are half black or empty.here's an example when rotating a volume of
10 slices:Am I missing something such as changing the origin or maybe
computing the center incorrectly? (The center is passed as parameter from
another program) <Loading Image...>
And here's the code I'm using: typedef itk::ResampleImageFilter<ImageType,
ImageType> FilterType; FilterType::Pointer FiltroResample =
FilterType::New(); FiltroResample->SetInput(reader->GetOutput()); typedef
itk::LinearInterpolateImageFunction<ImageType, double > InterpolatorType;
InterpolatorType::Pointer interpolator = InterpolatorType::New();
FiltroResample->SetInterpolator(interpolator);
FiltroResample->SetOutputDirection(inputImage->GetDirection());
FiltroResample->SetOutputOrigin(inputImage->GetOrigin());
ImageType::SizeType inputSize =
inputImage->GetLargestPossibleRegion().GetSize();
FiltroResample->SetSize(inputSize); const ImageType::SpacingType&
inputSpacing = inputImage->GetSpacing();
FiltroResample->SetOutputSpacing(inputSpacing);
FiltroResample->SetDefaultPixelValue(-1000); typedef itk::Euler3DTransform<
double > TransformType; //Transform TransformType::Pointer transform =
TransformType::New(); double alfa, beta, gamma, centro_rotacion_X,
centro_rotacion_Y, centro_rotacion_Z, origenX,origenY; gamma =
atof(argv[2]); beta = atof(argv[3]); alfa = atof(argv[4]);
centro_rotacion_X = atof(argv[5]); centro_rotacion_Y = atof(argv[6]);
centro_rotacion_Z = atof(argv[7]); origenX = atof(argv[8]); origenY =
atof(argv[9]); transform->SetRotation(gamma, beta, alfa); double centro[3]
= { centro_rotacion_X, centro_rotacion_Y, centro_rotacion_Z };
transform->SetCenter(centro);
FiltroResample->SetTransform(transform); FiltroResample->Update();



--
View this message in context: http://itk-users.7.n7.nabble.com/Rotating-image-results-in-last-slices-being-half-empty-tp38081.html
Sent from the ITK - Users mailing list archive at Nabble.com.
Dženan Zukić
2017-04-13 15:13:32 UTC
Permalink
Hi Matias,

you are not using origenX or origenY after they are defined. But your
program (with modifications to make it compile) works for me:
[image: Inline image 1]

Regards,
DÅŸenan Zukić, PhD, Senior R&D Engineer, Kitware (Carrboro, N.C.)
Hi, I'm rotating a volume (Using the Euler3DTransform) and the final set
of slices are half black or empty. here's an example when rotating a volume
of 10 slices: Am I missing something such as changing the origin or maybe
computing the center incorrectly? (The center is passed as parameter from
another program) And here's the code I'm using: typedef
itk::ResampleImageFilter<ImageType, ImageType> FilterType;
FilterType::Pointer FiltroResample = FilterType::New();
LinearInterpolateImageFunction<ImageType, double > InterpolatorType;
InterpolatorType::Pointer interpolator = InterpolatorType::New();
FiltroResample->SetInterpolator(interpolator); FiltroResample->
SetOutputDirection(inputImage->GetDirection()); FiltroResample->
SetOutputOrigin(inputImage->GetOrigin()); ImageType::SizeType inputSize =
inputImage->GetLargestPossibleRegion().GetSize(); FiltroResample->SetSize(inputSize);
const ImageType::SpacingType& inputSpacing = inputImage->GetSpacing();
FiltroResample->SetOutputSpacing(inputSpacing); FiltroResample->SetDefaultPixelValue(-1000);
typedef itk::Euler3DTransform< double > TransformType; //Transform
TransformType::Pointer transform = TransformType::New(); double alfa, beta,
gamma, centro_rotacion_X, centro_rotacion_Y, centro_rotacion_Z,
origenX,origenY; gamma = atof(argv[2]); beta = atof(argv[3]); alfa =
atof(argv[4]); centro_rotacion_X = atof(argv[5]); centro_rotacion_Y =
atof(argv[6]); centro_rotacion_Z = atof(argv[7]); origenX = atof(argv[8]);
origenY = atof(argv[9]); transform->SetRotation(gamma, beta, alfa); double
centro[3] = { centro_rotacion_X, centro_rotacion_Y, centro_rotacion_Z };
transform->SetCenter(centro); FiltroResample->SetTransform(transform);
FiltroResample->Update();
------------------------------
View this message in context: Rotating image results in last slices being
half empty
<http://itk-users.7.n7.nabble.com/Rotating-image-results-in-last-slices-being-half-empty-tp38081.html>
Sent from the ITK - Users mailing list archive
<http://itk-users.7.n7.nabble.com/> at Nabble.com.
_____________________________________
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
Matias
2017-04-14 16:26:37 UTC
Permalink
Thanks Dzenan. I actually use OrigenX and OrigenY to assign it to the DCM
tags. Just curious, how did you compile to use with Slicer?

El jue., 13 de abr. de 2017 a la(s) 12:14, DÅŸenan Zukić [via ITK - Users] <
Post by Dženan Zukić
Hi Matias,
you are not using origenX or origenY after they are defined. But your
[image: Inline image 1]
Regards,
DÅŸenan Zukić, PhD, Senior R&D Engineer, Kitware (Carrboro, N.C.)
On Sat, Apr 8, 2017 at 6:08 PM, Matias <[hidden email]
Hi, I'm rotating a volume (Using the Euler3DTransform) and the final set
of slices are half black or empty. here's an example when rotating a volume
of 10 slices: Am I missing something such as changing the origin or maybe
computing the center incorrectly? (The center is passed as parameter from
another program) And here's the code I'm using: typedef
itk::ResampleImageFilter<ImageType, ImageType> FilterType;
FilterType::Pointer FiltroResample = FilterType::New();
FiltroResample->SetInput(reader->GetOutput()); typedef
itk::LinearInterpolateImageFunction<ImageType, double > InterpolatorType;
InterpolatorType::Pointer interpolator = InterpolatorType::New();
FiltroResample->SetInterpolator(interpolator);
FiltroResample->SetOutputDirection(inputImage->GetDirection());
FiltroResample->SetOutputOrigin(inputImage->GetOrigin());
ImageType::SizeType inputSize =
inputImage->GetLargestPossibleRegion().GetSize();
FiltroResample->SetSize(inputSize); const ImageType::SpacingType&
inputSpacing = inputImage->GetSpacing();
FiltroResample->SetOutputSpacing(inputSpacing);
FiltroResample->SetDefaultPixelValue(-1000); typedef itk::Euler3DTransform<
double > TransformType; //Transform TransformType::Pointer transform =
TransformType::New(); double alfa, beta, gamma, centro_rotacion_X,
centro_rotacion_Y, centro_rotacion_Z, origenX,origenY; gamma =
atof(argv[2]); beta = atof(argv[3]); alfa = atof(argv[4]);
centro_rotacion_X = atof(argv[5]); centro_rotacion_Y = atof(argv[6]);
centro_rotacion_Z = atof(argv[7]); origenX = atof(argv[8]); origenY =
atof(argv[9]); transform->SetRotation(gamma, beta, alfa); double centro[3]
= { centro_rotacion_X, centro_rotacion_Y, centro_rotacion_Z };
transform->SetCenter(centro); FiltroResample->SetTransform(transform);
FiltroResample->Update();
------------------------------
View this message in context: Rotating image results in last slices
being half empty
<http://itk-users.7.n7.nabble.com/Rotating-image-results-in-last-slices-being-half-empty-tp38081.html>
Sent from the ITK - Users mailing list archive
<http://itk-users.7.n7.nabble.com/> at Nabble.com.
_____________________________________
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
_____________________________________
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
------------------------------
If you reply to this email, your message will be added to the discussion
http://itk-users.7.n7.nabble.com/Rotating-image-results-in-last-slices-being-half-empty-tp38081p38116.html
To unsubscribe from Rotating image results in last slices being half
empty, click here
<http://itk-users.7.n7.nabble.com/template/NamlServlet.jtp?macro=unsubscribe_by_code&node=38081&code=bWF0aW1vbnRnQGdtYWlsLmNvbXwzODA4MXwtMTk0NzIxNTA4Mw==>
.
NAML
<http://itk-users.7.n7.nabble.com/template/NamlServlet.jtp?macro=macro_viewer&id=instant_html%21nabble%3Aemail.naml&base=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespace&breadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml>
--
Matias




--
View this message in context: http://itk-users.7.n7.nabble.com/Rotating-image-results-in-last-slices-being-half-empty-tp38081p38121.html
Sent from the ITK - Users mailing list archive at Nabble.com.
Dženan Zukić
2017-04-14 17:15:49 UTC
Permalink
Hi Matias,

I didn't compile to use with Slicer. I only open the input and output image
in Slicer to visualize them.

But making a Slicer CLI module is fairly easy. You can take a look at one
<https://github.com/Slicer/Slicer/tree/master/Modules/CLI/AddScalarVolumes/>
of the existing modules, docs
<https://www.slicer.org/wiki/Documentation/Nightly/Developers/Modules>
including
extension wizard
<https://www.slicer.org/wiki/Documentation/Nightly/Developers/ExtensionWizard>
.

Regards,
DÅŸenan Zukić, PhD, Senior R&D Engineer, Kitware (Carrboro, N.C.)
Post by Matias
Thanks Dzenan. I actually use OrigenX and OrigenY to assign it to the DCM
tags. Just curious, how did you compile to use with Slicer?
El jue., 13 de abr. de 2017 a la(s) 12:14, DÅŸenan Zukić [via ITK - Users] <[hidden
Post by Dženan Zukić
Hi Matias,
you are not using origenX or origenY after they are defined. But your
[image: Inline image 1]
Regards,
DÅŸenan Zukić, PhD, Senior R&D Engineer, Kitware (Carrboro, N.C.)
On Sat, Apr 8, 2017 at 6:08 PM, Matias <[hidden email]
Hi, I'm rotating a volume (Using the Euler3DTransform) and the final set
of slices are half black or empty. here's an example when rotating a volume
of 10 slices: Am I missing something such as changing the origin or maybe
computing the center incorrectly? (The center is passed as parameter from
another program) And here's the code I'm using: typedef
itk::ResampleImageFilter<ImageType, ImageType> FilterType;
FilterType::Pointer FiltroResample = FilterType::New();
LinearInterpolateImageFunction<ImageType, double > InterpolatorType;
InterpolatorType::Pointer interpolator = InterpolatorType::New();
FiltroResample->SetInterpolator(interpolator); FiltroResample->
SetOutputDirection(inputImage->GetDirection()); FiltroResample->
SetOutputOrigin(inputImage->GetOrigin()); ImageType::SizeType inputSize
= inputImage->GetLargestPossibleRegion().GetSize();
FiltroResample->SetSize(inputSize); const ImageType::SpacingType&
inputSpacing = inputImage->GetSpacing(); FiltroResample->
SetOutputSpacing(inputSpacing); FiltroResample->SetDefaultPixelValue(-1000);
typedef itk::Euler3DTransform< double > TransformType; //Transform
TransformType::Pointer transform = TransformType::New(); double alfa, beta,
gamma, centro_rotacion_X, centro_rotacion_Y, centro_rotacion_Z,
origenX,origenY; gamma = atof(argv[2]); beta = atof(argv[3]); alfa =
atof(argv[4]); centro_rotacion_X = atof(argv[5]); centro_rotacion_Y =
atof(argv[6]); centro_rotacion_Z = atof(argv[7]); origenX = atof(argv[8]);
origenY = atof(argv[9]); transform->SetRotation(gamma, beta, alfa); double
centro[3] = { centro_rotacion_X, centro_rotacion_Y, centro_rotacion_Z };
transform->SetCenter(centro); FiltroResample->SetTransform(transform);
FiltroResample->Update();
------------------------------
View this message in context: Rotating image results in last slices
being half empty
<http://itk-users.7.n7.nabble.com/Rotating-image-results-in-last-slices-being-half-empty-tp38081.html>
Sent from the ITK - Users mailing list archive
<http://itk-users.7.n7.nabble.com/> at Nabble.com.
_____________________________________
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
_____________________________________
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
------------------------------
If you reply to this email, your message will be added to the discussion
http://itk-users.7.n7.nabble.com/Rotating-image-results-in-
last-slices-being-half-empty-tp38081p38116.html
To unsubscribe from Rotating image results in last slices being half
empty, click here.
NAML
<http://itk-users.7.n7.nabble.com/template/NamlServlet.jtp?macro=macro_viewer&id=instant_html%21nabble%3Aemail.naml&base=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespace&breadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml>
--
Matias
------------------------------
View this message in context: Re: [ITK-users] Rotating image results in
last slices being half empty
<http://itk-users.7.n7.nabble.com/Rotating-image-results-in-last-slices-being-half-empty-tp38081p38121.html>
Sent from the ITK - Users mailing list archive
<http://itk-users.7.n7.nabble.com/> at Nabble.com.
_____________________________________
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
Dženan Zukić
2017-04-14 17:16:53 UTC
Permalink
Here is the code I used:

#include <itkImageFileReader.h>
#include <itkImageFileWriter.h>
#include <itkResampleImageFilter.h>
#include <itkEuler3DTransform.h>

template< typename TImage >
itk::SmartPointer<TImage> ReadImage(const char *filename)
{
typedef itk::ImageFileReader<TImage> ReaderType;
typename ReaderType::Pointer r = ReaderType::New();
r->SetFileName(filename);
r->Update();
return r->GetOutput();
}

template< typename TImage >
void WriteImage(itk::SmartPointer<TImage> out, const char *filename)
{
typedef itk::ImageFileWriter<TImage> WriterType;
typename WriterType::Pointer w = WriterType::New();
w->SetInput(out);
w->SetFileName(filename);
//w->SetUseCompression(true);
w->Update();
}

int main(int argc, char *argv[])
{
const unsigned int dimension = 3;
typedef itk::Image<short, dimension> ImageType;
ImageType::Pointer inputImage = ReadImage<ImageType>("C:/CBCT.nrrd");

typedef itk::ResampleImageFilter<ImageType, ImageType> FilterType;
FilterType::Pointer FiltroResample = FilterType::New();
FiltroResample->SetInput(inputImage);
typedef itk::LinearInterpolateImageFunction<ImageType, double>
InterpolatorType;
InterpolatorType::Pointer interpolator = InterpolatorType::New();
FiltroResample->SetInterpolator(interpolator);
FiltroResample->SetOutputDirection(inputImage->GetDirection());
FiltroResample->SetOutputOrigin(inputImage->GetOrigin());
ImageType::SizeType inputSize =
inputImage->GetLargestPossibleRegion().GetSize();
FiltroResample->SetSize(inputSize);
const ImageType::SpacingType& inputSpacing = inputImage->GetSpacing();
FiltroResample->SetOutputSpacing(inputSpacing);
FiltroResample->SetDefaultPixelValue(-1000);
typedef itk::Euler3DTransform<double> TransformType;
TransformType::Pointer transform = TransformType::New();
transform->SetRotation(0.2, 0.3, 0.5);
double centro[3] = { 10,20,30 };
transform->SetCenter(centro);
FiltroResample->SetTransform(transform);
FiltroResample->Update();
WriteImage<ImageType>(FiltroResample->GetOutput(),
"C:/cbctResampled.nrrd");
}
Post by Dženan Zukić
Hi Matias,
I didn't compile to use with Slicer. I only open the input and output
image in Slicer to visualize them.
But making a Slicer CLI module is fairly easy. You can take a look at one
<https://github.com/Slicer/Slicer/tree/master/Modules/CLI/AddScalarVolumes/>
of the existing modules, docs
<https://www.slicer.org/wiki/Documentation/Nightly/Developers/Modules> including
extension wizard
<https://www.slicer.org/wiki/Documentation/Nightly/Developers/ExtensionWizard>
.
Regards,
DÅŸenan Zukić, PhD, Senior R&D Engineer, Kitware (Carrboro, N.C.)
Post by Matias
Thanks Dzenan. I actually use OrigenX and OrigenY to assign it to the DCM
tags. Just curious, how did you compile to use with Slicer?
El jue., 13 de abr. de 2017 a la(s) 12:14, DÅŸenan Zukić [via ITK - Users]
<[hidden email] <http:///user/SendEmail.jtp?type=node&node=38121&i=0>>
Post by Dženan Zukić
Hi Matias,
you are not using origenX or origenY after they are defined. But your
[image: Inline image 1]
Regards,
DÅŸenan Zukić, PhD, Senior R&D Engineer, Kitware (Carrboro, N.C.)
On Sat, Apr 8, 2017 at 6:08 PM, Matias <[hidden email]
Hi, I'm rotating a volume (Using the Euler3DTransform) and the final set
of slices are half black or empty. here's an example when rotating a volume
of 10 slices: Am I missing something such as changing the origin or maybe
computing the center incorrectly? (The center is passed as parameter from
another program) And here's the code I'm using: typedef
itk::ResampleImageFilter<ImageType, ImageType> FilterType;
FilterType::Pointer FiltroResample = FilterType::New();
FiltroResample->SetInput(reader->GetOutput()); typedef
itk::LinearInterpolateImageFunction<ImageType, double >
InterpolatorType; InterpolatorType::Pointer interpolator =
InterpolatorType::New(); FiltroResample->SetInterpolator(interpolator);
FiltroResample->SetOutputDirection(inputImage->GetDirection());
FiltroResample->SetOutputOrigin(inputImage->GetOrigin());
ImageType::SizeType inputSize = inputImage->GetLargestPossibleRegion().GetSize();
FiltroResample->SetSize(inputSize); const ImageType::SpacingType&
inputSpacing = inputImage->GetSpacing(); FiltroResample->SetOutputSpacing(inputSpacing);
FiltroResample->SetDefaultPixelValue(-1000); typedef
itk::Euler3DTransform< double > TransformType; //Transform
TransformType::Pointer transform = TransformType::New(); double alfa, beta,
gamma, centro_rotacion_X, centro_rotacion_Y, centro_rotacion_Z,
origenX,origenY; gamma = atof(argv[2]); beta = atof(argv[3]); alfa =
atof(argv[4]); centro_rotacion_X = atof(argv[5]); centro_rotacion_Y =
atof(argv[6]); centro_rotacion_Z = atof(argv[7]); origenX = atof(argv[8]);
origenY = atof(argv[9]); transform->SetRotation(gamma, beta, alfa); double
centro[3] = { centro_rotacion_X, centro_rotacion_Y, centro_rotacion_Z };
transform->SetCenter(centro); FiltroResample->SetTransform(transform);
FiltroResample->Update();
------------------------------
View this message in context: Rotating image results in last slices
being half empty
<http://itk-users.7.n7.nabble.com/Rotating-image-results-in-last-slices-being-half-empty-tp38081.html>
Sent from the ITK - Users mailing list archive
<http://itk-users.7.n7.nabble.com/> at Nabble.com.
_____________________________________
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
_____________________________________
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
------------------------------
If you reply to this email, your message will be added to the discussion
http://itk-users.7.n7.nabble.com/Rotating-image-results-in-l
ast-slices-being-half-empty-tp38081p38116.html
To unsubscribe from Rotating image results in last slices being half
empty, click here.
NAML
<http://itk-users.7.n7.nabble.com/template/NamlServlet.jtp?macro=macro_viewer&id=instant_html%21nabble%3Aemail.naml&base=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespace&breadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml>
--
Matias
------------------------------
View this message in context: Re: [ITK-users] Rotating image results in
last slices being half empty
<http://itk-users.7.n7.nabble.com/Rotating-image-results-in-last-slices-being-half-empty-tp38081p38121.html>
Sent from the ITK - Users mailing list archive
<http://itk-users.7.n7.nabble.com/> at Nabble.com.
_____________________________________
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
Matias Montroull
2017-04-15 14:27:45 UTC
Permalink
Dzenan,
The center of rotation is set to use milimeters or image coordinates?
Thanks

Matias
Post by Dženan Zukić
#include <itkImageFileReader.h>
#include <itkImageFileWriter.h>
#include <itkResampleImageFilter.h>
#include <itkEuler3DTransform.h>
template< typename TImage >
itk::SmartPointer<TImage> ReadImage(const char *filename)
{
typedef itk::ImageFileReader<TImage> ReaderType;
typename ReaderType::Pointer r = ReaderType::New();
r->SetFileName(filename);
r->Update();
return r->GetOutput();
}
template< typename TImage >
void WriteImage(itk::SmartPointer<TImage> out, const char *filename)
{
typedef itk::ImageFileWriter<TImage> WriterType;
typename WriterType::Pointer w = WriterType::New();
w->SetInput(out);
w->SetFileName(filename);
//w->SetUseCompression(true);
w->Update();
}
int main(int argc, char *argv[])
{
const unsigned int dimension = 3;
typedef itk::Image<short, dimension> ImageType;
ImageType::Pointer inputImage = ReadImage<ImageType>("C:/CBCT.nrrd");
typedef itk::ResampleImageFilter<ImageType, ImageType> FilterType;
FilterType::Pointer FiltroResample = FilterType::New();
FiltroResample->SetInput(inputImage);
typedef itk::LinearInterpolateImageFunction<ImageType, double>
InterpolatorType;
InterpolatorType::Pointer interpolator = InterpolatorType::New();
FiltroResample->SetInterpolator(interpolator);
FiltroResample->SetOutputDirection(inputImage->GetDirection());
FiltroResample->SetOutputOrigin(inputImage->GetOrigin());
ImageType::SizeType inputSize = inputImage->
GetLargestPossibleRegion().GetSize();
FiltroResample->SetSize(inputSize);
const ImageType::SpacingType& inputSpacing = inputImage->GetSpacing();
FiltroResample->SetOutputSpacing(inputSpacing);
FiltroResample->SetDefaultPixelValue(-1000);
typedef itk::Euler3DTransform<double> TransformType;
TransformType::Pointer transform = TransformType::New();
transform->SetRotation(0.2, 0.3, 0.5);
double centro[3] = { 10,20,30 };
transform->SetCenter(centro);
FiltroResample->SetTransform(transform);
FiltroResample->Update();
WriteImage<ImageType>(FiltroResample->GetOutput(),
"C:/cbctResampled.nrrd");
}
Post by Dženan Zukić
Hi Matias,
I didn't compile to use with Slicer. I only open the input and output
image in Slicer to visualize them.
But making a Slicer CLI module is fairly easy. You can take a look at one
<https://github.com/Slicer/Slicer/tree/master/Modules/CLI/AddScalarVolumes/>
of the existing modules, docs
<https://www.slicer.org/wiki/Documentation/Nightly/Developers/Modules> including
extension wizard
<https://www.slicer.org/wiki/Documentation/Nightly/Developers/ExtensionWizard>
.
Regards,
DÅŸenan Zukić, PhD, Senior R&D Engineer, Kitware (Carrboro, N.C.)
Post by Matias
Thanks Dzenan. I actually use OrigenX and OrigenY to assign it to the
DCM tags. Just curious, how did you compile to use with Slicer?
El jue., 13 de abr. de 2017 a la(s) 12:14, DÅŸenan Zukić [via ITK -
Users] <[hidden email]
Post by Dženan Zukić
Hi Matias,
you are not using origenX or origenY after they are defined. But your
[image: Inline image 1]
Regards,
DÅŸenan Zukić, PhD, Senior R&D Engineer, Kitware (Carrboro, N.C.)
On Sat, Apr 8, 2017 at 6:08 PM, Matias <[hidden email]
Hi, I'm rotating a volume (Using the Euler3DTransform) and the final
set of slices are half black or empty. here's an example when rotating a
volume of 10 slices: Am I missing something such as changing the origin or
maybe computing the center incorrectly? (The center is passed as parameter
from another program) And here's the code I'm using: typedef
itk::ResampleImageFilter<ImageType, ImageType> FilterType;
FilterType::Pointer FiltroResample = FilterType::New();
FiltroResample->SetInput(reader->GetOutput()); typedef
itk::LinearInterpolateImageFunction<ImageType, double >
InterpolatorType; InterpolatorType::Pointer interpolator =
InterpolatorType::New(); FiltroResample->SetInterpolator(interpolator);
FiltroResample->SetOutputDirection(inputImage->GetDirection());
FiltroResample->SetOutputOrigin(inputImage->GetOrigin());
ImageType::SizeType inputSize = inputImage->GetLargestPossibleRegion().GetSize();
FiltroResample->SetSize(inputSize); const ImageType::SpacingType&
inputSpacing = inputImage->GetSpacing(); FiltroResample->SetOutputSpacing(inputSpacing);
FiltroResample->SetDefaultPixelValue(-1000); typedef
itk::Euler3DTransform< double > TransformType; //Transform
TransformType::Pointer transform = TransformType::New(); double alfa, beta,
gamma, centro_rotacion_X, centro_rotacion_Y, centro_rotacion_Z,
origenX,origenY; gamma = atof(argv[2]); beta = atof(argv[3]); alfa =
atof(argv[4]); centro_rotacion_X = atof(argv[5]); centro_rotacion_Y =
atof(argv[6]); centro_rotacion_Z = atof(argv[7]); origenX = atof(argv[8]);
origenY = atof(argv[9]); transform->SetRotation(gamma, beta, alfa); double
centro[3] = { centro_rotacion_X, centro_rotacion_Y, centro_rotacion_Z };
transform->SetCenter(centro); FiltroResample->SetTransform(transform);
FiltroResample->Update();
------------------------------
View this message in context: Rotating image results in last slices
being half empty
<http://itk-users.7.n7.nabble.com/Rotating-image-results-in-last-slices-being-half-empty-tp38081.html>
Sent from the ITK - Users mailing list archive
<http://itk-users.7.n7.nabble.com/> at Nabble.com.
_____________________________________
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
_____________________________________
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
------------------------------
If you reply to this email, your message will be added to the discussion
http://itk-users.7.n7.nabble.com/Rotating-image-results-in-l
ast-slices-being-half-empty-tp38081p38116.html
To unsubscribe from Rotating image results in last slices being half
empty, click here.
NAML
<http://itk-users.7.n7.nabble.com/template/NamlServlet.jtp?macro=macro_viewer&id=instant_html%21nabble%3Aemail.naml&base=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespace&breadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml>
--
Matias
------------------------------
View this message in context: Re: [ITK-users] Rotating image results in
last slices being half empty
<http://itk-users.7.n7.nabble.com/Rotating-image-results-in-last-slices-being-half-empty-tp38081p38121.html>
Sent from the ITK - Users mailing list archive
<http://itk-users.7.n7.nabble.com/> at Nabble.com.
_____________________________________
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
Dženan Zukić
2017-04-15 14:33:57 UTC
Permalink
Hi Matias,

center of rotation should use physical units (millimeters).

Regards,
DÅŸenan Zukić, PhD, Senior R&D Engineer, Kitware (Carrboro, N.C.)
Post by Matias Montroull
Dzenan,
The center of rotation is set to use milimeters or image coordinates?
Thanks
Matias
Post by Dženan Zukić
#include <itkImageFileReader.h>
#include <itkImageFileWriter.h>
#include <itkResampleImageFilter.h>
#include <itkEuler3DTransform.h>
template< typename TImage >
itk::SmartPointer<TImage> ReadImage(const char *filename)
{
typedef itk::ImageFileReader<TImage> ReaderType;
typename ReaderType::Pointer r = ReaderType::New();
r->SetFileName(filename);
r->Update();
return r->GetOutput();
}
template< typename TImage >
void WriteImage(itk::SmartPointer<TImage> out, const char *filename)
{
typedef itk::ImageFileWriter<TImage> WriterType;
typename WriterType::Pointer w = WriterType::New();
w->SetInput(out);
w->SetFileName(filename);
//w->SetUseCompression(true);
w->Update();
}
int main(int argc, char *argv[])
{
const unsigned int dimension = 3;
typedef itk::Image<short, dimension> ImageType;
ImageType::Pointer inputImage = ReadImage<ImageType>("C:/CBCT.nrrd");
typedef itk::ResampleImageFilter<ImageType, ImageType> FilterType;
FilterType::Pointer FiltroResample = FilterType::New();
FiltroResample->SetInput(inputImage);
typedef itk::LinearInterpolateImageFunction<ImageType, double>
InterpolatorType;
InterpolatorType::Pointer interpolator = InterpolatorType::New();
FiltroResample->SetInterpolator(interpolator);
FiltroResample->SetOutputDirection(inputImage->GetDirection());
FiltroResample->SetOutputOrigin(inputImage->GetOrigin());
ImageType::SizeType inputSize = inputImage->GetLargestPossible
Region().GetSize();
FiltroResample->SetSize(inputSize);
const ImageType::SpacingType& inputSpacing = inputImage->GetSpacing();
FiltroResample->SetOutputSpacing(inputSpacing);
FiltroResample->SetDefaultPixelValue(-1000);
typedef itk::Euler3DTransform<double> TransformType;
TransformType::Pointer transform = TransformType::New();
transform->SetRotation(0.2, 0.3, 0.5);
double centro[3] = { 10,20,30 };
transform->SetCenter(centro);
FiltroResample->SetTransform(transform);
FiltroResample->Update();
WriteImage<ImageType>(FiltroResample->GetOutput(),
"C:/cbctResampled.nrrd");
}
Post by Dženan Zukić
Hi Matias,
I didn't compile to use with Slicer. I only open the input and output
image in Slicer to visualize them.
But making a Slicer CLI module is fairly easy. You can take a look at one
<https://github.com/Slicer/Slicer/tree/master/Modules/CLI/AddScalarVolumes/>
of the existing modules, docs
<https://www.slicer.org/wiki/Documentation/Nightly/Developers/Modules> including
extension wizard
<https://www.slicer.org/wiki/Documentation/Nightly/Developers/ExtensionWizard>
.
Regards,
DÅŸenan Zukić, PhD, Senior R&D Engineer, Kitware (Carrboro, N.C.)
Post by Matias
Thanks Dzenan. I actually use OrigenX and OrigenY to assign it to the
DCM tags. Just curious, how did you compile to use with Slicer?
El jue., 13 de abr. de 2017 a la(s) 12:14, DÅŸenan Zukić [via ITK -
Users] <[hidden email]
Post by Dženan Zukić
Hi Matias,
you are not using origenX or origenY after they are defined. But your
[image: Inline image 1]
Regards,
DÅŸenan Zukić, PhD, Senior R&D Engineer, Kitware (Carrboro, N.C.)
On Sat, Apr 8, 2017 at 6:08 PM, Matias <[hidden email]
Hi, I'm rotating a volume (Using the Euler3DTransform) and the final
set of slices are half black or empty. here's an example when rotating a
volume of 10 slices: Am I missing something such as changing the origin or
maybe computing the center incorrectly? (The center is passed as parameter
from another program) And here's the code I'm using: typedef
itk::ResampleImageFilter<ImageType, ImageType> FilterType;
FilterType::Pointer FiltroResample = FilterType::New();
FiltroResample->SetInput(reader->GetOutput()); typedef
itk::LinearInterpolateImageFunction<ImageType, double >
InterpolatorType; InterpolatorType::Pointer interpolator =
InterpolatorType::New(); FiltroResample->SetInterpolator(interpolator);
FiltroResample->SetOutputDirection(inputImage->GetDirection());
FiltroResample->SetOutputOrigin(inputImage->GetOrigin());
ImageType::SizeType inputSize = inputImage->GetLargestPossibleRegion().GetSize();
FiltroResample->SetSize(inputSize); const ImageType::SpacingType&
inputSpacing = inputImage->GetSpacing(); FiltroResample->SetOutputSpacing(inputSpacing);
FiltroResample->SetDefaultPixelValue(-1000); typedef
itk::Euler3DTransform< double > TransformType; //Transform
TransformType::Pointer transform = TransformType::New(); double alfa, beta,
gamma, centro_rotacion_X, centro_rotacion_Y, centro_rotacion_Z,
origenX,origenY; gamma = atof(argv[2]); beta = atof(argv[3]); alfa =
atof(argv[4]); centro_rotacion_X = atof(argv[5]); centro_rotacion_Y =
atof(argv[6]); centro_rotacion_Z = atof(argv[7]); origenX = atof(argv[8]);
origenY = atof(argv[9]); transform->SetRotation(gamma, beta, alfa); double
centro[3] = { centro_rotacion_X, centro_rotacion_Y, centro_rotacion_Z };
transform->SetCenter(centro); FiltroResample->SetTransform(transform);
FiltroResample->Update();
------------------------------
View this message in context: Rotating image results in last slices
being half empty
<http://itk-users.7.n7.nabble.com/Rotating-image-results-in-last-slices-being-half-empty-tp38081.html>
Sent from the ITK - Users mailing list archive
<http://itk-users.7.n7.nabble.com/> at Nabble.com.
_____________________________________
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
_____________________________________
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
------------------------------
If you reply to this email, your message will be added to the
http://itk-users.7.n7.nabble.com/Rotating-image-results-in-l
ast-slices-being-half-empty-tp38081p38116.html
To unsubscribe from Rotating image results in last slices being half
empty, click here.
NAML
<http://itk-users.7.n7.nabble.com/template/NamlServlet.jtp?macro=macro_viewer&id=instant_html%21nabble%3Aemail.naml&base=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespace&breadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml>
--
Matias
------------------------------
View this message in context: Re: [ITK-users] Rotating image results
in last slices being half empty
<http://itk-users.7.n7.nabble.com/Rotating-image-results-in-last-slices-being-half-empty-tp38081p38121.html>
Sent from the ITK - Users mailing list archive
<http://itk-users.7.n7.nabble.com/> at Nabble.com.
_____________________________________
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...