ImageEn for Delphi and C++ Builder ImageEn for Delphi and C++ Builder

 

ImageEn Forum
Profile    Join    Active Topics    Forum FAQ    Search this forumSearch
 All Forums
 ImageEn Library for Delphi, C++ and .Net
 ImageEn and IEvolution Support Forum
 Circle area and perimeter calculations

Note: You must be registered in order to post a reply.
To register, click here. Registration is FREE!

View 
UserName:
Password:
Format  Bold Italicized Underline  Align Left Centered Align Right  Horizontal Rule  Insert Hyperlink   Browse for an image to attach to your post Browse for a zip to attach to your post Insert Code  Insert Quote Insert List
   
Message 

 

Emoji
Smile [:)] Big Smile [:D] Cool [8D] Blush [:I]
Tongue [:P] Evil [):] Wink [;)] Black Eye [B)]
Frown [:(] Shocked [:0] Angry [:(!] Sleepy [|)]
Kisses [:X] Approve [^] Disapprove [V] Question [?]

 
Check here to subscribe to this topic.
   

T O P I C    R E V I E W
yeohray2 Posted - Feb 21 2022 : 02:48:35
Hi, I needed to create a circular region of interest. To do that, I let the user create a ellipse-type shape layer using mlCreateShapeLayers, then convert that shape to a polyline. That all works fine.

However, when I calculate the area and length using the polyline layers' CalculateArea and CalculateLength methods respectively, the values differ compared to using the 'normal' circle formulas i.e. pi * (r squared) and 2 * pi * r.

Is it because the polyline circle is made up of many small shapes, hence the different values for area and length?

Thanks in advance.

Regards
Ray Mond
4   L A T E S T    R E P L I E S    (Newest First)
yeohray2 Posted - Feb 23 2022 : 20:44:55
Hi Nigel,

Thanks, I wasn't aware of that function, will take a look at it.

Ray
xequte Posted - Feb 23 2022 : 15:01:54
Hi Ray

So it is not always elliptical?

If it is, you can use IEPointInEllipse()

Nigel
Xequte Software
www.imageen.com
yeohray2 Posted - Feb 23 2022 : 10:52:20
Hi, thanks for the suggestion to use text layers. However, I need to also calculate values for the area in the shape. These are DICOM images, and I'm using the IEIsPointInPoly function to calculate the mean and standard deviation for the HU values for the area within the shape.

Ray
xequte Posted - Feb 22 2022 : 20:46:50
Hi Ray

For elliptical and rectangular measurement you are better to use a TIETextLayer with a visible BorderShape.

Compare the following:

  // THREE WAYS TO CALCULATE PERIMETER AND AREA OF AN ELLIPSE

  // 1. Shape Layer
  ImageEnView1.LayersAdd( iesEllipse, 10, 10, 400, 250 );
  ImageEnView1.CurrentLayer.RulerUnits := ieuPixels;
  memo1.Lines.Add( 'Shape Perim : ' + FloatToStr( ImageEnView1.CurrentLayer.RulerValue( ierLength )));
  memo1.Lines.Add( 'Shape Area  : ' + FloatToStr( ImageEnView1.CurrentLayer.RulerValue( ierArea )));

  // 2. Text Layer
  ImageEnView1.LayersAdd( ielkText, 10, 410, 400, 250 );
  ImageEnView1.CurrentLayer.FillColor := clRed;
  ImageEnView1.CurrentLayer.RulerUnits := ieuPixels;
  ImageEnView1.CurrentLayer.RulerMode := iermLabel;
  TIETextLayer( ImageEnView1.CurrentLayer ).BorderShape := iesEllipse;
  memo1.Lines.Add( 'Text Perim  : ' + FloatToStr( ImageEnView1.CurrentLayer.RulerValue( ierLength )));
  memo1.Lines.Add( 'Text Area   : ' + FloatToStr( ImageEnView1.CurrentLayer.RulerValue( ierArea )));

  // 3. Polyline Layer (less accurate)
  ImageEnView1.LayersAdd( iesEllipse, 10, 810, 400, 250 );
  TIEShapeLayer( ImageEnView1.CurrentLayer ).ConvertToPolylineLayer();
  IEGlobalSettings().LayerCurveQuality := 36; // Less points to reduce complexity
  memo1.Lines.Add( 'Poly Perim   : ' + FloatToStr( TIEPolylineLayer( ImageEnView1.CurrentLayer ).CalculateLength( ieuPixels  )));
  memo1.Lines.Add( 'Poly Area    : ' + FloatToStr( TIEPolylineLayer( ImageEnView1.CurrentLayer ).CalculateArea( ieuPixels  )));

  ImageEnView1.Update;

  { Returns:
  Shape Perim : 1047.851
  Shape Area  : 78539.816
  Text Perim  : 1047.851
  Text Area   : 78539.816
  Poly Perim  : 1028.604
  Poly Area   : 77512.826
  }


Please see: https://www.imageen.com/help/TIELayer.RulerValue.html
But note that documentation is outdated as now all layer types support ierArea and ierLength.

Nigel
Xequte Software
www.imageen.com