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
 Intelligent color reducing algorithm?
 New Topic  Reply to Topic
Author Previous Topic Topic Next Topic  

PeterPanino

933 Posts

Posted - Apr 14 2024 :  10:28:38  Show Profile  Reply
I am looking for a content-based color-reducing algorithm that intelligently simplifies an image's colors by detecting the most used colors and reducing them to a few primary colors. It should reduce the palette to the most significant colors while maintaining the image's overall appearance.

How can I do this in ImageEn, perhaps with IEVision?

xequte

38608 Posts

Posted - Apr 14 2024 :  19:20:28  Show Profile  Reply
Hi

Yes, you can use ConvertTo:

http://www.imageen.com/help/TImageEnProc.ConvertTo.html

It will reduce colors in a optimized way, either using the Kohonen algorithm or median cut:

https://www.imageen.com/help/TIEGlobalSettings.ColorReductionQuality.html

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

PeterPanino

933 Posts

Posted - Apr 14 2024 :  23:41:06  Show Profile  Reply
Hi Nigel

I use this code to reduce the colors each time I click:

procedure TformPreview.mReduceColorsClick(Sender: TObject);
const
  ColorThresholds: array[0..6] of Integer = (256, 128, 64, 32, 16, 8, 4);
var
  CC, i: Integer;
begin
  CC := ImageEnViewPreview.Proc.CalcImageNumColors();
  for i := Low(ColorThresholds) to High(ColorThresholds) do
  begin
    if CC > ColorThresholds[i] then
    begin
      ImageEnViewPreview.Proc.ConvertTo(ColorThresholds[i], ieOrdered);
      Break; // Ensures the loop breaks after applying the first valid conversion
    end;
  end;
  ImageEnViewPreview.Update;
end;


How would you optimize this?
Go to Top of Page

xequte

38608 Posts

Posted - Apr 15 2024 :  04:33:43  Show Profile  Reply
Hi

I can't see a better way of doing that.

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