We want one of the images X.png that has certain colour and alpha values such that, when it is added to white.png, makes res4.png.
There are a virtually infinite number of solutions. However, if we knew or guessed the colour values of X.png, this determines the alpha values. Alternatively, if we knew or guessed the alpha values, this would determine the colour values.
Let's try the second method. We want the darker pixels to have more transparency. So let's suppose that the alpha values are the auto-levelled brightness of res4.png. (I choose "Brightness" to ensure that any fully-saturated pixels will have 100% opacity.)
All code is Windows BAT syntax.
Code: Select all
%IM%convert res4.png -grayscale Brightness -auto-level res_alpha.png

That is the alpha channel.
Now we have guessed the alpha values, we can calculate the colour values:
Code: Select all
%IM%convert ^
res4.png white.png ^
-compose MinusSrc -composite ^
res_alpha.png ^
-compose DivideSrc -composite ^
Xt2c.png

Those are the colours.
We need to combine the colour and alpha:
Code: Select all
%IM%convert ^
Xt2c.png ^
res_alpha.png ^
-compose CopyOpacity -composite ^
Xt2ca.png

This is the extracted "yellow blob".
As before, we can check the result:
Code: Select all
%IM%convert Xt2ca.png white.png -compose Plus -composite res_X2.png
Code: Select all
%IM%compare -metric RMSE res_X2.png res4.png NULL:
The difference is 0.000456, ie 0.04%, which is almost identical to the required result. The error is probably integer quantization.
I stress, this is just one of a virtually infinite number of possible solutions.