Changing Pixels On Texture/Surface

Hello Everyone.

I’m new to SDL and have been learning it with various tutorials. My goal is to make a program that can automatically cutout a subject from their background. The background pixels are known. So I simply need to compare the pixels. If the pixel in the new image is different from the known background I know to save that pixel since it’s a pixel from my subject.

I’ve been running in to issues with my current approach via the lazyFoo tutorials and was wondering how the more experienced users on this forum would tackle this. Would you work with surfaces only? Or is it easier to work with the pixels if they are both SDL_Textures? I feel like there is something fundamental I’m missing that is causing my program to crash whenever I access the pixels. I also then need to save the resulting surface/texture to a file.

I’d like to get to the point where I can have something like this

if(backgroundPixels[i] == subjectPixels[i])
{
    subjectPixels[i] = transparentValue;
}

Thanks in advance for anyone willing to help.

In BasicC:

you have several routines, e.g .: GetBitmap, GetImg, ImgBitmap
You can analyze it yourself …