How Can I set Noise In Image ?
-
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
-
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
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
-
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
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.