When you imread() a .jpg image, you will very likely get a uint8 array back. You then double() that uint8 array, getting a double array. You then do something with that double array. Finally you try to imwrite() the double array. But in MATLAB, the data type that you imwrite() determines what range of values are expected; for uint8() the range 0 to 255 is expected but for double() the range 0 to 1 is expected. Since your values are likely in the range 0 to 255 (because that what was read in) but are datatype double, MATLAB will think that nearly all of the values are maximum saturation.
The solution is to use uint8() on the data to be written:
imwrite(uint8(output_image), 'NewFile.jpg')
Best Answer