Discussion:
[ITK-users] Creating 3D dome using ITK
sidharta
2017-05-10 10:19:37 UTC
Permalink
Dear all,

I am trying to make a 3D dome (ie; Half Sphere) and then generating a binary
image out of it. The aim is to use this binary image as a mask in
maskFilter. I was able to generate a 2D circular mask, which was straight
forward. I used this in a maskFilter and masked the 3D image using
slicebysliceFilter.

I can think of two ways to do it:
1. Make several masks of decreasing circle radius which ultimately would
represent a dome.
2. Make a mask image and assign the values at indices accordingly to get a
dome mask.

The first step seems doable but to my understanding would be an overkill.
I am not able to do the second step. Following is the code I tried:

float MY_RADIUS = maskRegion.GetSize()[0];
MaskIteratorType iterator(maskImage, maskImage->GetLargestPossibleRegion());
while (!iterator.IsAtEnd())
{
const InputImageType::IndexType & index = iterator.GetIndex();
std::cout << "Index is " << index;
float value = (index[0] - centerPoint[0]) * (index[0] - centerPoint[0])
+ (index[1] - centerPoint[1]) * (index[1] - centerPoint[1]);
std::cout << "Compare - LHS = " << value << " RHS = " << MY_RADIUS *
MY_RADIUS << std::endl;
if ((index[0] - centerPoint[0]) * (index[0] - centerPoint[0])
+ (index[1] - centerPoint[1]) * (index[1] - centerPoint[1])
<= MY_RADIUS * MY_RADIUS)
{
iterator.Set(1);
}
--MY_RADIUS;
++iterator;
}

After adding the cout commands I saw that --MY_RADIUS is incorrect. I
generated the required sphere using matlab, just to get the values I should
assign to the pixels.

Additionally, I noticed there is a need for anti-aliasing to the mask.
Kindly let me know how this can be done iteratively.

Thank you!



--
View this message in context: http://itk-users.7.n7.nabble.com/Creating-3D-dome-using-ITK-tp38201.html
Sent from the ITK - Users mailing list archive at Nabble.com.
_____________________________________
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://www.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://public.kitware.com/mailman/listinfo/insight-users
Matt McCormick
2017-05-10 10:40:36 UTC
Permalink
Hi,

Depending on the code, MY_RADIUS may need to be divided by two.

To avoid difficulties like this, it is better to work in physical
space versus index space. For more information on how physical space
works in ITK, see the itk::Image overview in the ITK Software Guide:

https://itk.org/ITKSoftwareGuide/html/Book1/ITKSoftwareGuide-Book1ch4.html#x38-450004.1


There is a filter that can be used to anti-alias the mask. Here is an example:

https://itk.org/ITKExamples/src/Filtering/AntiAlias/SmoothBinaryImageBeforeSurfaceExtraction/Documentation.html


I hope this helps.

Matt
Post by sidharta
Dear all,
I am trying to make a 3D dome (ie; Half Sphere) and then generating a binary
image out of it. The aim is to use this binary image as a mask in
maskFilter. I was able to generate a 2D circular mask, which was straight
forward. I used this in a maskFilter and masked the 3D image using
slicebysliceFilter.
1. Make several masks of decreasing circle radius which ultimately would
represent a dome.
2. Make a mask image and assign the values at indices accordingly to get a
dome mask.
The first step seems doable but to my understanding would be an overkill.
float MY_RADIUS = maskRegion.GetSize()[0];
MaskIteratorType iterator(maskImage, maskImage->GetLargestPossibleRegion());
while (!iterator.IsAtEnd())
{
const InputImageType::IndexType & index = iterator.GetIndex();
std::cout << "Index is " << index;
float value = (index[0] - centerPoint[0]) * (index[0] - centerPoint[0])
+ (index[1] - centerPoint[1]) * (index[1] - centerPoint[1]);
std::cout << "Compare - LHS = " << value << " RHS = " << MY_RADIUS *
MY_RADIUS << std::endl;
if ((index[0] - centerPoint[0]) * (index[0] - centerPoint[0])
+ (index[1] - centerPoint[1]) * (index[1] - centerPoint[1])
<= MY_RADIUS * MY_RADIUS)
{
iterator.Set(1);
}
--MY_RADIUS;
++iterator;
}
After adding the cout commands I saw that --MY_RADIUS is incorrect. I
generated the required sphere using matlab, just to get the values I should
assign to the pixels.
Additionally, I noticed there is a need for anti-aliasing to the mask.
Kindly let me know how this can be done iteratively.
Thank you!
--
View this message in context: http://itk-users.7.n7.nabble.com/Creating-3D-dome-using-ITK-tp38201.html
Sent from the ITK - Users mailing list archive 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

Kitware offers ITK Training Courses, for more information visit:
http://www.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://public.kitware.com/mailman/listinfo/insight-users
Richard Beare
2017-05-10 11:01:50 UTC
Permalink
A simple, although not necessarily efficient, way of doing this is to
create an image with a single voxel where you want the centre of the
(hemi)sphere to be, then dilate using the binary dilate filter
(alternatively compute a distance transform them threshold). These two
methods will give you a sphere, and you can then blank the half you don't
want.

Depending on the interface to ITK you are using, you could probably achieve
something similar by generating images containing physical coordinates an
plug those into formula for a sphere.
Post by Matt McCormick
Hi,
Depending on the code, MY_RADIUS may need to be divided by two.
To avoid difficulties like this, it is better to work in physical
space versus index space. For more information on how physical space
https://itk.org/ITKSoftwareGuide/html/Book1/ITKSoftwareGuide-Book1ch4.
html#x38-450004.1
https://itk.org/ITKExamples/src/Filtering/AntiAlias/
SmoothBinaryImageBeforeSurfaceExtraction/Documentation.html
I hope this helps.
Matt
Post by sidharta
Dear all,
I am trying to make a 3D dome (ie; Half Sphere) and then generating a
binary
Post by sidharta
image out of it. The aim is to use this binary image as a mask in
maskFilter. I was able to generate a 2D circular mask, which was straight
forward. I used this in a maskFilter and masked the 3D image using
slicebysliceFilter.
1. Make several masks of decreasing circle radius which ultimately would
represent a dome.
2. Make a mask image and assign the values at indices accordingly to get
a
Post by sidharta
dome mask.
The first step seems doable but to my understanding would be an overkill.
float MY_RADIUS = maskRegion.GetSize()[0];
MaskIteratorType iterator(maskImage, maskImage->
GetLargestPossibleRegion());
Post by sidharta
while (!iterator.IsAtEnd())
{
const InputImageType::IndexType & index =
iterator.GetIndex();
Post by sidharta
std::cout << "Index is " << index;
float value = (index[0] - centerPoint[0]) * (index[0] -
centerPoint[0])
Post by sidharta
+ (index[1] - centerPoint[1]) * (index[1] -
centerPoint[1]);
Post by sidharta
std::cout << "Compare - LHS = " << value << " RHS = " <<
MY_RADIUS *
Post by sidharta
MY_RADIUS << std::endl;
if ((index[0] - centerPoint[0]) * (index[0] -
centerPoint[0])
Post by sidharta
+ (index[1] - centerPoint[1]) * (index[1] -
centerPoint[1])
Post by sidharta
<= MY_RADIUS * MY_RADIUS)
{
iterator.Set(1);
}
--MY_RADIUS;
++iterator;
}
After adding the cout commands I saw that --MY_RADIUS is incorrect. I
generated the required sphere using matlab, just to get the values I
should
Post by sidharta
assign to the pixels.
Additionally, I noticed there is a need for anti-aliasing to the mask.
Kindly let me know how this can be done iteratively.
Thank you!
--
View this message in context: http://itk-users.7.n7.nabble.
com/Creating-3D-dome-using-ITK-tp38201.html
Post by sidharta
Sent from the ITK - Users mailing list archive 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
robert tamburo
2017-05-10 11:19:36 UTC
Permalink
https://itk.org/Wiki/ITK/Examples/SpatialObjects/EllipseSpatialObject
Post by Richard Beare
A simple, although not necessarily efficient, way of doing this is to
create an image with a single voxel where you want the centre of the
(hemi)sphere to be, then dilate using the binary dilate filter
(alternatively compute a distance transform them threshold). These two
methods will give you a sphere, and you can then blank the half you don't
want.
Depending on the interface to ITK you are using, you could probably
achieve something similar by generating images containing physical
coordinates an plug those into formula for a sphere.
On Wed, May 10, 2017 at 8:40 PM, Matt McCormick <
Post by Matt McCormick
Hi,
Depending on the code, MY_RADIUS may need to be divided by two.
To avoid difficulties like this, it is better to work in physical
space versus index space. For more information on how physical space
https://itk.org/ITKSoftwareGuide/html/Book1/ITKSoftwareGuide
-Book1ch4.html#x38-450004.1
https://itk.org/ITKExamples/src/Filtering/AntiAlias/SmoothBi
naryImageBeforeSurfaceExtraction/Documentation.html
I hope this helps.
Matt
Post by sidharta
Dear all,
I am trying to make a 3D dome (ie; Half Sphere) and then generating a
binary
Post by sidharta
image out of it. The aim is to use this binary image as a mask in
maskFilter. I was able to generate a 2D circular mask, which was
straight
Post by sidharta
forward. I used this in a maskFilter and masked the 3D image using
slicebysliceFilter.
1. Make several masks of decreasing circle radius which ultimately would
represent a dome.
2. Make a mask image and assign the values at indices accordingly to
get a
Post by sidharta
dome mask.
The first step seems doable but to my understanding would be an
overkill.
Post by sidharta
float MY_RADIUS = maskRegion.GetSize()[0];
MaskIteratorType iterator(maskImage, maskImage->GetLargestPossibleR
egion());
Post by sidharta
while (!iterator.IsAtEnd())
{
const InputImageType::IndexType & index =
iterator.GetIndex();
Post by sidharta
std::cout << "Index is " << index;
float value = (index[0] - centerPoint[0]) * (index[0] -
centerPoint[0])
Post by sidharta
+ (index[1] - centerPoint[1]) * (index[1] -
centerPoint[1]);
Post by sidharta
std::cout << "Compare - LHS = " << value << " RHS = "
<< MY_RADIUS *
Post by sidharta
MY_RADIUS << std::endl;
if ((index[0] - centerPoint[0]) * (index[0] -
centerPoint[0])
Post by sidharta
+ (index[1] - centerPoint[1]) * (index[1] -
centerPoint[1])
Post by sidharta
<= MY_RADIUS * MY_RADIUS)
{
iterator.Set(1);
}
--MY_RADIUS;
++iterator;
}
After adding the cout commands I saw that --MY_RADIUS is incorrect. I
generated the required sphere using matlab, just to get the values I
should
Post by sidharta
assign to the pixels.
Additionally, I noticed there is a need for anti-aliasing to the mask.
Kindly let me know how this can be done iteratively.
Thank you!
--
View this message in context: http://itk-users.7.n7.nabble.c
om/Creating-3D-dome-using-ITK-tp38201.html
Post by sidharta
Sent from the ITK - Users mailing list archive 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
_____________________________________
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
--
robert
Richard Beare
2017-05-10 11:22:10 UTC
Permalink
Yep - even better.
Post by robert tamburo
https://itk.org/Wiki/ITK/Examples/SpatialObjects/EllipseSpatialObject
Post by Richard Beare
A simple, although not necessarily efficient, way of doing this is to
create an image with a single voxel where you want the centre of the
(hemi)sphere to be, then dilate using the binary dilate filter
(alternatively compute a distance transform them threshold). These two
methods will give you a sphere, and you can then blank the half you don't
want.
Depending on the interface to ITK you are using, you could probably
achieve something similar by generating images containing physical
coordinates an plug those into formula for a sphere.
On Wed, May 10, 2017 at 8:40 PM, Matt McCormick <
Post by Matt McCormick
Hi,
Depending on the code, MY_RADIUS may need to be divided by two.
To avoid difficulties like this, it is better to work in physical
space versus index space. For more information on how physical space
https://itk.org/ITKSoftwareGuide/html/Book1/ITKSoftwareGuide
-Book1ch4.html#x38-450004.1
https://itk.org/ITKExamples/src/Filtering/AntiAlias/SmoothBi
naryImageBeforeSurfaceExtraction/Documentation.html
I hope this helps.
Matt
Post by sidharta
Dear all,
I am trying to make a 3D dome (ie; Half Sphere) and then generating a
binary
Post by sidharta
image out of it. The aim is to use this binary image as a mask in
maskFilter. I was able to generate a 2D circular mask, which was
straight
Post by sidharta
forward. I used this in a maskFilter and masked the 3D image using
slicebysliceFilter.
1. Make several masks of decreasing circle radius which ultimately
would
Post by sidharta
represent a dome.
2. Make a mask image and assign the values at indices accordingly to
get a
Post by sidharta
dome mask.
The first step seems doable but to my understanding would be an
overkill.
Post by sidharta
float MY_RADIUS = maskRegion.GetSize()[0];
MaskIteratorType iterator(maskImage, maskImage->GetLargestPossibleR
egion());
Post by sidharta
while (!iterator.IsAtEnd())
{
const InputImageType::IndexType & index =
iterator.GetIndex();
Post by sidharta
std::cout << "Index is " << index;
float value = (index[0] - centerPoint[0]) * (index[0]
- centerPoint[0])
Post by sidharta
+ (index[1] - centerPoint[1]) * (index[1] -
centerPoint[1]);
Post by sidharta
std::cout << "Compare - LHS = " << value << " RHS = "
<< MY_RADIUS *
Post by sidharta
MY_RADIUS << std::endl;
if ((index[0] - centerPoint[0]) * (index[0] -
centerPoint[0])
Post by sidharta
+ (index[1] - centerPoint[1]) * (index[1] -
centerPoint[1])
Post by sidharta
<= MY_RADIUS * MY_RADIUS)
{
iterator.Set(1);
}
--MY_RADIUS;
++iterator;
}
After adding the cout commands I saw that --MY_RADIUS is incorrect. I
generated the required sphere using matlab, just to get the values I
should
Post by sidharta
assign to the pixels.
Additionally, I noticed there is a need for anti-aliasing to the mask.
Kindly let me know how this can be done iteratively.
Thank you!
--
View this message in context: http://itk-users.7.n7.nabble.c
om/Creating-3D-dome-using-ITK-tp38201.html
Post by sidharta
Sent from the ITK - Users mailing list archive 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
_____________________________________
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
--
robert
sidharta
2017-05-10 12:06:45 UTC
Permalink
I tried the EllipseSpatialObject as follows:

int EllipseSpatialObjectToImage(InputImageType::Pointer binaryImage){

typedef itk::EllipseSpatialObject<Dimension> EllipseType;
EllipseType::Pointer ellipse = EllipseType::New();

ellipse->SetRadius(0.5 / binaryImage->GetSpacing()[0]);
ellipse->SetDefaultInsideValue(1.0);
ellipse->SetDefaultOutsideValue(0.0);

typedef itk::SpatialObjectToImageFilter<EllipseType, InputImageType>
SpatialObjectToImageFilterType;
SpatialObjectToImageFilterType::Pointer filter =
SpatialObjectToImageFilterType::New();

int d = 1.0 / binaryImage->GetSpacing()[0];
InputImageType::SizeType size;
size.Fill(d);
filter->SetSize(size);

filter->SetInsideValue(255);
filter->SetOutsideValue(0);

double O[3] = { 0, 0, 0 };
filter->SetOrigin(O);
filter->SetInput(ellipse);

filter->Update();

int flag = FileWriter(filter->GetOutput(),
"C:/Users/api/Desktop/3D_mask_ellipse.mhd");
if (!flag)
return EXIT_FAILURE;
else
return EXIT_SUCCESS;
}
But I get a blank image unfortunately. How would I get hemi-sphere from
this? Just cropImageFilter?


Thank you
Sidharta



--
View this message in context: http://itk-users.7.n7.nabble.com/Creating-3D-dome-using-ITK-tp38201p38210.html
Sent from the ITK - Users mailing list archive at Nabble.com.
_____________________________________
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://www.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://public.kitware.com/mailman/listinfo/insight-users
Francois Budin
2017-05-10 13:54:15 UTC
Permalink
Hello Sidharta,

Don't forget to move the ellipsoid where you want in space. In the example
that Robert pointed you to [1], it is:

ellipse->SetObjectToParentTransform( transform );

To obtain only haft a dome, you could only create an image that contains
half of your ellipse for "SpatialObjectToImageFilter", and then resize the
image
afterward to match the image size you want.

Hope this helps,
Francois


[1] https://itk.org/Wiki/ITK/Examples/SpatialObjects/EllipseSpatialObject
Post by sidharta
int EllipseSpatialObjectToImage(InputImageType::Pointer binaryImage){
typedef itk::EllipseSpatialObject<Dimension> EllipseType;
EllipseType::Pointer ellipse = EllipseType::New();
ellipse->SetRadius(0.5 / binaryImage->GetSpacing()[0]);
ellipse->SetDefaultInsideValue(1.0);
ellipse->SetDefaultOutsideValue(0.0);
typedef itk::SpatialObjectToImageFilter<EllipseType,
InputImageType>
SpatialObjectToImageFilterType;
SpatialObjectToImageFilterType::Pointer filter =
SpatialObjectToImageFilterType::New();
int d = 1.0 / binaryImage->GetSpacing()[0];
InputImageType::SizeType size;
size.Fill(d);
filter->SetSize(size);
filter->SetInsideValue(255);
filter->SetOutsideValue(0);
double O[3] = { 0, 0, 0 };
filter->SetOrigin(O);
filter->SetInput(ellipse);
filter->Update();
int flag = FileWriter(filter->GetOutput(),
"C:/Users/api/Desktop/3D_mask_ellipse.mhd");
if (!flag)
return EXIT_FAILURE;
else
return EXIT_SUCCESS;
}
But I get a blank image unfortunately. How would I get hemi-sphere from
this? Just cropImageFilter?
Thank you
Sidharta
--
View this message in context: http://itk-users.7.n7.nabble.
com/Creating-3D-dome-using-ITK-tp38201p38210.html
Sent from the ITK - Users mailing list archive 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
sidharta
2017-05-10 15:10:02 UTC
Permalink
Dear Froncois

Thank you for your reply. The reason why I need this dome is because it
mimics a burr (drill bit). So, I extract densities in a cubic volume and
then mask this cube with the dome, which essentially would give me an image
which shows what densities will the burr encounter while drilling. The
ellipse object seems to be the key here but I don't know how to transform.
The rotation would be identity but the translation is the key. So following
is a pseudo code with I came up with, correct me if I am wrong:

1. Make an ellipse object of radius = 2 * edge length of the cube.
2. With SpatialObjectToImageFilter, set size of the image as the edge length
of the cube (in all dimensions). Then transform the object (ellipse) so that
the center of the ellipse lies at the origin of the image. This is what I am
not able to figure how to achieve.

Kindly let me know what you think

Regards,
Sidharta



--
View this message in context: http://itk-users.7.n7.nabble.com/Creating-3D-dome-using-ITK-tp38201p38218.html
Sent from the ITK - Users mailing list archive at Nabble.com.
_____________________________________
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://www.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://public.kitware.com/mailman/listinfo/insight-users
sidharta
2017-05-10 17:10:44 UTC
Permalink
So I tried the following:

int EllipseSpatialObjectToImage(InputImageType::Pointer binaryImage){

typedef itk::EllipseSpatialObject<Dimension> EllipseType;
typedef itk::SpatialObjectToImageFilter<EllipseType, InputImageType>
SpatialObjectToImageFilterType;

SpatialObjectToImageFilterType::Pointer spatialObjectToImageFilter =
SpatialObjectToImageFilterType::New();

InputImageType::SizeType size;
size[0] = 8;
size[1] = 8;
size[2] = 8;
// spatialObjectToImageFilter->SetSize(size); not setting the size
explicitly as by default the filter will calculate the optimum size.

InputImageType::SpacingType spacing;
spacing.Fill(1);
spatialObjectToImageFilter->SetSpacing(spacing);

EllipseType::Pointer ellipse = EllipseType::New();
EllipseType::ArrayType radiusArray;
ellipse->SetRadius(8); // Since I want half of this ellipse, I set the
radius to 8.

// Position the ellipse in the image
typedef EllipseType::TransformType TransformType;
TransformType::Pointer transform = TransformType::New();

transform->SetIdentity();

TransformType::OutputVectorType translation;
TransformType::CenterType center;
translation[0] = 8 * spacing[0]; // Translate so the center of the
"ellipse" is such that it covers the entire image bounds.
translation[1] = 8 * spacing[1];
translation[2] = -8 * spacing[2]; // This is for dome
transform->Translate(translation);
ellipse->SetObjectToParentTransform(transform);
std::cout << "Ellipse bounding box " <<
ellipse->GetBoundingBox()->GetMaximum() << std::endl;
spatialObjectToImageFilter->SetInput(ellipse);
ellipse->SetDefaultInsideValue(255);
ellipse->SetDefaultOutsideValue(0);

spatialObjectToImageFilter->SetUseObjectValue(true);
spatialObjectToImageFilter->SetOutsideValue(0);

spatialObjectToImageFilter->Update();

int flag = FileWriter(spatialObjectToImageFilter->GetOutput(),
"C:/Users/api/Desktop/dome.mhd");
if (!flag)
return EXIT_FAILURE;
return EXIT_SUCCESS;


}

But I don't get what I am intending. Any suggestions?




--
View this message in context: http://itk-users.7.n7.nabble.com/Creating-3D-dome-using-ITK-tp38201p38220.html
Sent from the ITK - Users mailing list archive at Nabble.com.
_____________________________________
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://www.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://public.kitware.com/mailman/listinfo/insight-users
Francois Budin
2017-05-10 17:54:39 UTC
Permalink
Hello Sidharta,
Post by sidharta
Dear Froncois
Thank you for your reply. The reason why I need this dome is because it
mimics a burr (drill bit). So, I extract densities in a cubic volume and
then mask this cube with the dome, which essentially would give me an image
which shows what densities will the burr encounter while drilling. The
ellipse object seems to be the key here but I don't know how to transform.
The rotation would be identity but the translation is the key. So following
1. Make an ellipse object of radius = 2 * edge length of the cube.
Don't you mean that the ellipse radius is 1/2 of the edge length of the
cube?
Post by sidharta
2. With SpatialObjectToImageFilter, set size of the image as the edge length
of the cube (in all dimensions). Then transform the object (ellipse) so that
the center of the ellipse lies at the origin of the image. This is what I am
not able to figure how to achieve.
You probably don't want the center of the image to lie at the origin, but
in the center of your edge if I understand correctly, at least for 2 of
your 3 dimensions, and at the origin for the 3rd dimension to obtain a
half-dome.
Post by sidharta
Kindly let me know what you think
Regards,
Sidharta
--
View this message in context: http://itk-users.7.n7.nabble.c
om/Creating-3D-dome-using-ITK-tp38201p38218.html
Sent from the ITK - Users mailing list archive 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
sidharta
2017-05-10 18:15:36 UTC
Permalink
Dear Francois,

Thank you for your reply.

1. Say I have a cube with edge length = 16. If I make an ellipse of radius =
8, the dome wouldn't fit in the entire cube, but rather only half of the
cube. So, making an ellipse of radius = 16, and then masking the cube with
the dome would give me what I want (correct me if I am wrong).

2. If 0,0,0 is the origin of the image, I would like to set the transform
such that the center of the ellipse is at 8, 8, -8 so that I get only the
dome in the image with "SpatialObjectToImageFilter".

Using "->ComputeBoundingBox()" and then "->GetBoundingBox()->GetBounds()",
before and after transformation (before would be in local coordinates and
after would be in Parent coordinates), I got the following results for

translation[0] = 0 * spacing[0];
translation[1] = 8 * spacing[1];
translation[2] = 0 * spacing[2];

<http://itk-users.7.n7.nabble.com/file/n38222/New_Bitmap_Image_%283%29.bmp>



--
View this message in context: http://itk-users.7.n7.nabble.com/Creating-3D-dome-using-ITK-tp38201p38222.html
Sent from the ITK - Users mailing list archive at Nabble.com.
_____________________________________
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://www.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://public.kitware.com/mailman/listinfo/insight-users
sidharta
2017-05-10 18:49:10 UTC
Permalink
I seemed to have fixed it using the following:

translation[0] = 8;
translation[1] = 8;
translation[2] = 0;

<http://itk-users.7.n7.nabble.com/file/n38223/New_Bitmap_Image_%282%29.bmp>

which is what I imagined before. So far so good, but the image I am going to
mask this with (or convolve) has a spacing of 0.125 in all directions. I
achieved the desired results with spacing in all directions = 1. When I
change the spacing to 0.125 and run the code, the resulting "dome" image is
blank. Can you tell why it is like this and how I can fix it?

Thank you for your time
Sidharta



--
View this message in context: http://itk-users.7.n7.nabble.com/Creating-3D-dome-using-ITK-tp38201p38223.html
Sent from the ITK - Users mailing list archive at Nabble.com.
_____________________________________
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://www.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://public.kitware.com/mailman/listinfo/insight-users
Francois Budin
2017-05-10 20:23:02 UTC
Permalink
I have to admit that I am not sure to picture correctly what you are trying
to do with the dome and the square. However, my guess is that you can you
have an error with the spacing because of a scaling issue. You may want to
scale your ellipsoid by adding scaling values in the transform matrix.

Hope this helps,
Francois
Post by sidharta
translation[0] = 8;
translation[1] = 8;
translation[2] = 0;
<http://itk-users.7.n7.nabble.com/file/n38223/New_Bitmap_Image_%282%29.bmp
which is what I imagined before. So far so good, but the image I am going to
mask this with (or convolve) has a spacing of 0.125 in all directions. I
achieved the desired results with spacing in all directions = 1. When I
change the spacing to 0.125 and run the code, the resulting "dome" image is
blank. Can you tell why it is like this and how I can fix it?
Thank you for your time
Sidharta
--
View this message in context: http://itk-users.7.n7.nabble.
com/Creating-3D-dome-using-ITK-tp38201p38223.html
Sent from the ITK - Users mailing list archive 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
sidharta
2017-05-11 12:58:57 UTC
Permalink
Dear Francois,

Thank you for your reply.

Is it also possible to change the spacing explicitly in the final image? As
in using "SpatialObjectToImageFilter" I get the ellipse in an image with
spacing and after that I change the spacing to what I want from 1.

<Loading Image...>

Because I tried that and I get the desired image with the correct spacing
but then the program crashes.

P.S. To my understanding (correct me if I am wrong), if initially the
spacing is 1.0 and everything works, I should scale the ellipse by setting
"transform->Scale(1 / spacing[0])", where spacing[0] is the desired spacing.
Then, I would also have to change the translation vectors accordingly (which
I am still trying to figure out so that the image size is exactly what I
want it to be).


Thank you for your time.
Sidharta



--
View this message in context: http://itk-users.7.n7.nabble.com/Creating-3D-dome-using-ITK-tp38201p38227.html
Sent from the ITK - Users mailing list archive at Nabble.com.
_____________________________________
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://www.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://public.kitware.com/mailman/listinfo/insight-users
Francois Budin
2017-05-11 18:01:15 UTC
Permalink
Hello Sidharta,

I agree. The easiest way for you to get the image you want is to generate
it with a spacing of 1, and then change the spacing directly on the
generated image:
my_image->SetSpacing(my_new_spacing);

If you want your ellipse to have the same scale (covers the same number of
pixels) in your image that has spacing=1 and in your image that has spacing
Y, you need to set the transform to:
transform->Scale(spacing[0])

Hope this helps,
Francois
Post by sidharta
Dear Francois,
Thank you for your reply.
Is it also possible to change the spacing explicitly in the final image? As
in using "SpatialObjectToImageFilter" I get the ellipse in an image with
spacing and after that I change the spacing to what I want from 1.
<http://itk-users.7.n7.nabble.com/file/n38227/dome.png>
Because I tried that and I get the desired image with the correct spacing
but then the program crashes.
P.S. To my understanding (correct me if I am wrong), if initially the
spacing is 1.0 and everything works, I should scale the ellipse by setting
"transform->Scale(1 / spacing[0])", where spacing[0] is the desired spacing.
Then, I would also have to change the translation vectors accordingly (which
I am still trying to figure out so that the image size is exactly what I
want it to be).
Thank you for your time.
Sidharta
--
View this message in context: http://itk-users.7.n7.nabble.
com/Creating-3D-dome-using-ITK-tp38201p38227.html
Sent from the ITK - Users mailing list archive 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...