Colorize hidden parts from camera projection
You've indicated a few details in your comments: you're using the perspective of the camera for your UV projector; you want to do this using only scriptable tools (no mouse strokes).  For that, the linked answer you gave won't help you.
You need to make a mask for your projected image.  As I indicated in comments, the easiest way to make this mask is just by hand, with texture painting.  But it's not impossible to do it another way:

Make your object flat shaded.  Give it a diffuse material.  If it's not UV mapped, give it a non-overlapping UV map (a smart project or lightmap project would be fine.)

Place a point light at the location of your UV projector camera.  Set the radius to 0 and the light to something really high (like 100,000).

If necessary, remove everything but the object and point light from renders.  Set bounces to 0.

Create an image texture node in your material and bake combined to a new image.  Save your image.

Create compositing nodes using your baked image (not a render).  For each pixel of your image, check to see if the brightness is greater than 0.  Make your output 1 if it is, 0 if it isn't.  Set your color management display device to None.  Set your rendering resolution to the same resolution as your baked image.  Render.  Save the render.  As necessary, revert to settings used at the start of the process.


You now have a mask created using only scriptable operations that represents the occlusion (only) from your UV projector.

Let me know if that image is bugging out for you-- Imgur looks like it's freaking out or something.  Check comments for a different image host.