convert image to binary
I've converted the image in grayscale, and I need to convert it to binary, any Ideas?!!!
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Jignesh KumarPosted Mar 4, 2021, 4:00 AM
Kip HackmanPosted Mar 3, 2021, 8:13 PM
Ahmed FahmyPosted Sep 14, 2017, 8:44 PM
Munesh SharmaPosted Oct 16, 2014, 6:59 AM
for more go here
http://dotnet-munesh.blogspot.in/2014/05/how-to-save-image-in-database-in-window.html
Aldemir NolanPosted Oct 16, 2014, 3:16 AM
Some of the replies here don't seem to understand what "binary" means. I don't think you on mean "byte data", but you want "binary color", which means pure black and white. Is this correct?
The article suggested by Selva is a good approximation for converting color to grayscale. However, it neither accurately converts to grayscale nor does it convert to pure black and white like the original question.
The article calculates the gray level as the direct average of the red, green and blue values, or:
Gray = ( R + G + B) / 3
A more accurate value gives more weight to green because the human eye is much more sensitive to it. One common algorithm is this:
Gray = (0.25 R + 0.62 G + 0.13 B) / 3
However, if the goal is to convert to black and white instead of gray, more processing is needed depending on your final goal. At some stage you might be better off using a dedicated image processing library such as Leadtools.Hemant SrivastavaPosted Oct 3, 2014, 10:22 AM
Here is the link where I am converting an Image into BinaryArray and a BinaryArray back to image:
http://hemant-srivastava.blogspot.com/2012/07/converting-any-image-into-bytearray-and.html
Abhishek KumarPosted Oct 3, 2014, 5:35 AM
Follow the below article.
http://www.codeproject.com/Articles/109013/Image-in-Csharp-Save-Resize-and-Convert-to-Binary
Abhishek
Selva GanapathyPosted Oct 3, 2014, 4:39 AM
Hi Klajdi Paja,
Using the following code snippet you can canvert an image to a binary.
BinaryReader r = new BinaryReader();
byte[] b= r.ReadBytes(image);
Also the following article may help you to image conversion
http://www.c-sharpcorner.com/Blogs/13672/convert-a-color-image-into-black-and-white-image.aspx
Regards,
Selva Ganapathy K