Can someone advise me how to turn whitish background into pure white - but without affecting the subject in the graphic

Is there a quick to use filter in Photoshop? How about Gimp?
How about a coded solution like in PHP for example?

A second best would be to outline very roughly around an object and then have the outside fade into pure white

Not sure if any of the above makes sense!