I have an image (.jpg image) and I want to extract the background from the original image. I googled a lot, but only found tutorials on extracting foreground images.
I took the code from another question https://stackoverflow.com/a/318618/ The code works fine for me, and I have successfully extracted the foreground (according to my requirements). Now I want to completely remove this foreground from the original image. I want it to be something like this: -
Background = Original Image - Foreground
White space can be filled in black or white. How can i achieve this?
I tried using this technique: -
Mat background = image2 - foreground;
but he gives a complete black image.
The code: -
#include <opencv2/opencv.hpp>
Note. I am a beginner novice and do not know about it now. I will be very grateful if you can publish the full code (as I need) or simply place the lines of code and tell me where these lines of code will be placed. Thanks.
PS This is my second question at StackOverflow.com. apologies ... if you do not follow any agreement.
c ++ opencv
Omar tariq
source share