嗨,您可以使用中值滤波器或 Max 滤波器,因为您有 90% 的噪声。请参考下面的 C++ 代码,但您可以轻松地将其与 python 相关联。//maxOrmedian = True/False, inputImage = std::vector, kernalSize = 3, width = 256, height= 256 //
std::vector<double> medianFilter(bool maxOrmedian, std::vector<double> inputImage, double kernalSize,int width, int height)
{
/* Fill all the values to output image */
vector<double> outImage = inputImage;
for(int y = kernalSize; y < height - kernalSize; y++)
{
for(int x = kernalSize; x < width - kernalSize; x++)
{
std::vector<double> tempList;
for(int i = - kernalSize; i <= kernalSize; i++)
{
for(int j = -kernalSize; j <= kernalSize; j++)
{
double pixelValue = inputImage[(y+j)*width + (x+i)];
tempList.push_back(pixelValue);
}
}
std::sort(tempList.begin(),tempList.end());
double newPixelValue = 0;
if(maxOrmedian) //median filter
newPixelValue = tempList[tempList.size()/2];
else
newPixelValue = tempList[tempList.size()-1];
outImage[y*width + x] = newPixelValue;
}
}
return outImage;
}