Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. How Can I set Noise In Image ?

How Can I set Noise In Image ?

Scheduled Pinned Locked Moved C / C++ / MFC
questionc++htmlcsslounge
3 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • 0 Offline
    0 Offline
    002comp
    wrote on last edited by
    #1

    Hello Friends I am creating a MFC application in which I am saving a image from DC into bmp.I gave different effects on that image by using Gaussian Filter Formula by following this link http://lodev.org/cgtutor/filtering.html[^] I am setting image blur,embossed and etc by getting image pixels and then settign back. Now, I want to add noise Effect to image based on some range(0-100)[if 10 then less particles in image,if 20 more particles and so on]. Using same Gaussian,I didnt get any idea to use any filter to give effect of Noise. I tried my own formula also but it is not adding random particles to image. Here is own way to set noise.I got pixels of Image and randomly change some pixels to black but tht was not producing noise in some continuous manner. I want it should apply in some manner.

    int n = 0;
    for(int x = 0; x < nWidth; ++x)
    {
    for(int y = 0; y < nHeight; ++y)
    {
    n++;
    if(n > 9 + randomFactor)
    {
    n =0;
    randomFactor += x; //Added Randomly
    memDC.SetPixel(x,y,RGB(0,0,0));
    }
    }
    }

    I want to add noise randomly but in some continuous manner. Any Ideas?? Regards Y

    M N 2 Replies Last reply
    0
    • 0 002comp

      Hello Friends I am creating a MFC application in which I am saving a image from DC into bmp.I gave different effects on that image by using Gaussian Filter Formula by following this link http://lodev.org/cgtutor/filtering.html[^] I am setting image blur,embossed and etc by getting image pixels and then settign back. Now, I want to add noise Effect to image based on some range(0-100)[if 10 then less particles in image,if 20 more particles and so on]. Using same Gaussian,I didnt get any idea to use any filter to give effect of Noise. I tried my own formula also but it is not adding random particles to image. Here is own way to set noise.I got pixels of Image and randomly change some pixels to black but tht was not producing noise in some continuous manner. I want it should apply in some manner.

      int n = 0;
      for(int x = 0; x < nWidth; ++x)
      {
      for(int y = 0; y < nHeight; ++y)
      {
      n++;
      if(n > 9 + randomFactor)
      {
      n =0;
      randomFactor += x; //Added Randomly
      memDC.SetPixel(x,y,RGB(0,0,0));
      }
      }
      }

      I want to add noise randomly but in some continuous manner. Any Ideas?? Regards Y

      M Offline
      M Offline
      Marco Bertschi
      wrote on last edited by
      #2

      Well... I have to admit I have no idea of the Gaussian formula but I found a page with formulas which may help you: IA State[^]

      cheers Marco Bertschi


      Software Developer & Founder SMGT Web-Portal CP Profile | My Articles | Twitter | Facebook | SMGT Web-Portal

      1 Reply Last reply
      0
      • 0 002comp

        Hello Friends I am creating a MFC application in which I am saving a image from DC into bmp.I gave different effects on that image by using Gaussian Filter Formula by following this link http://lodev.org/cgtutor/filtering.html[^] I am setting image blur,embossed and etc by getting image pixels and then settign back. Now, I want to add noise Effect to image based on some range(0-100)[if 10 then less particles in image,if 20 more particles and so on]. Using same Gaussian,I didnt get any idea to use any filter to give effect of Noise. I tried my own formula also but it is not adding random particles to image. Here is own way to set noise.I got pixels of Image and randomly change some pixels to black but tht was not producing noise in some continuous manner. I want it should apply in some manner.

        int n = 0;
        for(int x = 0; x < nWidth; ++x)
        {
        for(int y = 0; y < nHeight; ++y)
        {
        n++;
        if(n > 9 + randomFactor)
        {
        n =0;
        randomFactor += x; //Added Randomly
        memDC.SetPixel(x,y,RGB(0,0,0));
        }
        }
        }

        I want to add noise randomly but in some continuous manner. Any Ideas?? Regards Y

        N Offline
        N Offline
        nv3
        wrote on last edited by
        #3

        Two things: You are not really adding noise, but just setting a pixel to black here and there. The idea of noise is to modify all color components of all pixels by adding a random value (plus or minus). So, start off by using a random number generator like rand(), scale its return value to the amount of noise you want and add the outcome pixel by pixel. You may think of it as computing a noise image and adding that image to your original image. If you want to refine that, don't use equally distributed random numbers, but gaussian distribution or others. And you may apply filterind (low-pass, higo-pass, etc) to the noise image before adding to modify the spectral distribution of noise.

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups