简体   繁体   中英

Image becomes blue masked after applying tf.image.crop_to_bounding_box and tf.image.encode_jpeg

I am trying to crop and save images from tensorflow object detection API output with following code I created using previous stack overflow questions. But after saving the image seemed to have high density of blue color. The original image has normal color. Since both cropping and encoding refer image channel for format I am not sure about the source of the issue.

Your problem here is not related to Tensorflow at all but to OpenCV.

For some reason, OpenCV loads images in a BGR format and not RGB as Tensorflow expects them to be.

Invert your first and third channels in your image before passing it to Tensorflow and everything should be fine.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM