Do you mean: Is it possible to identify a photon as to its source; either as background or an x-ray device? Yes, in general, using directional detectors and/or shielding. Compton suppression using a detector surrounding a detector also works. Nevertheless, you cannot identify a particular photon as to its source.
Signal separation from background always entails statistical separation, i.e., background subtraction with uncertainty.
As far as you know that your net x-rays you want to detect belong the characteristic lines you can use energy resolving detectors; and the continuous spectral background due to single and multiple Compton scatter can be easily separated. But in the case of x-rays belonging to the Bremsstrahlung part you have to work with some kind of shielding via anti scatter grids and diaphragms as Joseph pointed out above.
But you have to bear in mind that background rejection by this shielding approach does not work perfectly.
In special cases reference measurement by blocking (just behind the sample) the direct x-rays coming from the x-ray source is an alternative technique; but it is still limited in its application because in this case you will only get a lower limit of your background. But here Monte Carlo simulation techniques could help to estimate the errors and correct the magnitude of the measured background.
But be carefull, when subtractiing the (noisy) backgound statistical issues come up as Joseph pointed out. However measuring the reference (background) at a very, very much larger time scale will decrease these apprehensions.