Noise generation - salt and pepper



Hello,

Can you please tell me , How i could generate salt and pepper noise. I
understand that its simply flipping up the pixels, But i donot
understand, on how to go about on the percentage and randomness of
flipping.

It will be helpfull, if you could point me to some source codes/
tutorials/sw for various noise generation techniques with specific
emphasis to salt and pepper noise.

My application domain is for document imaging.

Thanks
Raj

.