我想在运行时设置图像的阈值。目前我的代码如下所示:跟踪栏的阈值图像
ImageAttributes imageAttr = new ImageAttributes();
imageAttr.SetThreshold(kryptonTrackBar1.Value/100);
System.Drawing.Bitmap bmp = new System.Drawing.Bitmap(pictureBox3.Image);
Graphics g = System.Drawing.Graphics.FromImage(bmp);
g.DrawImage(bmp, new Rectangle(0, 0, bmp.Width, bmp.Height), 0, 0,
bmp.Width, bmp.Height, GraphicsUnit.Pixel, imageAttr);
pictureBox1.Image = bmp;
picturebox3
包含黑白图像。问题出在imageAttr.SetThreshold(kryptonTrackBar1.Value/100);
行内。
我的trackbar max是100,最小值是0. 所以我最终会得到类似于0.07等数值,而滚动trackbar,但trackbar只返回0和1的值! 1如果我一直向右滚动!
它有什么问题?
请参阅 “[堆栈溢出不允许在标题标签(http://meta.stackexchange.com/a/130208)”。 –