Hi.
I have a task to perform and it’s not always working correctly: loading a 8-bit RGB color .BMP file from the filesystem, watermarking it and then save it.
The watermarking process is just fine and also the imdecode/imencode (or imread/imwrite) works for many of my images (~80.000) but sometimes it fails with this kind of result:
The original bitmap is 1193x2048 and I’d love to share it but I don’t have the rights for that (Boeing/Jeppesen property).
No matter what flags I use for reading or writing the image I get this data that looks like each line is “duplicated” but with the wrong background.
...
cv::Mat _image = cv::imread("something.bmp", cv::IMREAD_COLOR);
cv::imwrite("something_else.bmp", _image);
...
The BMP has a standard “BM” header and a simplified color table where only 4~6 colors are mentioned (this are aircraft navigation charts and are pretty simple images).
The code I shared is in C++ but I also tried in Python:
import cv2 as cv
img = cv.imread("source.bmp")
cv.imwrite("destin.bmp", img)
…with the same exact result!
I tried to open the original .bmp files with paint (Windows), Mirage (Linux), Gimp (Linux)… they are fine: no weird colors or errors!
Do you have any idea what I’m doing wrong or how to correct this behavior?
Thanks.