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 build a palette from pixel selected
 New Topic  Reply to Topic
Author Previous Topic Topic Next Topic  

yogiyang

India
725 Posts

Posted - Jun 09 2018 :  03:00:41  Show Profile  Reply
Hello,

I am trying to build a color palette from a 8bit image based on selected pixels.

How can I achieve this?

TIA


Yogi Yang

xequte

38176 Posts

Posted - Jun 10 2018 :  19:36:08  Show Profile  Reply
Hi Yogi

How about if you copy the selection to a bitmap and use CalcImagePalette:

https://www.imageen.com/help/TImageEnProc.CalcImagePalette.html

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

yogiyang

India
725 Posts

Posted - Jun 11 2018 :  00:29:07  Show Profile  Reply
Hello Nigel,

Thanks for the tip. I tried that but what I am getting is not acceptable.

The image that I am using for testing is attached here. In the attached image just select a small portion of the image like say the RED color square and generate a palette. It contains many colors and some of the colors are just not possible in a red color pixels.

TIA




Yogi Yang
Go to Top of Page

xequte

38176 Posts

Posted - Jun 12 2018 :  16:30:44  Show Profile  Reply
Please show me your code.



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

yogiyang

India
725 Posts

Posted - Jun 20 2018 :  02:22:13  Show Profile  Reply
Hello,

The code that I am using:

// Load images in native format
ImageEnView1.IO.NativePixelFormat := true;
with ImageEnView1.IO do
    LoadFromFileAuto( ExecuteOpenDialog());
// if the bitmap is not 8 bit paletted then convert it
if ImageEnView1.IEBitmap.PixelFormat <> ie8p then
    ImageEnView1.IEBitmap.PixelFormat := ie8p;
//Build the Palette
IEColorPalette1.AssignPalette( ImageEnView1 );


I also tried out: CalcImagePalette

But the result is the same.

TIA


Yogi Yang
Go to Top of Page

xequte

38176 Posts

Posted - Jun 21 2018 :  18:48:24  Show Profile  Reply
Hi Yogi

Your code looks correct. What problem does it give you? Please post an example image too.


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

yogiyang

India
725 Posts

Posted - Jun 22 2018 :  01:22:21  Show Profile  Reply
I am attaching three sample images for testing.

Just compile and start the demo app (Demos\ImageAnalysis\Palette\Palette.exe)

Open each file and see what comes up in the color palette.

It show many colors which just does not exist in the image!

TIA

attach/yogiyang/20186221225_ImageSwatches.zip
14.27 KB


Yogi Yang
Go to Top of Page

xequte

38176 Posts

Posted - Jun 24 2018 :  22:46:45  Show Profile  Reply
Hi Yogi

The Palette demo uses AssignPalette, which shows all the colors of the image's palette, even those not being used. You need to use CalcImagePalette, to only get those in use.

Anyway, for v8.0.0 ready before the end of the week, I've added a parameter to AssignPalette to show only the used colors.

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