有哪位大虾能够提供给我 将人脸斑点和皱纹祛除的代码啊,数字图像处理方面的,在VS2008环境下,用C#语言。
wujie
vs2008代码的空格变成小点!~
这是热键的问题,你按组合键ctrl + E ,S
或者是
编辑----> 高级------>查看空白。
就可以了
我用的是WPF实现的,需要这么一些命名空间
using System;
using System.Windows;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.IO;
代码:
private static void ImageProcess()
{
var pathSrc = AppDomain.CurrentDomain.BaseDirectory + "Image.png";
// 创建源位图对象
var iSrc = new BitmapImage(new Uri(pathSrc));
// 缓存数组(RGBA的每个像素需要4Byte)
var array = new byte[ iSrc.PixelWidth * (iSrc.PixelHeight * 2 / 3) * 4 ];
// 截取区域
var rect = new Int32Rect( 0, 0, iSrc.PixelWidth, iSrc.PixelHeight * 2 / 3 );
// 复制到数组
iSrc.CopyPixels( rect, array, iSrc.PixelWidth * 4, 0 );
// 从数组创建新的位图对象
var iDst = BitmapImage.Create( iSrc.PixelWidth, iSrc.PixelHeight * 2 / 3,
96, 96, PixelFormats.Bgra32, null, array, iSrc.PixelWidth * 4 );
// 保存到文件
var fs = File.Create( "ImageNew.png" );
var encoder = new PngBitmapEncoder();// 也可使用Jpeg或者Bmp
encoder.Frames.Add( BitmapFrame.Create(iDst) );
encoder.Save( fs );
fs.Close();
}