[ITK] FW: Determine surface area of certain region in image

Dženan Zukić dzenanz at gmail.com
Wed Aug 10 13:28:58 EDT 2016


OK, now I understand your question (I think).

3DImage contains 3D coordinates of points, laid out in approximate grid
pattern when view along z axis.
LabelImage contains information which points are part of an object's
surface. You want to calculate area of this surface.
[image: Inline image 1]
Option 1: calculate surface of the cross-hatched area.
Option 2: calculate surface of the dotted area (similar to ITK's pixel area
definition in Defining origin and spacing
<https://itk.org/ITKSoftwareGuide/html/Book1/ITKSoftwareGuide-Book1ch4.html>
).

Option 2 would be easier to do using ITK. Calculate each point's surface
coverage by examining how far away it is from the neighbors using 3D
coordinates, and then simply sum up all those areas. Area of each point
coverage would be a 4 triangles or quadrilaterals formed with 4 neighbors.

Option 1 is more like creating a triangular surface patch, and then
calculating its surface area. Easiest would be iterating the triangles and
summing their surface areas using vector cross product. Alternatively, you
could convert it to a data structure of some mesh library like e.g.
vtkPolyData, and then use that library's algorithms to calculate the
surface area e.g. vtkMassProperties
<http://vtk.1045678.n5.nabble.com/Calculating-the-area-of-a-polygon-td1238841.html>
.

But to do either I think you should use iterators to access individual
pixels, and SimpleITK doesn't have them. Have you considered using regular
ITK?

On Wed, Aug 10, 2016 at 12:16 PM, Matthias B <matthias.b at hotmail.com> wrote:

>
>
> ------------------------------
> From: matthias.b at hotmail.com
> To: dzenanz at gmail.com
> Subject: RE: [ITK] Determine surface area of certain region in image
> Date: Wed, 10 Aug 2016 18:15:39 +0200
>
>
> I'm sorry, I really don't get it Dženan,
>
> Maybe another approach, I'm working with a 3D camera with a resolution of
> 5 by 5. Every pixel contains a X, Y and Z component, let's say in
> centimeters.
> I put an object int front of the camera right in the center of the image,
> the object covers 3x3 pixels..
>
> Now I want to have the surface area of this object, I now the object is
> located on the image like this {{0,0,0,0,0},{0,1,1,1,0},{0,1,1,1,0},
> {0,1,1,1,0},{0,0,0,0,0}}
>
> Xdata={{-4,-2,0,2,4},{-4,-2,0,2,4},{-4,-2,0,2,4},{-4,-2,0,2,4},
> {-4,-2,0,2,4}}
> Ydata={{3,2.5,2.1,2.5,2.2},{1.4,1.2,1.3,1.1,1.1},{0,0,0,0,0},
> {-3,-2.5,-2.1,-2.5,-2.2},{-1.4,-1.2,-1.3,-1.1,-1.1}}
> Zdata={{0,0,0,0,0},{0,0,0,0,0},{0,0,0,0,0},{0,0,0,0,0},{0,0,0,0,0}}
>
> So, is it possible to get the object surface area in real world, so in cm2
> with the ITK library?
>
> Thank you for your effort
>
> ------------------------------
> From: dzenanz at gmail.com
> Date: Wed, 10 Aug 2016 11:19:28 -0400
> Subject: Re: [ITK] Determine surface area of certain region in image
> To: matthias.b at hotmail.com
> CC: dan.muel at gmail.com; community at itk.org; blowekamp at mail.nih.gov
>
> There are nine 1s in the LabelImage, which means that your object with
> label 1 is 9 pixels big. Content of the 3DImage is irrelevant. If the
> example LabelImage content you provided does not reflect what you want, you
> need to come up with a better LabelImage (a different, better
> segmentation), derived from 3DImage.
>
> On Wed, Aug 10, 2016 at 11:11 AM, Matthias B <matthias.b at hotmail.com>
> wrote:
>
> Thank you for the code
>
> sp[0] and sp[1] is both 1 in my code. I don't get how I would get 12 in
> your example.
> The 3DImage is also never used.
>
> The spacing is also never absolute in my situation.
> Ydata could also be like this={{3,2.5,2.1,2.5,2.2},{1.4
> ,1.2,1.3,1.1,1.1},...}
>
> ------------------------------
> From: dzenanz at gmail.com
> Date: Wed, 10 Aug 2016 09:58:32 -0400
> Subject: Re: [ITK] Determine surface area of certain region in image
> To: matthias.b at hotmail.com
> CC: dan.muel at gmail.com; community at itk.org; blowekamp at mail.nih.gov
>
>
> 3DImage of size 5x5x3, and LabelImage 5x5.
>
> Dim labelShapeStatistics = New simple.LabelShapeStatisticsImageFilter()
> labelShapeStatistics.Execute(labelImage)
> Dim perimeterValue= labelShapeStatistics.GetPerimeter(1)
> Dim pixelCount = labelShapeStatistics.GetNumberOfPixels(1)  //=9 in your
> example
> Dim sp = labelImage.GetSpacing()
> Dim surfaceArea=pixelCount*sp[0]*sp[1]  //sp[0]*sp[1] should be =1.25 to
> yield a total of 12 which you want
>
> HTH,
> Dženan
>
> On Wed, Aug 10, 2016 at 9:48 AM, Matthias B <matthias.b at hotmail.com>
> wrote:
>
> I think an example is the best way to solve my problem.
>
> Let us take following 3D Data with name 3DImage as itk.simple.image
> Xdata={{-4,-2,0,2,4},{-4,-2,0,2,4},{-4,-2,0,2,4},{-4,-2,0,2,4},
> {-4,-2,0,2,4}}
> Ydata={{2,2,2,2,2},{1,1,1,1,1},{0,0,0,0,0},{-1,-1,-1,-1,-1},
> {-2,-2,-2,-2,-2}}
> Zdata={{0,0,0,0,0},{0,0,0,0,0},{0,0,0,0,0},{0,0,0,0,0},{0,0,0,0,0}}
>
> and LabelImage as itk.simple.image
> LabelImage={{{0,0,0,0,0},{0,1,1,1,0},{0,1,1,1,0},{0,1,1,1,0},{0,0,0,0,0}}
>
> The surface area with label 1 should be 12.
> Which steps (C# or C++) do I need to take to solve this?
>
> Thank you guys
>
> ------------------------------
> From: dzenanz at gmail.com
> Date: Wed, 10 Aug 2016 09:27:05 -0400
> Subject: Re: [ITK] Determine surface area of certain region in image
> To: matthias.b at hotmail.com
> CC: community at itk.org; dan.muel at gmail.com; blowekamp at mail.nih.gov
>
>
> Sorry, I have confused LabelShapeStatistics
> <https://itk.org/SimpleITKDoxygen/html/classitk_1_1simple_1_1LabelShapeStatisticsImageFilter.html>
> with LabelStatistics
> <https://itk.org/Doxygen/html/classitk_1_1LabelStatisticsImageFilter.html>
> filter.
>
> With label shape statistics, there is no intensity image, only the label
> image which you are already using as input.
>
> You generally don't mix (add) label and intensity images, you just keep
> them separate and know which two are a pair. For label statistics, you
> simply set two inputs like in this example
> <https://itk.org/Wiki/ITK/Examples/ImageProcessing/LabelStatisticsImageFilter>
> .
>
> Regards
>
> On Wed, Aug 10, 2016 at 9:19 AM, Matthias B <matthias.b at hotmail.com>
> wrote:
>
> I understand, but how do I add the label on the 3D image programmatically?
> preferable in C#, but C++ is also ok.
>
> Thank you for your help
> ------------------------------
> From: dzenanz at gmail.com
> Date: Wed, 10 Aug 2016 09:14:35 -0400
> Subject: Re: [ITK] Determine surface area of certain region in image
> To: matthias.b at hotmail.com
> CC: blowekamp at mail.nih.gov; dan.muel at gmail.com; community at itk.org
>
>
> The 3D image where the label will be applied is need for statistics such
> as mean, min and max values. If you don't care about those, you can supply
> the same image as both label and original (intensity) image. Or you can
> supply an empty (all black) image there.
>
> HTH,
> Dženan
>
> On Wed, Aug 10, 2016 at 8:47 AM, Matthias B <matthias.b at hotmail.com>
> wrote:
>
> Thank you for answering Dženan,
>
> ok, the perimeter attribute is what I need.
>
> Problem is that I don't see a way where I can
> 1. Choose a label image to define the region
> 2. Choose the 3D Image where the label will be aplied
>
> At this moment it looks for me that the label image already contains the
> 3D data, which confuses me.
>
> ------------------------------
> From: dzenanz at gmail.com
> Date: Wed, 10 Aug 2016 08:32:53 -0400
> Subject: Re: [ITK] Determine surface area of certain region in image
> To: matthias.b at hotmail.com
> CC: blowekamp at mail.nih.gov; community at itk.org
>
>
> Hi Matthias,
>
> perimeter should be surface area in 3D (which you can divide by 2 to
> eliminate back side if you have a very flat object). In 2D image, it is the
> circumference. In 2D image, you can get object's surface area by counting
> how many pixels it has and then multiplying that by the size of each pixel
> (spacing[0]*spacing[1]).
>
> Regards,
> Dženan
>
> On Wed, Aug 10, 2016 at 2:40 AM, Matthias B <matthias.b at hotmail.com>
> wrote:
>
> Thank you for answering!
>
> At this moment I get the perimeter in pixel units (not the surface area of
> my X,Y-data) of my labeled image.
> I have also really no idea how to use my 3D data with a labeled image. I
> see no way how to add 3D data to a LabelMap for example.
>
> This is what I have at the moment.
> Dim labelShapeStatistics = New simple.LabelShapeStatisticsImageFilter()
> labelShapeStatistics.Execute(labelImage)
> Dim perimeterValue= labelShapeStatistics.GetPerimeter(1)
>
> Thanks for any help, Matthias
>
>
>
> ------------------------------
> From: blowekamp at mail.nih.gov
> To: matthias.b at hotmail.com
> CC: community at itk.org
> Subject: Re: [ITK] Determine surface area of certain region in image
> Date: Tue, 9 Aug 2016 15:58:56 +0000
>
>
> Hello,
>
> You should look into the label map framework [1]. In particular the
> LabelImageToShapeLabelMapFilter[2] and the Perimeter attribute [3] [4].
>
> HTH,
> Brad
>
> [1] http://hdl.handle.net/1926/584
> [2] https://itk.org/Doxygen/html/classitk_1_1LabelImageToSha
> peLabelMapFilter.html
> [3] https://itk.org/Doxygen/html/classitk_1_1ShapeLabelObjec
> t.html#aff1209e925293c15775520ef89e97afb
> [4] http://hdl.handle.net/10380/3342
>
> On Aug 9, 2016, at 11:50 AM, Matthias B <matthias.b at hotmail.com> wrote:
>
> Hello ITK-community,
>
> At the moment I'm working with 3D Images with following structure:
> 100x80x3. Every pixel contains a X,Y,Z value.
> I want to calculate the surface area of a certain region that I have
> defined with a boolean 2D-Image (100x80).
> The surface area should only be calculated with the X,Y-data.
>
> In Matlab I have experience with this by using the function bwboundaries
> on the boolean image. This function determines the indices of the the
> boundaries in clockwise direction.  Next I take the corresponding X,Y
> values of the indices so I can calculate the surface area with the function
> polyarea.
>
> Is this possbile with the ITK-library?
>
> Thank you for your help guys.
>
>
> <https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail>
> Virusvrij. www.avast.com
> <https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail>
> _______________________________________________
> Community mailing list
> Community at itk.org
> http://public.kitware.com/mailman/listinfo/community
>
>
>
> _______________________________________________
> Community mailing list
> Community at itk.org
> http://public.kitware.com/mailman/listinfo/community
>
>
>
>
> <https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail> Virusvrij.
> www.avast.com
> <https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail>
> <#m_4865192857103803213_m_-24046198973060639_m_876262044166110828_m_1512104202195024141_m_4192781686007042514_DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2>
>
>
>
>
>
>
> _______________________________________________
> Community mailing list
> Community at itk.org
> http://public.kitware.com/mailman/listinfo/community
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/community/attachments/20160810/12533a04/attachment-0001.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: xyObject.png
Type: image/png
Size: 39697 bytes
Desc: not available
URL: <http://public.kitware.com/pipermail/community/attachments/20160810/12533a04/attachment-0001.png>


More information about the Community mailing list