convert image in rgb image

pixels are scanned row wise and converted into red , green or blue based on dominant color. Output image is RGB.