#include <stdio.h>
#include "opencv2/core/core.hpp"
#include "opencv2/features2d/features2d.hpp"
#include "opencv2/highgui/highgui.hpp"
#include "opencv2/nonfree/nonfree.hpp"
#ifndef _DEBUG
#pragma comment(lib,"IlmImf.lib")
#pragma comment(lib,"libjasper.lib")
#pragma comment(lib,"libjpeg.lib")
#pragma comment(lib,"libpng.lib")
#pragma comment(lib,"libtiff.lib")
#pragma comment(lib,"zlib.lib")
#pragma comment(lib,"opencv_calib3d2411.lib")
#pragma comment(lib,"opencv_contrib2411.lib")
#pragma comment(lib,"opencv_core2411.lib")
#pragma comment(lib,"opencv_features2d2411.lib")
#pragma comment(lib,"opencv_flann2411.lib")
#pragma comment(lib,"opencv_gpu2411.lib")
#pragma comment(lib,"opencv_highgui2411.lib")
#pragma comment(lib,"opencv_imgproc2411.lib")
#pragma comment(lib,"opencv_legacy2411.lib")
#pragma comment(lib,"opencv_ml2411.lib")
#pragma comment(lib,"opencv_nonfree2411.lib")
#pragma comment(lib,"opencv_objdetect2411.lib")
#pragma comment(lib,"opencv_ocl2411.lib")
#pragma comment(lib,"opencv_photo2411.lib")
#pragma comment(lib,"opencv_stitching2411.lib")
#pragma comment(lib,"opencv_superres2411.lib")
#pragma comment(lib,"opencv_ts2411.lib")
#pragma comment(lib,"opencv_video2411.lib")
#pragma comment(lib,"opencv_videostab2411.lib")
#else
#pragma comment(lib,"zlibd.lib")
#pragma comment(lib,"IlmImfd.lib")
#pragma comment(lib,"libjasperd.lib")
#pragma comment(lib,"libjpegd.lib")
#pragma comment(lib,"libpngd.lib")
#pragma comment(lib,"libtiffd.lib")
#pragma comment(lib,"opencv_calib3d2411d.lib")
#pragma comment(lib,"opencv_contrib2411d.lib")
#pragma comment(lib,"opencv_core2411d.lib")
#pragma comment(lib,"opencv_features2d2411d.lib")
#pragma comment(lib,"opencv_flann2411d.lib")
#pragma comment(lib,"opencv_gpu2411d.lib")
#pragma comment(lib,"opencv_highgui2411d.lib")
#pragma comment(lib,"opencv_imgproc2411d.lib")
#pragma comment(lib,"opencv_legacy2411d.lib")
#pragma comment(lib,"opencv_ml2411d.lib")
#pragma comment(lib,"opencv_nonfree2411d.lib")
#pragma comment(lib,"opencv_objdetect2411d.lib")
#pragma comment(lib,"opencv_ocl2411d.lib")
#pragma comment(lib,"opencv_photo2411d.lib")
#pragma comment(lib,"opencv_stitching2411d.lib")
#pragma comment(lib,"opencv_superres2411d.lib")
#pragma comment(lib,"opencv_ts2411d.lib")
#pragma comment(lib,"opencv_video2411d.lib")
#pragma comment(lib,"opencv_videostab2411d.lib")
#endif
using namespace cv;
void salt(cv::Mat image, int n) {
int i,j;
for (int k=0; k<n; k++) {
// rand() is the random number generator
i= std::rand()%image.cols;
j= std::rand()%image.rows;
if (image.type() == CV_8UC1) { // gray-level image
image.at<uchar>(j,i)= 255;
} else if (image.type() == CV_8UC3) { // color image
image.at<cv::Vec3b>(j,i)[0]= 255;
image.at<cv::Vec3b>(j,i)[1]= 255;
image.at<cv::Vec3b>(j,i)[2]= 255;
}
}
}
int main(int argc, char** argv)
{
Mat img1 = imread("lena.jpg");
//Mat img2 = imread(argv[2], CV_LOAD_IMAGE_GRAYSCALE);
if(img1.empty() )
{
printf("Can't read one of the images\n");
return -1;
}
salt(img1,100);
// drawing the results
cv::imshow("img1", img1);
salt(img1,100);
// drawing the results
cv::imshow("img2", img1);
salt(img1,100);
cv::imshow("img3", img1);
salt(img1,100);
cv::imshow("img4", img1);
salt(img1,100);
cv::imshow("img5", img1);
waitKey(0);
return 0;
}