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
 CalcAverageRGB from Programmatically Defined Polygon
 New Topic  Reply to Topic
Author Previous Topic Topic Next Topic  

HMArnold

USA
36 Posts

Posted - Aug 17 2026 :  08:45:23  Show Profile  Reply
I have areas of an image that contains polygons of know coordinates that I'm trying to get an average RGB from.

What is the best way to define the nodes of the polygon, select that polygon, then get the average RGB of the pixels from only within the polygon.

There is an example of CalcAverageRGB in a Demo, but it appears to only work from an interactive selection.

Here is what I have tried...

        Image1.BeginSelect;
        for x := 0 to Length(Mask.Polygon[0])-1 do
          Image1.AddSelPoint(Mask.Polygon[0][x].X, Mask.Polygon[0][x].Y);
        Image1.EndSelect;
        Image1.Update;
        RGB := Image1.Proc.CalcAverageRGB(0);
        ListBox1.Items.Add('Avg RGB : '+CxIn(RGB.r,4)+CxIn(RGB.g,4)+CxIn(RGB.b,4));

But it appears to still give the average of the entire image, not just within the polygon.

Also, is there anything like GetDominantColor that can be used within a selection?

Thanks

HM Arnold

xequte

39510 Posts

Posted - Aug 18 2026 :  02:30:07  Show Profile  Reply
Hi

Your code works fine when I test it here (different result for the selection than the whole image). What version of ImageEn are you using? Perhaps you could create a small project that shows the issue?

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