Make median filter parallel

This commit is contained in:
2019-09-28 13:05:07 +02:00
parent eb307ea091
commit 759383c4a1
3 changed files with 15 additions and 8 deletions
+3 -3
View File
@@ -169,7 +169,7 @@ public:
{
std::vector<T> tmp;
tmp.resize(m_width*m_height);
size_t d=0;
#pragma omp parallel for
for(uint32_t y=0;y<m_height;y++)
{
for(uint32_t x=0;x<m_width;x++)
@@ -177,8 +177,8 @@ public:
T array[9] = { pixel(x-1, y-1), pixel(x, y-1), pixel(x+1, y-1),
pixel(x-1, y), pixel(x, y), pixel(x+1, y),
pixel(x-1, y+1), pixel(x, y+1), pixel(x+1, y+1)};
std::partial_sort(std::begin(array), array+5, std::end(array));
tmp[d++] = array[4];
std::nth_element(std::begin(array), array+4, std::end(array));
tmp[y*m_width+x] = array[4];
}
}
m_img = std::move(tmp);