<div class="gmail_quote">Dear Luis,<br><br>Background: I have an image volume, MRI of the knee. The tibia is segmented and<br>all the 'femur' voxels have grey values (not binary). All the rest is black.<br>Therefore, I create a mask by applying a thresholder with a threshold of 1: all the <br>
voxels that have intensity>0 are given the value '1'.<br><br> typedef itk::ThresholdImageFilter< FixedImageType > ThresholdFilterType;<br> ThresholdFilterType::Pointer thresholder = ThresholdFilterType::New();<br>
thresholder->SetInput( fixedImage);<br> thresholder->SetOutsideValue( 1 );<br> thresholder->ThresholdAbove( 0 );<br> thresholder->Update(); <br><br> // insert caster here, casting from float to unsigned char<br>
typedef unsigned char MaskPixelType;<br> typedef itk::Image< MaskPixelType, Dimension > MaskImageType;<br> typedef itk::CastImageFilter< FixedImageType, MaskImageType > CastFilterType;<br> <br>
CastFilterType::Pointer caster = CastFilterType::New();<br> caster->SetInput( thresholder->GetOutput() ); <br><br> // create a 3D mask type<br> typedef itk::ImageMaskSpatialObject< 3 > MaskType;<br> // then create the mask itself<br>
MaskType::Pointer mask = MaskType::New();<br><br> //connect the binary image to the mask<br> mask->SetImage(caster->GetOutput() ); <br><br> // pass the spatial object mask to the image metric<br> metric->SetFixedImageMask( mask);<br>
// metric->SetMovingImageMask( mask);<br><br> // write the mask to a file, just to check if thresholding went alright<br> typedef itk::ImageFileWriter< MaskImageType > MaskImageWriter;<br> MaskImageWriter::Pointer writerBinary = MaskImageWriter::New();<br>
writerBinary->SetInput( caster->GetOutput() ); <br> writerBinary->SetFileName("mask.mhd" );<br> writerBinary->Update(); <br> std::cout << "mask created" << std::endl << std::endl;<br>
<br>I'm afraid I can't post the mask file to the mailing list (1.7MB) but I'll mail it to you.<br><br>cheers, <br><br>Michael<div><div></div><div class="h5"><br><div class="gmail_quote"><br><br><br>On Sat, Mar 6, 2010 at 11:02 PM, Luis Ibanez <span dir="ltr"><<a href="mailto:luis.ibanez@kitware.com" target="_blank">luis.ibanez@kitware.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">Hi Michiel,<br>
<br>
Thanks for sharing your findings in this problem.<br>
<br>
Can you tell us more about the mask (the segmentation)<br>
that you created ?<br>
<br>
Have you checked this mask with any visualization<br>
application ?<br>
<br>
What are the pixel values ?<br>
<br>
Is there a chance that you could share that binary image<br>
with us ?<br>
<br>
<br>
Thanks<br>
<br>
<br>
Luis<br>
<br>
---------------------------------------------------------------------------<br>
<div><div></div><div>On Fri, Mar 5, 2010 at 11:28 AM, michiel mentink<br>
<<a href="mailto:michael.mentink@st-hughs.ox.ac.uk" target="_blank">michael.mentink@st-hughs.ox.ac.uk</a>> wrote:<br>
> Dear all,<br>
><br>
> When running an image registration algorithm with mask, I get this error:<br>
><br>
> File:<br>
> /MMprogs/src/ITK_src/Code/Algorithms/itkMeanSquaresImageToImageMetric.txx<br>
> Line: 364<br>
> Description: itk::ERROR: MeanSquaresImageToImageMetric(0x95f63f0): All the<br>
> points mapped to outside of the moving image<br>
><br>
> I've traced this to the following problem:<br>
> in ImageMaskSpatialObject->IsInside(), all points are found outside of the<br>
> mask/image (?)<br>
><br>
> and this is because the boundingbox of the mask has bounding values of 0, 0,<br>
> 0, 0, 0, 0, so indeed, there are no points that<br>
> can be found inside these values.<br>
><br>
> I am a bit stuck now, apparently, the mask that I created from a segmented<br>
> volume is not converted into a bounding box correctly.<br>
><br>
> Where do I check to find out why this is happening?<br>
><br>
> cheers,<br>
><br>
> Michael<br>
><br>
><br>
> ps: some more info about my data:<br>
><br>
> new moving image origin: [0, 0, 0]<br>
> fixed image size: [215, 172, 48]<br>
> fixed image origin: [44.0625, 0, 0]<br>
> fixed image spacing: [0.3125, 0.3125, 1.9808]<br>
> fixed image direction:<br>
> 1 0 0<br>
> 0 1 0<br>
> 0 0 1<br>
><br>
><br>
> moving image size: [512, 512, 52]<br>
> moving image origin: [0, 0, 0]<br>
> moving image spacing: [0.3125, 0.3125, 1.92911]<br>
> moving image direction:<br>
> 1 0 0<br>
> 0 1 0<br>
> 0 0 1<br>
><br>
><br>
> image mask size: [215, 172, 48]<br>
> image mask origin: [44.0625, 0, 0]<br>
> image mask spacing: [0.3125, 0.3125, 1.9808]<br>
> image mask direction:<br>
> 1 0 0<br>
> 0 1 0<br>
> 0 0 1<br>
><br>
><br>
</div></div><div><div></div><div>> _____________________________________<br>
> Powered by <a href="http://www.kitware.com" target="_blank">www.kitware.com</a><br>
><br>
> Visit other Kitware open-source projects at<br>
> <a href="http://www.kitware.com/opensource/opensource.html" target="_blank">http://www.kitware.com/opensource/opensource.html</a><br>
><br>
> Kitware offers ITK Training Courses, for more information visit:<br>
> <a href="http://www.kitware.com/products/protraining.html" target="_blank">http://www.kitware.com/products/protraining.html</a><br>
><br>
> Please keep messages on-topic and check the ITK FAQ at:<br>
> <a href="http://www.itk.org/Wiki/ITK_FAQ" target="_blank">http://www.itk.org/Wiki/ITK_FAQ</a><br>
><br>
> Follow this link to subscribe/unsubscribe:<br>
> <a href="http://www.itk.org/mailman/listinfo/insight-users" target="_blank">http://www.itk.org/mailman/listinfo/insight-users</a><br>
><br>
><br>
</div></div></blockquote></div><br>
</div></div></div><br>