I have rendered an object using hdri and lamp lights. Using render layers i want to have object and shadows only. I show you my nodes. I need to know how to transform white pixels to alpha channel using nodes.
One solution would be to enable a shadow pass, invert the colors and use that as alpha using a Set Alpha node.
The Dilate/Erode will help with the antialiasing of the shadow pass.
Now... if you hate the previous option and absolutely want to use the layers you have set up, you can try this:
From the background layer you can indeed subtract the shadow layer, creating a black and white image that holds the shadow information only. But use difference instead of subtract (also, you don't need the invert node because you can invert the image with the curves node, but you do need to get rid of the color information). Next, combine that image with the alpha channel of the sphere, and use the resulting image as alpha channel on the mix of the shadow and the sphere...