Click here to Skip to main content
12,892,589 members (48,351 online)
Click here to Skip to main content
Alternatives (4)
Add your own
alternative version

Tagged as


5 bookmarked
Posted 13 Jan 2012

Convert RGB to Gray Scale without using Pointers

, 13 Jan 2012 CPOL
Simple way of Converting RGB Image to Gray Scale Image without using any pointers


Members may post updates or alternatives to this current article in order to show different approaches or add new features.

13 Jan 2012
Luc Pattyn
I'm afraid there are better ways doing this, based on the power of the framework; in this case ColorMatrix is the tool to use. See e.g. here[^] (warning: make sure to use correct matrix elements, corresponding to the coefficients mentioned in the tip/trick).:)
17 Jan 2012
You shouldn't rely on methods from the .NET classes (Bitmap::SetPixel, Bitmap::GetPixel, Color::FromArgb) in the inner loop as these are called intensively, million times per image, and their implementation are opaque to you.If their implementation is opaque to the compiler too, no code...
17 Jan 2012
Paw Jershauge
I would use the colormatrix for that... Look here under the grayscale method
18 Jan 2012
A piece of warning, though: the LockBits method is not a transparent one, it does image format conversion before returning a pointer to the bitmap (this is why it has a PixelFormat argument). And conversely, the UnlockBits method converts back to the original format. My best guess is that when...


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

CEO Integrated Ideas
India India
gasshopper.iics is a group of like minded programmers and learners in codeproject. The basic objective is to keep in touch and be notified while a member contributes an article, to check out with technology and share what we know. We are the "students" of codeproject.

This group is managed by Rupam Das, an active author here. Other Notable members include Ranjan who extends his helping hands to invaluable number of authors in their articles and writes some great articles himself.

Rupam Das is mentor of Grasshopper Network,founder and CEO of Integrated Ideas Consultancy Services, a research consultancy firm in India. He has been part of projects in several technologies including Matlab, C#, Android, OpenCV, Drupal, Omnet++, legacy C, vb, gcc, NS-2, Arduino, Raspberry-PI. Off late he has made peace with the fact that he loves C# more than anything else but is still struck in legacy style of coding.
Rupam loves algorithm and prefers Image processing, Artificial Intelligence and Bio-medical Engineering over other technologies.

He is frustrated with his poor writing and "grammer" skills but happy that coding polishes these frustrations.
Group type: Organisation

116 members

| | Privacy | Terms of Use | Mobile
Web02 | 2.8.170424.1 | Last Updated 14 Jan 2012
Article Copyright 2012 by Grasshopper.iics
Everything else Copyright © CodeProject, 1999-2017
Layout: fixed | fluid