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
 CalcAverageRGB from Programmatically Defined Polygon

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
HMArnold Posted - Aug 17 2026 : 08:45:23
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
1   L A T E S T    R E P L I E S    (Newest First)
xequte Posted - Aug 18 2026 : 02:30:07
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