# How do I remove all white pixels in a modified image which are not present in the original?

I have the following image

and after thresholding it, I obtained this result:

How can I remove all white pixels which do not belong to the original image?

The desired output should look like this (I manually edited the image):

• Please clarify your question, and replace the links with the actual images. Use images to explain what you're trying to accomplish. – Roronoa Zoro Feb 7 '12 at 0:36
• @RoronoaZoro I have edited the question to inline the images. The edit needs to be approved though. In SO it is not possible to include images in question before gaining some minimal reputation--maybe same here. – Matthias Odisio Feb 7 '12 at 0:59
• @Roronoa.there is two images ,original and resultant image,i didnt undestand you .what i need is only the veins in the original image as a white lines without any other white pixels ,any additional whitr pixel represent a noise for me. – ruaa Feb 7 '12 at 1:03
• @ruaa Starting by thresholding might not be the best idea. As stated by the MatthiasOdisio, you should look into the link he provided, plus look into morphological operations as he suggested. I would like to add that you might want to try the watershed segmentation algorithm for this problem. – Roronoa Zoro Feb 7 '12 at 16:30

Welcome to Image processing!

(See edit at the bottom)

If I understood you well, thresholding the image with a low threshold will provide a mask for the hand that you can use to remove the background pixels.

That's how it will look in Mathematica (ImagePad here is just used to remove the extra white border on your images):

img = ColorConvert[Import["http://i.stack.imgur.com/krbMs.jpg"], "Grayscale"];
border = BorderDimensions[img];

hand = Binarize[img, 0.2]