- DIP - Computer Vision and Graphics
- DIP - Optical Character Recognition
- DIP - JPEG compression
- DIP - Introduction to Color Spaces
- DIP - High Pass vs Low Pass Filters
- DIP - Convolution theorm
- DIP - Fourier series and Transform
- DIP - Frequency Domain Analysis
- DIP - Laplacian Operator
- DIP - Krisch Compass Mask
- DIP - Robinson Compass Mask
- DIP - Sobel operator
- DIP - Prewitt Operator
- DIP - Concept of Edge Detection
- DIP - Concept of Blurring
- DIP - Concept of Masks
- DIP - Concept of convolution
- DIP - Gray Level Transformations
- DIP - Histogram Equalization
- DIP - Introduction to Probability
- DIP - Histogram Stretching
- DIP - Histogram Sliding
- DIP - Image Transformations
- DIP - Brightness and Contrast
- DIP - Histograms Introduction
- DIP - Concept of Dithering
- DIP - ISO Preference curves
- DIP - Concept of Quantization
- DIP - Gray Level Resolution
- DIP - Pixels Dots and Lines per inch
- DIP - Spatial Resolution
- DIP - Zooming methods
- DIP - Concept of Zooming
- DIP - Pixel Resolution
- DIP - Concept of Sampling
- DIP - Grayscale to RGB Conversion
- DIP - Color Codes Conversion
- DIP - Types of Images
- DIP - Concept of Bits Per Pixel
- DIP - Perspective Transformation
- DIP - Concept of Pixel
- DIP - Camera Mechanism
- DIP - Image Formation on Camera
- DIP - Concept of Dimensions
- DIP - Applications and Usage
- DIP - History of Photography
- DIP - Signal and System Introduction
- DIP - Image Processing Introduction
- DIP - Home
DIP Useful Resources
Selected Reading
- Who is Who
- Computer Glossary
- HR Interview Questions
- Effective Resume Writing
- Questions and Answers
- UPSC IAS Exams Notes
Grayscale to RGB Conversion
We have already define the RGB color model and gray scale format in our tutorial of Image types. Now we will convert an color image into a grayscale image. There are two methods to convert it. Both has their own merits and demerits. The methods are:
Average method
Weighted method or luminosity method
Average method
Average method is the most simple one. You just have to take the average of three colors. Since its an RGB image, so it means that you have add r with g with b and then spanide it by 3 to get your desired grayscale image.
Its done in this way.
Grayscale = (R + G + B / 3)
For example:
![rgb](/dip/images/rgb.jpg)
If you have an color image pke the image shown above and you want to convert it into grayscale using average method. The following result would appear.
![rgb_gray](/dip/images/rgb_gray.jpg)
Explanation
There is one thing to be sure, that something happens to the original works. It means that our average method works. But the results were not as expected. We wanted to convert the image into a grayscale, but this turned out to be a rather black image.
Problem
This problem arise due to the fact, that we take average of the three colors. Since the three different colors have three different wavelength and have their own contribution in the formation of image, so we have to take average according to their contribution, not done it averagely using average method. Right now what we are doing is this,
33% of Red, 33% of Green, 33% of Blue
We are taking 33% of each, that means, each of the portion has same contribution in the image. But in reapty thats not the case. The solution to this has been given by luminosity method.
Weighted method or luminosity method
You have seen the problem that occur in the average method. Weighted method has a solution to that problem. Since red color has more wavelength of all the three colors, and green is the color that has not only less wavelength then red color but also green is the color that gives more soothing effect to the eyes.
It means that we have to decrease the contribution of red color, and increase the contribution of the green color, and put blue color contribution in between these two.
So the new equation that form is:
New grayscale image = ( (0.3 * R) + (0.59 * G) + (0.11 * B) ).
According to this equation, Red has contribute 30%, Green has contributed 59% which is greater in all three colors and Blue has contributed 11%.
Applying this equation to the image, we get this
Original Image:
![rgb](/dip/images/rgb.jpg)
Grayscale Image:
![weighted_gray](/dip/images/weighted_gray.jpg)
Explanation
As you can see here, that the image has now been properly converted to grayscale using weighted method. As compare to the result of average method, this image is more brighter.
Advertisements