I'm using the Boost-GIL library for some image-processing tasks. First, I color separate the image into RGB channels and perform operations on each channel. Something odd came to my notice in terms of the reversibility of the operation. The principle of reversibility would imply if we re-combine the channels to re-construct the original image we should get back the original image without any difference with the original. Unfortunately, I do not see that behavior. I've attached the image pair as an illustration of the problem. The left one is the original and the right one is re-combined image. Clearly, there is higher precedence of blue color. I used the Mathematica ColorCombine function for the re-combination operation and as a cross-check I used Mathematica ColorSeparate function to perform the same color separation operation. After applying ColorCombine on the ColorSeparated channels, I get back the original image without a single pixel of difference. Also, I verified this on two separate images and observed that only the blue channel mismatches with the Mathematica implementation. Since, color-sepration is a very fundamental operation it should be fixed immediately if there are issues in the library. My code to color separate from a raw .jpg image is given below.
boost::gil::rgb8_image_t img;
std::string image_path="Eiffel_towner.jpg";
boost::gil::read_image(image_path.c_str(), img, boost::gil::jpeg_tag());
auto pixel = std::move(img_view(x,y));
boost::gil::rgb32f_pixel_t pixel_f(pixel);
float pixel_red = boost::gil::at_c<0>(pixel_f);
float pixel_green = boost::gil::at_c<1>(pixel_f);87676
float pixel_blue = boost::gil::at_c<2>(pixel_f);```
[![Eiffel Tower][1]][1]
[1]: https://i.stack.imgur.com/njSL0.png
Aucun commentaire:
Enregistrer un commentaire