资源简介
去雾算法及实现过程,何凯明博士的C++代码实现,自己学习的一个过程。
代码片段和文件信息
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Drawing.Imaging;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Runtime.InteropServices;
using System.Diagnostics;
namespace HazeRemovalTest
{
public unsafe partial class FrmTest : Form
{
// dll的代码中用的是StdCall,这里也要用StdCall,如果用Cdecl,则会出现对 PInvoke 函数“....”的调用导致堆栈不对称错误,再次按F5又可以运行
[DllImport(“HazeRemoval.dll“ CallingConvention = CallingConvention.StdCall CharSet = CharSet.Unicode ExactSpelling = true)]
private static extern void HazeRemovalUseDarkChannelPrior(byte* Src byte* Dest int Width int Height int Stride int Radiusint GuideRadius int MaxAtom float Omega float Epsilon float T0);
private bool Busy = false;
public FrmTest()
{
InitializeComponent();
}
private void CmdOpen_Click(object sender EventArgs e)
{
OpenFileDialog openFileDialog = new OpenFileDialog();
openFileDialog.RestoreDirectory = true;
if (openFileDialog.ShowDialog() == DialogResult.OK)
{
PicSrc.Image.Dispose();
PicDest.Image.Dispose();
PicSrc.Image = Bitmap.FromFile(openFileDialog.FileName);
PicDest.Image = Bitmap.FromFile(openFileDialog.FileName);
Application.DoEvents();
ShowHazeRemovalResult();
}
}
private void CmdHazeRemoval_Click(object sender EventArgs e)
{
ShowHazeRemovalResult();
}
private void ShowHazeRemovalResult()
{
Busy = true;
Bitmap SrcB = (Bitmap)PicSrc.Image;
Bitmap DstB = (Bitmap)PicDest.Image;
BitmapData SrcBmpData = SrcB.LockBits(new Rectangle(0 0 SrcB.Width SrcB.Height) ImageLockMode.ReadWrite PixelFormat.Format24bppRgb);
BitmapData DstBmpData = DstB.LockBits(new Rectangle(0 0 DstB.Width DstB.Height) ImageLockMode.ReadWrite PixelFormat.Format24bppRgb);
Stopwatch Sw = new Stopwatch();
Sw.Start();
HazeRemovalUseDarkChannelPrior((byte*)SrcBmpData.Scan0 (byte*)DstBmpData.Scan0 SrcBmpData.Width SrcBmpData.Height SrcBmpData.Stride BlockSize.Value GuideBlockSize.Value MaxAtom.Value Omega.Value * 0.01f Epsilon.Value * 0.001f T0.Value * 0.01f);
Sw.Stop();
this.Text = Sw.ElapsedMilliseconds.ToString();
SrcB.UnlockBits(SrcBmpData);
DstB.UnlockBits(DstBmpData);
PicDest.Invalidate();
Busy = false;
}
private void FrmTest_Load(object sender EventArgs e)
{
ShowHazeRemovalResult();
}
private void BlockSize_Scroll(object sender ScrollEventArgs e)
{
LblBlo
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 11264 2013-10-14 21:49 HazeRemovalTest\bin\Release\HazeRemoval.dll
文件 885760 2013-10-14 22:31 HazeRemovalTest\bin\Release\HazeRemovalTest.exe
文件 4292 2013-10-14 21:49 HazeRemovalTest\FrmTest.cs
文件 15613 2013-10-13 12:32 HazeRemovalTest\FrmTest.Designer.cs
文件 546895 2013-10-13 12:32 HazeRemovalTest\FrmTest.resx
文件 3997 2013-10-13 12:25 HazeRemovalTest\HazeRemovalTest.csproj
文件 305 2013-10-13 10:54 HazeRemovalTest\HazeRemovalTest.csproj.user
文件 871 2013-10-14 22:31 HazeRemovalTest\HazeRemovalTest.sln
..A..H. 25088 2013-10-14 22:31 HazeRemovalTest\HazeRemovalTest.suo
文件 498 2013-10-12 21:11 HazeRemovalTest\Program.cs
文件 1380 2013-10-12 21:09 HazeRemovalTest\Properties\AssemblyInfo.cs
文件 3110 2013-10-13 12:25 HazeRemovalTest\Properties\Resources.Designer.cs
文件 6191 2013-10-13 12:25 HazeRemovalTest\Properties\Resources.resx
文件 1098 2013-10-12 21:09 HazeRemovalTest\Properties\Settings.Designer.cs
文件 249 2013-10-12 21:09 HazeRemovalTest\Properties\Settings.settings
文件 148174 2013-10-13 12:25 HazeRemovalTest\Resources\75.jpg
文件 360518 2013-10-13 12:23 HazeRemovalTest\平面设计.ico
目录 0 2013-10-14 22:49 HazeRemovalTest\bin\Release
目录 0 2013-10-14 22:32 HazeRemovalTest\bin
目录 0 2013-10-14 22:31 HazeRemovalTest\Properties
目录 0 2013-10-14 22:31 HazeRemovalTest\Resources
目录 0 2013-10-14 22:32 HazeRemovalTest
----------- --------- ---------- ----- ----
2015303 22
- 上一篇:银行家算法 MFC实现
- 下一篇:3*4矩阵键盘
评论
共有 条评论