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

 

ImageEn Forum
Profile    Join    Active Topics    Forum FAQ    Search this forumSearch
Forum membership is Free!  Click Join to sign-up
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 ImageEn Library for Delphi, C++ and .Net
 ImageEn and IEvolution Support Forum
 How to select a polygon ROI and enlarge it by code
 New Topic  Reply to Topic
Author Previous Topic Topic Next Topic  

zhengyuanyi27

58 Posts

Posted - Oct 13 2020 :  13:16:53  Show Profile  Reply
I want to select a polygon ROI and enlarge the ROI by codes.

Three questions:
1. How to get the position (x,y) for each dots of the polygon?
2. How to select a polygon by codes?
3. Is it possible to enlarge the ROI using th codes like: Select( SelX1 - 10, SelY1 - 10, SelX2 - 10, SelY2 - 10 , Selx3 -10, Sely3-10,....,Slex100+10, Sley100+10,....)

Thank you very much.

xequte

38180 Posts

Posted - Oct 13 2020 :  18:45:41  Show Profile  Reply
Hi

Please the example at:

https://www.imageen.com/help/TImageEnView.AddSelPoint.html


To convert control coordinates to bitmap ones use:

https://www.imageen.com/help/TImageEnView.XScr2Bmp.html
https://www.imageen.com/help/TImageEnView.YScr2Bmp.html

Nigel
Xequte Software
www.imageen.com
Go to Top of Page

zhengyuanyi27

58 Posts

Posted - Oct 13 2020 :  21:32:04  Show Profile  Reply
Thank you very much.
Go to Top of Page

zhengyuanyi27

58 Posts

Posted - Oct 14 2020 :  05:05:54  Show Profile  Reply
Dear Nigel,
Thank you very much for your help.
By learning the example, I could get the points array for the polygon ROI selection, and make the same polygon ROI selection by code. But I don't know how to enlarge the polygon ROI on all sides, for example, Enlarge the polygon ROI selection by ten pixels on all sides. There is one example to show how to "Enlarge the selection by ten pixels on all sides" for a rectangle ROI selection, while I din't find one example for a polygon selection.
The following is the codes to get the points array for the polygon ROI selection, and make the same polygon ROI selection by code.
Could you please teach me how to enlarge the polygon selection on all sides?
Thanks a lot.


procedure TForm1.Button4Click(Sender: TObject);
var
  MyPolySelArray: array of TPoint;
  I: Integer;
begin
  // Create an array of TPoints of the polygon selection in a TImageEnView
  SetLength( MyPolySelArray, ImageEnView1.PolySelCount );
  for I := 0 to ImageEnView1.PolySelCount - 1 do
    MyPolySelArray[ I ] := ImageEnView1.PolySel[ I ];

   //how to modify the points to enlarge the ROI on all sides.
    ???
    ???


  // Create a polygon selection from an array of TPoints
     ImageEnView1.Deselect();
     for I := Low( MyPolySelArray ) to High( MyPolySelArray ) do
     begin
        ImageEnView1.AddSelPoint( MyPolySelArray[I].x, MyPolySelArray[ I ].y );
     end;
     ImageEnView1.EndSelect();
end;
Go to Top of Page

zhengyuanyi27

58 Posts

Posted - Oct 14 2020 :  05:12:45  Show Profile  Reply
I tried to use selx1, sely1, but failed for polygon ROI.
Example
// Enlarge the selection by ten pixels on all sides
With ImageEnView1 do
begin
  SelectionBase := iesbBitmap;
  Select( SelX1 - 10, SelY1 - 10, SelX2 - 10, SelY2 - 10 );
End;
Go to Top of Page

xequte

38180 Posts

Posted - Oct 14 2020 :  23:11:27  Show Profile  Reply
Hi

There is no built in method in ImageEn to do this. You can try using our internal method (but we can't provide technical support for it).

In hyieutils there are scale methods:

procedure IEScalePoints(var rpt: array of TPoint; PointCount: Integer; MinX, MinY, MaxX, MaxY: Integer; MaintainAR: Boolean = False);
procedure IEScaleDPoints(var rpt: array of TDPoint; PointCount: Integer; MinX, MinY, MaxX, MaxY: Double; MaintainAR: Boolean = False);

Which take an array of TDPoint or TPoint and scale all points to be within a rect bounded by (MinX, MinY) and (MaxX, MaxY).



Nigel
Xequte Software
www.imageen.com
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
Jump To: