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
 Dominant Colors
 New Topic  Reply to Topic
Author Previous Topic Topic Next Topic  

woywod

Turkey
5 Posts

Posted - Dec 28 2022 :  11:21:03  Show Profile  Reply
Hi
I am using the Proc.Get Dominant Color function, it works very well, but I want to add color numbers to it, for example, find dominant 20 colors used in the picture?

xequte

38196 Posts

Posted - Dec 28 2022 :  14:58:41  Show Profile  Reply
Hi

I'm afraid that is not supported. Take a look at the code in TImageEnProc.GetDominantColor(); to see how it is calculated (nothing complex happening there).

You might want to copy it to a local method, then use your preferred method to find the 20 highest values in the TIEIntegerMap (named hash).

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

woywod

Turkey
5 Posts

Posted - Dec 28 2022 :  15:02:49  Show Profile  Reply
thank you.
Go to Top of Page

woywod

Turkey
5 Posts

Posted - Dec 29 2022 :  11:25:47  Show Profile  Reply
Hi
I was not very good. can you write me a little example???
Go to Top of Page

xequte

38196 Posts

Posted - Jan 03 2023 :  20:57:04  Show Profile  Reply
Please email me for the latest beta. You can do it as follows:

// Get the ten most used colors
var
  i: Integer;
  usedColors : array[1..10] of TColor;
  c: TColor;
  dd: Double;
begin
  Memo1.Clear;

  // Reset used color array
  for i := Low(usedColors) to High(usedColors) do
    usedColors[i] := clNone;

  for i := 1 to 10 do
  begin
    dd := ImageEnView1.Proc.GetDominantColor( c, usedColors );
    usedColors[ i ] := c;
    Memo1.Lines.Add( format( '%s (%d%%)', [ ColorToHex( c ), Round( dd ) ]));
  end;

  // Show palette to users
  IEPromptForColor( c, usedColors, 10 );
end;


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