Question:

Can someone tell me how to add noise to an image...?

by  |  earlier

0 LIKES UnLike

I am using c++

If you could give me an example code or the algorithm for random noise for example, I would appreciate it.

(10 Points for the most helpful answer)

 Tags:

   Report

1 ANSWERS


  1. Noise is random pixels being off from true by a random factor.

    (pseudocode)

    Pixel noisyPixel(Pixel p)

    p.blue = rand * p.blue;

    p.green = rand * p.green;

    p.red = rand * p.red;

    return p;

    int w = image.width, h = image.height;

    for i = 0 to numberOfPixels

    x = rand * w;

    y = rand * h;

    Pixel p = image.pixel(x, y);

    p = noisyPixel(p);

    image.setPixel(x,y,p);

    numberOfPixels will be a function of the number of pixels in the image and the amount of noise desired.

    This is a very rough and ready way to do it. Noise is a very involved subject.

Question Stats

Latest activity: earlier.
This question has 1 answers.

BECOME A GUIDE

Share your knowledge and help people by answering questions.