Greyscale image to binary image conversion using operations on pixel Previously, I tried convert a color image into a greyscale image by using pixel values of an image from a simple formula :-

Grey = 0.3*Red + 0.58*Green + 0.11*Blue


After that, I wanted to convert the greyscale image into a binary image &amp; I used two different techniques :

NOTE : Red, Green &amp; Blue are variables storing Greyscale intensity of the Pixel.

1. Algorithm 1:

if Red &lt;= 127:
   Red = 0
   Green = 0
   Blue = 0
else:
   Red = 1
   Green = 1
   Blue = 1


2. Algorithm 2:

if Red &lt;= AvgIntensity:
   Red = 0
   Green = 0
   Blue = 0
else:
   Red = 1
   Green = 1
   Blue = 1


where, AvgIntensity represents the average intensity of all the pixels of the image. 

(Obviously,) the algorithms turned out to be wrong, producing incorrect output. So, I wanted to know about the correct way for greyscale to binary image conversion.
You are looking for a thresholding algorithm.  There is no correct or incorrect algorithm.  Some methods tend to work better than others on specific types of images; which method is best may depend on what kind of images you usually work with. I suggest studying standard thresholding methods and picking one.