如何使用AForge用红色替换位图白色像素?

net*_*rog 2 .net c# image-processing

我知道这可以做到GetPixel/SetPixel,但这需要太长时间.

我现在正试图容纳AForge,并想知道是否有一个过滤器可以快速完成.

hyp*_*ush 5

您可以使用EuclideanColorFiltering来实现此目的:

 EuclideanColorFiltering filter = new EuclideanColorFiltering();            
 filter.CenterColor = new AForge.Imaging.RGB(Color.White); //Pure White
 filter.Radius = 0; //Increase this to allow off-whites
 filter.FillColor = new AForge.Imaging.RGB(Color.Red); //Replacement Colour
 filter.ApplyInPlace(image);
Run Code Online (Sandbox Code Playgroud)

  • 实际上,如果你设置`filter.FillOutside = false;`,代码将会起作用,因为这会使它只填充白色,而不是全白. (3认同)