Created
October 18, 2015 14:35
-
-
Save kotakagi0914/f45888d6e23e6e9ff1fc to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <opencv2/opencv.hpp> | |
using namespace cv; | |
int main(int argc, char* argv[]) | |
{ | |
Mat src_image = imread("R2-D2.jpg");//画像の読み込み | |
namedWindow("original picture");//Windowの作成 | |
imshow("original picture", src_image);//Windowの表示 | |
Mat dst_image; | |
int i, j, x, y; | |
//ノイズの作成 | |
for (i = 0; i < 1000; i++){ | |
x = rand() % 320; | |
y = rand() % 240; | |
for (j = 0; j < 3; j++) | |
src_image.at<Vec3b>(y, x)[j] = 0; | |
x = rand() % 320; | |
y = rand() % 240; | |
for (j = 0; j < 3; j++) | |
src_image.at<Vec3b>(y, x)[j] = 255; | |
} | |
namedWindow("noise picture"); | |
imshow("noise picture", src_image); | |
blur(src_image, dst_image, Size(3, 3)); | |
namedWindow("blur picture"); | |
imshow("blur picture", dst_image); | |
GaussianBlur(src_image, dst_image, Size(3, 3), 0); | |
namedWindow("GaussianBlur picture"); | |
imshow("GaussianBlur picture", dst_image); | |
medianBlur(src_image, dst_image, 3); | |
namedWindow("medianBlur picture"); | |
imshow("medianBlur picture", dst_image); | |
bilateralFilter(src_image, dst_image, -1, 50, 20); | |
namedWindow("bilateralFilter picture"); | |
imshow("bilateralFilter picture", dst_image); | |
waitKey(0); | |
destroyAllWindows(); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment