if( Igray.empty() ){ cout << "Can not load " << argv[6] << endl; return -1; }
// Declare the output images
cv::Mat It, Iat;
// Thresholds
cv::threshold(
Igray,
It,
fixed_threshold,
255,
threshold_type);
cv::adaptiveThreshold(
Igray,
Iat,
255,
adaptive_method,
threshold_type,
block_size,
offset
);
// Show the results
cv::imshow("Raw",Igray);
cv::imshow("Threshold",It);
cv::imshow("Adaptive Threshold",Iat);
cv::waitKey(0);
return 0;
}
Smoothing
Figure 5-6: Gaussian blur on 1D pixel array
Smoothing, also called blurring, is a simple and frequently used image processing operation. There are
many reasons for smoothing, but it is often done to reduce noise or camera artifacts. Smoothing is also
important when we wish to reduce the resolution of an image in a principled way (we will discuss this in
more detail in the “Image Pyramids” section of this chapter).
OpenCV offers five different smoothing operations, each with its own associated library function, which
each accomplish slightly different kinds of smoothing.