how to set white or black background of textures transparent
Alphas are far more nuanced than people would typically know, or choose to acknowledge.

An associated alpha image is effectively a record of emission (RGB pixels) and occlusion (the alpha channel). If we view such an encoded image without alpha, it would appear as nothing more than the image composited against black.

If we apply this logic to your question, we can see that we have the emission recorded fine. We simply don't have the occlusion. In short, with a composited on black image, we are already halfway there. The second half would be via a generation of the alpha channel.

There are two manners to generate alpha, and given that this is a fire-like explosion, it is a perfect example.

When captured in an image, fire has both occluded areas, where particulate and such occlude a given ratio of a pixel's window. That is, we could consider a pixel grid as being a wire screen, and the unknown geometry that lands across any particular grid as being the occlusion ratio. Where there is solid geometry occluding the pixel grid, we set the alpha to 100%. Where there is zero occlusion, the alpha is set to 0%.

But what about fire and the atmospheric glowing emission that isn't occluding at all? That would be 0% alpha and any nonzero RGB value.

So in your above image, you have two ways to set alpha:


You could simply use a math node to deduce the maximum value in the RGB triplet, and use that as your Set Alpha factor. After doing so, your image would be 100% correct when using associated alpha overs (aka the horrible term premultiplied).
If you used a more nuanced approach, such as converting to BW via the node, you would end up with an alpha channel that would represent averaged luminance, which will result in pixels whose alpha is lower than the RGB values. When using a proper alpha over instruction, the fire would occlude the degree of alpha and emit the remainder.


The following demonstrates such a node tree that covers both versions, the upper being the alpha that will embody a glowing bit of emission and some occlusion, with the lower being a more "vanilla" alpha where the max(RGB) represents the amount of knockout:


And the result, in animated form to demonstrate differences:


If you try either of these techniques, you will likely find that the latter has a more nuanced look because it is closer to a physical reality within the confines of our image manipulation models.

Always remember, there is only one true alpha, and it is the one that can represent both occlusion and emission. It is not unassociated (aka the awful terms straight, key, etc.)

Hope this helps...

PS: This is why frequently element plates will always be shot against black, not white. If it isn't going to be keyed, black is the ideal background.