Greyscale image to binary image conversion using operations on pixel
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.