我正在读取图像并对蓝色通道进行一些处理,而不更改红色和绿色通道。
当我处理完蓝色通道后,我将三个通道合并回一个 RGB 图像。当我使用 imshow 查看频道时,一切正常,我可以看到我所做的更改仅影响蓝色频道,不会影响红色和绿色频道。
至此,一切正常!
但是当我使用 imwrite 保存图像时,生成的图像略有不同,因为在蓝色通道上所做的更改似乎会传播到红色和绿色通道,就像 imwrite 在 3 个通道之间做某种平均:
image = imread('image.jpg', IMREAD_COLOR);
split(image, channels);
// Create some changes on channels[0]
merge(channels, 3, image);
// Up to this point every thing is alright
imwrite("modified.jpg", image); // Image changes when written;
Run Code Online (Sandbox Code Playgroud)
有什么解决方案可以避免这种行为吗?