I have implemented a Gaussian blur to allow for the blurring of an image. This image is saved as 'stage2_blurred'. I then want to re-input this 'stage2_blurred' image to then make any pixels that are not black into white, and save the newly created image as 'stage2_threshold'. The code I have implemented is giving me an error within the parallel_for -
This is the line containing the error: int whitePixels = parallel_reduce(
and this is the error message: "a value of type "void" cannot be used to initialise an entity type of "int"
Can anyone direct me as to where I have gone wrong within my code please?
Any help is greatly appreciated. Code to follow:
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");
}
}
});