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
 Gray or Color
 New Topic  Reply to Topic
Author Previous Topic Topic Next Topic  

graph_man

260 Posts

Posted - Jul 20 2021 :  17:38:56  Show Profile  Reply
All opened images are 24bit.

ImageEnView1.IO.Params.BitsPerSample = 8;
ImageEnView1.IO.Params.SamplesPerPixel = 3;

How to determine which image is color or gray?

xequte

6248 Posts

Posted - Jul 21 2021 :  06:19:26  Show Profile  Reply
Hi

You can use:

If ImageEnView1.IEBitmap.IsGrayScale() then
  ShowMessage( 'Image is gray scale' );

https://www.imageen.com/help/TIEBitmap.IsGrayScale.html

For certain image formats you can do it more quickly using the image properties.

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

graph_man

260 Posts

Posted - Jul 21 2021 :  07:40:19  Show Profile  Reply
Thanks, but for some reason this function does not always work.
I sent you the test file by e-mail.
Go to Top of Page

xequte

6248 Posts

Posted - Jul 21 2021 :  19:18:01  Show Profile  Reply
That is because the image is not truly gray-scale. For instance, look at pixel 715,2017, you will see that its RGB value is (33,30,25).

For the next update I have added a tolerance value to IsGrayScale, so this works:

If ImageEnView1.IEBitmap.IsGrayScale() then
  ShowMessage( 'Image is gray scale' )
else
If ImageEnView1.IEBitmap.IsGrayScale(10) then
  ShowMessage( 'Image is almost gray scale' )
else
  ShowMessage( 'Image is colored' );




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

graph_man

260 Posts

Posted - Jul 22 2021 :  06:07:55  Show Profile  Reply
Thanks.
How to get this update?

ps
Is there a way to use a workaround by counting the number of colors in an image?
Go to Top of Page

xequte

6248 Posts

Posted - Jul 22 2021 :  06:47:51  Show Profile  Reply
Hi

You can email me for the beta, or await the official release in a couple of weeks.

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