关于显微镜下图片的处理
最近在弄个课程设计,用到了显微镜,可是我需要的是白色的图,就是要把显微镜下的背景图去掉,还不能把线弄没了。一个同学说,我可以试着用C#,可是我只会用matlab,真是头大,只好问问大家,有什么好的范例吗,或者谁有代码可以共享看看的,谢谢了。我把图片传上来。请大家指点指点! --------------------编程问答--------------------
--------------------编程问答-------------------- --------------------编程问答-------------------- --------------------编程问答-------------------- 谢谢LS的兄弟,我在vs2010下编译不能通过,还请再指点一二。 --------------------编程问答-------------------- 我的是vs2008,汗'''' --------------------编程问答-------------------- 你引用几个名称空间就行了。 --------------------编程问答-------------------- dim B as bitmap=bitmap.fromfile("...")
/// <summary>
/// 图片黑白化使用的方法
/// </summary>
/// <param name="img">原图片</param>
/// <param name="hsb">黑白的阈值</param>
/// <returns></returns>
public static Bitmap BitmapTo1Bpp(Bitmap img, Double hsb)
{
int w = img.Width;
int h = img.Height;
Bitmap bmp = new Bitmap(w, h, PixelFormat.Format1bppIndexed);
BitmapData data = bmp.LockBits(new Rectangle(0, 0, w, h), ImageLockMode.ReadWrite, PixelFormat.Format1bppIndexed);//Format1bppIndexed
for (int y = 0; y < h; y++)
{
byte[] scan = new byte[(w + 7) / 8];
for (int x = 0; x < w; x++)
{
Color c = img.GetPixel(x, y);
if (c.GetBrightness() >= hsb) scan[x / 8] |= (byte)(0x80 >> (x % 8));
}
Marshal.Copy(scan, 0, (IntPtr)((int)data.Scan0 + data.Stride * y), scan.Length);
}
bmp.UnlockBits(data);
return bmp;
}
B.MakeTransparnet() --------------------编程问答--------------------
我知道vs2010删除了一些命名空间,可是怎么添加呢
补充:.NET技术 , C#