I have written a code (in c++) to add noise in the image using CImg library. Now i want to load the image with noise and remove those noise inside the image using median filter algorithm. Below is my code.
int main()
{
int x;
cout<<"Welcome to my app\n";
cout<<"Choose options below\n";
cout<<"1. Remove pepper 2. Add pepper\n";
cin>>x;
if (x==1)
{
cout<<"Needs help";
/*
* i tried to change the noise level to 0 but it did not work like below
* image.noise(0,2);
*
*/
}
else if(x==2)
{
//image file
CImg<unsigned char> image("new.bmp");
const unsigned char red[] = { 255,0,0 }, green[] = { 0,255,0 }, blue[] = { 0,0,255 };
image.noise(100,2);
image.save("new2.bmp");
CImgDisplay main_disp(image, "Image with Pepper noise");
while (!main_disp.is_closed())
{
main_disp.wait();
}
}
getchar();
return 0;
}
If there is another way of doing this using CImg library, I will be thankful!!