[ITK] [ITK-users] Getting different labels slice by slice

Sarah Basti ahalabasti at hotmail.com
Thu May 29 07:33:48 EDT 2014


Oh, this is awkward, you are right, I was using unsigned short instead of int...thank you very much Brad, and sorry for that!!
Sarah

Subject: Re: [ITK-users] Getting different labels slice by slice
From: blowekamp at mail.nih.gov
Date: Thu, 29 May 2014 07:23:55 -0400
CC: pie.nardelli at gmail.com; insight-users at itk.org
To: ahalabasti at hotmail.com

Any reason you couldn't just use an "unsigned int" type of size 32-bits?
Brad
On May 29, 2014, at 6:53 AM, Sarah Basti <ahalabasti at hotmail.com> wrote:Hi guys,
I need your help for another problem I have. I managed to get all the labels with a different value. However, sometimes I happen to have more than 65536 (2^16) labels. In that case I realized that numbers starting from 0 again are assigned to the new labels. Do you know if there is any way to overcome this problem? 
Many many thanks as usual,Sarah

Date: Mon, 26 May 2014 14:08:44 +0100
Subject: Re: [ITK-users] Getting different labels slice by slice
From: pie.nardelli at gmail.com
To: ahalabasti at hotmail.com
CC: blowekamp at mail.nih.gov; insight-users at itk.org

Hi Sarah,
I guess that the itkChangeInformationImageFilter[1] might help you sort your issue with the spacing out. 
HTH,Pietro
[1]http://www.itk.org/Doxygen/html/classitk_1_1ChangeInformationImageFilter.html

2014-05-26 13:33 GMT+01:00 Sarah Basti <ahalabasti at hotmail.com>:
Hi Brad!
Thank you very much!! Actually, since I could not figure out how to solve the problem, I had decided to implement my own class that creates an image with the number of the slice on it. I tried the method you suggested though and it actually seems to work better...the only problem I have with it now is that the spacing of my 3D image is 0.625, so considering an unsigned short pixel type in the PhysicalPointImageSource, two adjacent slices may have the same value...I think that I may try using float instead, but then I think that I would have the same problem 
when adding the value to the original label, am I correct? For encoding both the image label and the slice index do you suggest using a VectorImage?
Thank you very much for your help,
SarahSubject: Re: [ITK-users] Getting different labels slice by slice
From: blowekamp at mail.nih.gov
Date: Sun, 25 May 2014 11:32:50 -0400
CC: insight-users at itk.org
To: ahalabasti at hotmail.com

Hello,
If you can't find an example, it's frequently useful to search through the test. Here is one that may be helpful:https://github.com/InsightSoftwareConsortium/ITK/blob/master/Modules/Filtering/ImageSources/test/itkPhysicalPointImageSourceTest.cxx
It's the bits not include in your code segment which aren't correct :)
>From the doxygen[1]: "This image source supports image which have a multi-component pixel equal to the image dimension, and variable length VectorImages. It is recommented that the component type be a real valued type."
You have instantiated it with an itk::Image of unsigned char, while the filter expects a multi-component image. Such as an itk::Image of Point<float,3>, Index<int,3> or an itk::VectorImage<int, 3>. 
Here is how I would do this in SimpleITK for Python:
import SimpleITK as sitk
img = sitk.Image([100,100,100], sitk.sitkUInt8)
idxImage = sitk.PhysicalPointSource(sitk.sitkVectorUInt32, size=img.GetSize())
zidxImage = sitk.VectorIndexSelectionCast(idxImage,2)
>From here you can do some image arithmetic to encode both the original image label and slice index. Perhaps keeping the label id in the lower bits and the slice id in the upper.
Brad
[1] http://www.itk.org/Doxygen/html/classitk_1_1PhysicalPointImageSource.html
On May 23, 2014, at 10:26 AM, Sarah Basti <ahalabasti at hotmail.com> wrote:
I tried to do the following:
typedef itk::PhysicalPointImageSource<OutputImageType> physicalPointImageType;
physicalPointImageType::Pointer physicalImage = physicalPointImageType::New();
physicalImage->SetSize(reader->GetOutput()->GetLargestPossibleRegion().GetSize());
physicalImage->Update();


I get this error though:

In file included from /home/Support/Slicer-SuperBuild-Release/ITKv4/Modules/Filtering/ImageSources/include/itkPhysicalPointImageSource.h:81:0,                 from /home/acorvo/Desktop/SlicerModules/Cross-Section-Location/Source/CrossSectionLocation.cxx:18:/home/Support/Slicer-SuperBuild-Release/ITKv4/Modules/Filtering/ImageSources/include/itkPhysicalPointImageSource.hxx: In member function ‘void itk::PhysicalPointImageSource<TOutputImage>::ThreadedGenerateData(const RegionType&, itk::ThreadIdType) [with TOutputImage = itk::Image<short unsigned int, 3u>, itk::PhysicalPointImageSource<TOutputImage>::RegionType = itk::ImageRegion<3u>, itk::ThreadIdType = unsigned int]’:/home/Desktop/SlicerModules/Cross-Section-Location/Source/CrossSectionLocation.cxx:238:1:   instantiated from here/home/Support/Slicer-SuperBuild-Release/ITKv4/Modules/Filtering/ImageSources/include/itkPhysicalPointImageSource.hxx:71:7: error: subscripted value is neither array nor pointermake[2]: *** [CMakeFiles/CrossSectionLocation.dir/CrossSectionLocation.cxx.o] Error 1make[1]: *** [CMakeFiles/CrossSectionLocation.dir/all] Error 2make: *** [all] Error 2
Do you know what that might mean? Any idea?
Thank you,SarahFrom: ahalabasti at hotmail.com
To: blowekamp at mail.nih.gov
Date: Fri, 23 May 2014 13:17:13 +0000
CC: insight-users at itk.org
Subject: Re: [ITK-users] Getting different labels slice by slice

Hi Brad,
thank you very much, I really appreciate your help!! It is indeed a great idea what you are proposing, thanks!! Only one question: is the PhysicalPointImageSource used as if it was a normal image (but having the slice number on it)? Sorry for that, but I haven't found any example and I'm quite new with ITK. 

Thank you very much!!Sarah
Subject: Re: [ITK-users] Getting different labels slice by slice
From: blowekamp at mail.nih.gov
Date: Fri, 23 May 2014 07:48:19 -0400
CC: insight-users at itk.org
To: ahalabasti at hotmail.com

Hello Sarah,
Here is an idea. Create an image where each slice contains the slice number, then add that to you original label image, and do a little binary logic. The goal here would be to give each slice sequentially higher numbers. Then you can runs a statistics image filter in 3D. You can use the a component from the PhysicalPointImageSource[1] as the image with the slice number.
Good luck,Brad
[1] http://www.itk.org/Doxygen/html/classitk_1_1PhysicalPointImageSource.html
On May 23, 2014, at 6:50 AM, Sarah Basti <ahalabasti at hotmail.com> wrote:
Hello guys,
I'm quite new with ITK and I really need your help. I was able to extract/segment 3D objects from an image using the binary threshold image filter. However I'm stuck here, because I need to analyze the mean intensities of these objects in the original image, but I need to to this analysis in 2D, because I need the intensities for each slice. As suggested in some other post I tried using the slice by slice filter, converting the binary image into a label map and then into labels. And my idea was to then use the label statistics image filter on the output of the slice by slice filter to extract the mean values. However, it turned out that although the conversion is made slice by slice, many times on adjacent slices the same label is assigned to the same object (I guess that it makes sense!), so when I use the label statistics, is like having 3D labels again, instead of a set of 2D labels. Therefore, I was wondering if there is some option to have different labels for each slice, or there is any other way to evaluate the 2D mean intensity of 3D objects!
I thank you all in advance!!
Sarah_____________________________________
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://www.itk.org/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://www.itk.org/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://www.itk.org/mailman/listinfo/insight-users
 		 	   		  
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/community/attachments/20140529/108b1016/attachment-0002.html>
-------------- next part --------------
_____________________________________
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://www.itk.org/mailman/listinfo/insight-users


More information about the Community mailing list