# Display layer where luminosity is greater than fixed value

I had a paper-and-ink image with a thick black border around it. Past the black border was very dirty white paper. I wanted to (using Photoshop) replace the dirty white paper with pure white, or possibly with paper texture cloned from other parts of the image.

I realized that there was a reasonable gap in luminosity between the border and the dirt, so I figured what I could do is pick a shade of grey somewhere inside that gap, let's call it the threshold, that's brighter than the border, and darker than the dirt. Then just use the polygonal lasso tool to select right down the middle of the black border (so no finicky feathered edges on the selection, just nice straight lines) and select the dirty trim around the image. Fill that area with white on a new layer, and then say "Display this layer wherever the background is brighter than the threshold, otherwise display the background." If I pick the right threshold value, that should have the effect of masking off the dirty white paper, but letting through the border, right? All without the need to do any tedious, risky manual work that might gnaw into the border.

But how can I do that? Is it even possible?

I think what you try to do is this:

1. Copy the original layer
2. Hit D to reset your foreground and background colors
3. Use the stamp-filter on the copied layer Filter > Sketch > Stamp
5. Select the whole layer and copy it
7. Alt+Click on the mask thumbnail
8. Paste the copied content from before
9. Invert the mask CMD or CTRL+I)
10. Delete the layer you used the stamp filter on
11. Create a white layer for your background