Bayer images aren't like regular RGB images where each pixel has some red, green, and blue component. Instead, Bayer images have a singular red, green, or blue value at each pixel location with varying intensities. This is typical on a lot of sensors, so that each pixel can capture the light of a particular wavelength. The Wikipedia entry on Bayer filters might be helpful.
First you'll have to de-Bayer the image, which is to interpolate those values to RGB, and then you can convert it down to grayscale for display. This has the OpenCV tag, so assuming you're using OpenCV, you can complete both steps with cv2.cvtColor()
:
import numpy as np
import matplotlib.pyplot as plt
import cv2
path = 'bin_image.txt'
f = open(path,'rb')
height = 2500
width = 1000
bin_image = np.fromstring(f.read(), dtype=np.uint16)
bin_image.shape = (height, width)
bin_image = cv2.cvtColor(bin_image, cv2.COLOR_BayerBG2RGB)
bin_image = cv2.cvtColor(bin_image, cv2.COLOR_RGB2GRAY)
plt.imshow(bin_image, cmap='gray')
plt.show(block=True)

There are three different orders a typical Bayer image comes in; in OpenCV they are listed as BayerBG
(most common), BayerRG
, and BayerGR
. You should figure out which pattern your raw images are stored in for best results.