How to convert Image to Grayscale by using HLS colorspace?
Many image processing application provide functionality to convert images to gray scale. How they do it? There are many ways to convert an image to gray scale. The common method is to get the gray value of a pixel by the following equation GrayValue = 0.3*Red + 0.59*Green + 0.11*Blue There is another method to convert an image to grayscale – By using HLS colorspace. I’ve already explaned about HLS color space here – http://weseetips.com/2008/05/22/convert-color-in-rgb-to-hls-and-vice-versa/ In the HLS color space, we can represent a pixel in Hue, luminosity and Saturation, where Saturation represents the colorfulness of the color or how colorful the color is. If the saturation goes to minimum, that color will become grayscale and if it goes to maximum the more fluorescent it will become. 1) Get each pixel in image in RGB. 2) Convert RGB to HLS and get the saturation. 3) Set saturation to 1 and convert back to RGB. 4) Set the new image pixel. See the code snippet below. Please note that
Related Questions
- I have a CIELAB workflow. If I want to print image files in CIELAB colorspace can I use ColorPro to select my output profile and rendering intent then just print the files?
- How to convert document including the background color and image?
- What is the best freeware software to convert files to ISO image?