我想在運行時設置圖像的閾值。目前我的代碼如下所示:跟蹤欄的閾值圖像
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)」。 –