[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 174
  • Last Modified:

Greyscale or not

hi .. everyone ...
i have a problem here about the algorithm
for classifiying an image into grayscale
image and not. And if there is Delphi
source code please tell me ok ...

Regards,
Billy
0
Bilce
Asked:
Bilce
  • 2
  • 2
  • 2
1 Solution
 
robert_marquardtCommented:
Now what IS the problem?
A picture is grayscale if for all pixels the R, G and B values are the same.
Making a colored picture grayscale is calculating the brightness of the pixel. A formula which i do not know.
0
 
robert_marquardtCommented:
That is for each pixel R, G and B value of this pixel has to be the same.
0
 
scrapdogCommented:
to convert from color to greyscale:

brightness = (R + G + B) / 3

set R, G, and B to the value in brightness

0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
edeyCommented:
Actually you'd prob. want to at least weight your rgb values, something like this:

brightness := round(sqrt((r*r+g*g+b*b)/3));

Better yet you'd convert to HSV, extract the V & convert back to RGB.  This results in much better contrast & picture quality.  I believe this is because we aren't equaly sensitive to all three primary colours. Here's a pretty good approximation I found at Earl Glynn's site: http://www.efg2.com (great site BTW):

brightness :=((r Shl 5)+(g Shl 6)+(b*12)) Div 108;


GL
Mike
0
 
scrapdogCommented:
Thanks edey for that HSV formula.  I used it and did notice an improvement.
0
 
edeyCommented:
Excellent, Glad to be of service :)

Gl
Mike
0

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

  • 2
  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now