我已经实现了高斯模糊以允许图像模糊。此图像保存为“stage2_blurred”。然后我想重新输入这个“stage2_blurred”图像,然后将任何不是黑色的像素变成白色,并将新创建的图像保存为“stage2_threshold”。我实现的代码在 parallel_for 中给了我一个错误-
这是包含错误的行: int whitePixels = parallel_reduce(
这是错误消息:““void”类型的值不能用于初始化“int”实体类型
谁能指导我在我的代码中哪里出错了?
任何帮助是极大的赞赏。要遵循的代码:
outputBlurImage.convertToType(FREE_IMAGE_TYPE::FIT_BITMAP);
outputBlurImage.convertTo24Bits();
outputBlurImage.save("stage2_blurred.png");
//last part of part 2
fipImage blurredImage;
blurredImage.load("stage2_blurred.png");
unsigned int width = blurredImage.getHeight();
unsigned int height = blurredImage.getWidth();
float pixels = width * height;
fipImage outputThreshold;
outputThreshold = fipImage(FIT_BITMAP, width, height, 24);
vector<vector<RGBQUAD>> rgbValuesOutput;
rgbValuesOutput.resize(height, vector<RGBQUAD>(width));
int whitePixels = parallel_reduce(
blocked_range2d<int, int>(0, height, 0, width),
[&](const blocked_range2d<int, int>& range, int value)-> int {
auto y1 = range.rows().begin();
auto y2 = range.rows().end();
auto x1 = range.cols().begin();
auto x2 = range.cols().end();
RGBQUAD rgb1;
for (auto y = y1; y < y2; y++) {
for (auto x = x1; x < x2; x++) {
blurredImage.getPixelColor(x, y, &rgb1); //extracting pixels
blurredImage.getPixelColor(x, y, &rgb1);
if (rgbValuesOutput[y][x].rgbRed != 0 || rgbValuesOutput[y][x].rgbGreen != 0 || rgbValuesOutput[y][x].rgbBlue != 0) {
rgbValuesOutput[y][x].rgbRed = 255;
rgbValuesOutput[y][x].rgbGreen = 255;
rgbValuesOutput[y][x].rgbBlue = 255;
value += 1;
}
outputThreshold.setPixelColor(x, y, &rgbValuesOutput[y][x]);
outputThreshold.save("stage2_threshold.png");
}
}
});