I did some processing on an input image and saved the final image using cv2.imwrite method, input image size in 1.2MB (3120 * 4160 pixels) and the saved image is of size 2.8MB (3111 * 4151), which is more than double the size of input image.
After some research I've found that, opencv saves the image in 16bit rate, so I used scipy.misc.imsave for saving the image, this solves my problem, the resultant size decreased to 1.1MB but the colormap changes, original and processed images are not in the same color.
Can anyone please shed some light on why this happens? why did the image size almost double incase of cv2 write method and why did i lose the color using scipy write method?
from matplotlib import pyplot
import cv2
from scipy.misc import imsave
'''
read the input image here (jpg format) and image segmentation code here
'''
pyplot.imsave('py_result.jpg', final_img) #this one doubles the image size and also changes the color, why is there a size bump?
cv2.imwrite('cv2_result.jpg', final_img) #this one almost doubles the image size
imsave('scipy_result.jpg', final_img) #this one doesnot bump the image size but changes the color in output image
Here are the images for reference:
This is the input image.
The processed image saved using scipy.imsave() as you can see the blue text in the input image has changed to red.