使用boost::gil模块进行图像处理时,临界点threshold是一个非常重要的参数。为了测试threshold值对于图像分割的影响,本文提供了一个简单的boost::gil模块临界点threshold的测试程序。
首先我们需要准备一张测试图像,本程序使用的是一张灰度图像。将该图像命名为test.jpg并放置在同一目录下。接着,我们需要定义处理函数,如下所示:
#include <boost/gil.hpp>
#include <boost/gil/extension/io/jpeg_dynamic_io.hpp>
#include <iostream>
using namespace boost::gil;
using namespace std;
void process_image(const char* filename, int threshold)
{
rgb8_image_t img;
jpeg_read_image(filename, img);
// Convert to grayscale
gray8_image_t gray_img(img.dimensions());
color_converted_view<rgb8_pixel_t, gray8_pixel_t> gray_view = color_converted_view<rgb8_pixel_t, gray8_pixel_t>(const_view(img), defa