Stack Exchange network consists of 183 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.
Select from the menu Image->Adjustments->Gradient Map. Unfold the drop-down and make sure the first gradient option is selected (from foreground to background).
Note: You might want to do some prep work first and exaggerate the contrast by playing with the levels. It might help turning the image grayscale first.