I'm using magic wand to separate the background and foreground (an apple in the example). The goal is to get a binary image, with white pixels standing for the foreground. The problem here is the foreground layer is not pure white. Photoshop is always "matting" the edges such that quite a few pixels become something like (240,243,242). It happens even when I use "edit-clear" a selected area. Is there a way to get a "hard" solution? Either the background is pure black or the foreground is pure white will be good enough; both is not necessary. Thanks!
You will want to disable the anti-alias setting on your Magic Wand selection tool. When you have the Magic Wand active, check out your options bar on top:
If you remove the checkmark, the Wand will select hard egdes. If you don't have the options bar, make it visible with
Window > Options. (That's CS6 terminology. They renamed it 'status' in CC 2014, iirc.)
edit: In order to select a single colour (only your hard whites, for example), you may also want to set the
Tolerance to 0. Tolerance is a measure for the amount of slightly different hues the Wand will inlcude in the selection. When set to 0, it will only select pixels in the exact colour of the pixel you click on.