您的位置:首页 > 其它

Emgu-WPF学习使用 - 颜色映射

2018-03-26 13:52 330 查看

string sFile = "";
if (!String.IsNullOrEmpty(AppConstUtils.GDefaultFile) && File.Exists(AppConstUtils.GDefaultFile))
sFile = AppConstUtils.GDefaultFile;
else
sFile = GlobalVar.DATAS_PATH + "Samples/Test5.jpg";

System.Drawing.Image imgOrigin = System.Drawing.Image.FromFile(sFile);
Bitmap barcodeBitmap = new Bitmap(imgOrigin);
Image<Bgr, byte> imgSrc = new Image<Bgr, byte>(barcodeBitmap);
AppUtils.AttachImageItem(this.WpDemo1Zm, imgSrc, "原始图");
imgOrigin.Dispose();
barcodeBitmap.Dispose();

Image<Gray, byte> imgGray = new Image<Gray, byte>(imgSrc.Size);
CvInvoke.CvtColor(imgSrc, imgGray, ColorConversion.Bgr2Gray);
AppUtils.AttachImageItem(this.WpDemo1Zm, imgGray, "灰度化->");

Image<Bgr, byte> imgColorAutumn = new Image<Bgr, byte>(imgSrc.Size);
CvInvoke.ApplyColorMap(imgGray, imgColorAutumn, ColorMapType.Autumn);
AppUtils.AttachImageItem(this.WpDemo1Zm, imgColorAutumn, "灰度化->Autumn颜色映射");

Image<Bgr, byte> imgColorBone = new Image<Bgr, byte>(imgSrc.Size);
CvInvoke.ApplyColorMap(imgGray, imgColorBone, ColorMapType.Bone);
AppUtils.AttachImageItem(this.WpDemo1Zm, imgColorBone, "灰度化->Bone颜色映射");

Image<Bgr, byte> imgColorCool = new Image<Bgr, byte>(imgSrc.Size);
CvInvoke.ApplyColorMap(imgGray, imgColorCool, ColorMapType.Cool);
AppUtils.AttachImageItem(this.WpDemo1Zm, imgColorCool, "灰度化->Cool颜色映射");

Image<Bgr, byte> imgColorHot = new Image<Bgr, byte>(imgSrc.Size);
CvInvoke.ApplyColorMap(imgGray, imgColorHot, ColorMapType.Hot);
AppUtils.AttachImageItem(this.WpDemo1Zm, imgColorHot, "灰度化->Hot颜色映射");

Image<Bgr, byte> imgColorHsv = new Image<Bgr, byte>(imgSrc.Size);
CvInvoke.ApplyColorMap(imgGray, imgColorHsv, ColorMapType.Hsv);
AppUtils.AttachImageItem(this.WpDemo1Zm, imgColorHsv, "灰度化->Hsv颜色映射");

Image<Bgr, byte> imgColorJet = new Image<Bgr, byte>(imgSrc.Size);
CvInvoke.ApplyColorMap(imgGray, imgColorJet, ColorMapType.Jet);
AppUtils.AttachImageItem(this.WpDemo1Zm, imgColorJet, "灰度化->Jet颜色映射");

Image<Bgr, byte> imgColorOcean = new Image<Bgr, byte>(imgSrc.Size);
CvInvoke.ApplyColorMap(imgGray, imgColorOcean, ColorMapType.Ocean);
AppUtils.AttachImageItem(this.WpDemo1Zm, imgColorOcean, "灰度化->Ocean颜色映射");

Image<Bgr, byte> imgColorPink = new Image<Bgr, byte>(imgSrc.Size);
CvInvoke.ApplyColorMap(imgGray, imgColorPink, ColorMapType.Pink);
AppUtils.AttachImageItem(this.WpDemo1Zm, imgColorPink, "灰度化->Pink颜色映射");

Image<Bgr, byte> imgColorRainbow = new Image<Bgr, byte>(imgSrc.Size);
CvInvoke.ApplyColorMap(imgGray, imgColorRainbow, ColorMapType.Rainbow);
AppUtils.AttachImageItem(this.WpDemo1Zm, imgColorRainbow, "灰度化->Rainbow颜色映射");

Image<Bgr, byte> imgColorSpring = new Image<Bgr, byte>(imgSrc.Size);
CvInvoke.ApplyColorMap(imgGray, imgColorSpring, ColorMapType.Spring);
AppUtils.AttachImageItem(this.WpDemo1Zm, imgColorSpring, "灰度化->Spring颜色映射");

Image<Bgr, byte> imgColorSummer = new Image<Bgr, byte>(imgSrc.Size);
CvInvoke.ApplyColorMap(imgGray, imgColorSummer, ColorMapType.Summer);
AppUtils.AttachImageItem(this.WpDemo1Zm, imgColorSummer, "灰度化->Summer颜色映射");

Image<Bgr, byte> imgColorWinter = new Image<Bgr, byte>(imgSrc.Size);
CvInvoke.ApplyColorMap(imgGray, imgColorWinter, ColorMapType.Winter);
AppUtils.AttachImageItem(this.WpDemo1Zm, imgColorWinter, "灰度化->Winter颜色映射");
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: