91av视频/亚洲h视频/操亚洲美女/外国一级黄色毛片 - 国产三级三级三级三级

資源簡介

水平矯正圖片角度,采用傅立葉變換,頻譜圖,相譜圖,霍夫檢測直線,計算角度,矯正角度

資源截圖

代碼片段和文件信息

using?System;
using?System.Collections.Generic;
using?System.IO;
using?System.Text;

using?OpenCvSharp;
using?OpenCvSharp.Extensions;
using?OpenCvSharp.Utilities;

namespace?OpenCvRotate
{
class?Program
{
static?void?Main(string[]?args)
{
//以灰度方式讀入原文件
string?filename?=?“source.jpg“;
var?src?=?IplImage.FromFile(filename?LoadMode.GrayScale);

//轉換到合適的大小,以適應快速變換
int?width?=?Cv.GetOptimalDFTSize(src.Width);
int?height?=?Cv.GetOptimalDFTSize(src.Height);
var?padded?=?new?IplImage(width?height?BitDepth.U8?1);
Cv.CopyMakeBorder(src?padded?new?CvPoint(0?0)?BorderType.Constant?CvScalar.ScalarAll(0));

//實部、虛部(單通道)
var?real?=?new?IplImage(padded.Size?BitDepth.F32?1);
var?imaginary?=?new?IplImage(padded.Size?BitDepth.F32?1);
//合并(雙通道)
var?fourier?=?new?IplImage(padded.Size?BitDepth.F32?2);

//圖像復制到實部,虛部清零
Cv.ConvertScale(padded?real);
Cv.Zero(imaginary);

//合并、變換、再分解
Cv.Merge(real?imaginary?null?null?fourier);
Cv.DFT(fourier?fourier?DFTFlag.Forward);
Cv.Split(fourier?real?imaginary?null?null);

//計算sqrt(re^2+im^2),再存回re
Cv.Pow(real?real?2.0);
Cv.Pow(imaginary?imaginary?2.0);
Cv.Add(real?imaginary?real);
Cv.Pow(real?real?0.5);

//計算log(1+re),存回re
Cv.AddS(real?CvScalar.ScalarAll(1)?real);
Cv.Log(real?real);

//歸一化,落入0-255范圍
Cv.Normalize(real?real?0?255?NormType.MinMax);

//把低頻移動到中心
ShiftDFT(real);

//二值化,以150作為分界點,經驗值,需要根據實際情況調整
Cv.Threshold(real?real?150?255?ThresholdType.Binary);

//由于HoughLines2方法只接受8UC1格式的圖片,因此進行轉換
var?gray?=?new?IplImage(real.Size?BitDepth.U8?1);
Cv.ConvertScale(real?gray);

//找直線,threshold參數取100,經驗值,需要根據實際情況調整
var?storage?=?Cv.CreateMemStorage();
var?lines?=?Cv.HoughLines2(gray?storage?HoughLinesMethod.Standard?1?Cv.PI?/?180?100);

//找到符合條件的那條斜線
float?angel?=?0f;
float?piThresh?=?(float)Cv.PI?/?90;
float?pi2?=?(float)Cv.PI?/?2;
for?(int?i?=?0;?i? {
//極坐標下的點,X是極徑,Y是夾角,我們只關心夾角
var?p?=?lines.GetSeqElem(i);
float?theta?=?p.Value.Y;

if?(Math.Abs(theta)?>=?piThresh?&&?Math.Abs(theta?-?pi2)?>=?piThresh)
{
angel?=?theta;
break;
}
}
angel?=?angel? Cv.ReleaseMemStorage(storage);

//轉換角度
if?(angel?!=?pi2)
{
float?angelT?=?(float)(src.Height?*?Math.Tan(angel)?*?1.0?/?src.Width);
angel?=?(float)Math.Atan(angelT);
}
float?angelD?=?angel?*?180?/?(float)Cv.PI;

//旋轉
var?center?=?new?CvPoint2D32f(src.Width?/?2.0?src.Height?/?2.0);
var?rotMat?=?Cv.GetRotationMatrix2D(center?angelD?1.0);
var?dst?=?new?IplImage(src.Size?BitDepth.U8?1);
Cv.WarpAffine(src?dst?rotMat?Interpolation.Cubic?|?Interpolation.FillOutliers?CvScalar.ScalarAll(255));

Console.WriteLine(“如果旋轉失敗,說明HoughLines2方法未檢測到直線,請適當調整源碼66行的最后一個參

?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----

????..A..H.?????36864??2017-07-25?09:22??OpenCvRotate\.vs\OpenCvRotate\v14\.suo

?????文件????1013248??2015-06-04?04:55??OpenCvRotate\bin\dll\x64\OpenCvSharpExtern.dll

?????文件????1200128??2015-06-04?04:55??OpenCvRotate\bin\dll\x64\opencv_calib3d2410.dll

?????文件????1403904??2015-06-04?04:55??OpenCvRotate\bin\dll\x64\opencv_contrib2410.dll

?????文件????2573824??2015-06-04?04:55??OpenCvRotate\bin\dll\x64\opencv_core2410.dll

?????文件?????868864??2015-06-04?04:55??OpenCvRotate\bin\dll\x64\opencv_features2d2410.dll

?????文件????9720042??2015-06-04?04:55??OpenCvRotate\bin\dll\x64\opencv_ffmpeg2410_64.dll

?????文件?????656384??2015-06-04?04:55??OpenCvRotate\bin\dll\x64\opencv_flann2410.dll

?????文件?????482304??2015-06-04?04:55??OpenCvRotate\bin\dll\x64\opencv_gpu2410.dll

?????文件????2410496??2015-06-04?04:55??OpenCvRotate\bin\dll\x64\opencv_highgui2410.dll

?????文件????2236416??2015-06-04?04:55??OpenCvRotate\bin\dll\x64\opencv_imgproc2410.dll

?????文件????1489408??2015-06-04?04:55??OpenCvRotate\bin\dll\x64\opencv_legacy2410.dll

?????文件?????597504??2015-06-04?04:55??OpenCvRotate\bin\dll\x64\opencv_ml2410.dll

?????文件?????657408??2015-06-04?04:55??OpenCvRotate\bin\dll\x64\opencv_nonfree2410.dll

?????文件?????805888??2015-06-04?04:55??OpenCvRotate\bin\dll\x64\opencv_objdetect2410.dll

?????文件????2967040??2015-06-04?04:55??OpenCvRotate\bin\dll\x64\opencv_ocl2410.dll

?????文件?????235008??2015-06-04?04:55??OpenCvRotate\bin\dll\x64\opencv_photo2410.dll

?????文件????1228800??2015-06-04?04:55??OpenCvRotate\bin\dll\x64\opencv_stitching2410.dll

?????文件?????716800??2015-06-04?04:55??OpenCvRotate\bin\dll\x64\opencv_superres2410.dll

?????文件?????443904??2015-06-04?04:55??OpenCvRotate\bin\dll\x64\opencv_video2410.dll

?????文件?????632320??2015-06-04?04:55??OpenCvRotate\bin\dll\x64\opencv_videostab2410.dll

?????文件???????6656??2017-07-25?09:24??OpenCvRotate\bin\OpenCvRotate.exe

?????文件??????13824??2017-07-25?09:24??OpenCvRotate\bin\OpenCvRotate.pdb

?????文件??????22688??2017-07-25?09:24??OpenCvRotate\bin\OpenCvRotate.vshost.exe

?????文件????????490??2016-07-16?19:44??OpenCvRotate\bin\OpenCvRotate.vshost.exe.manifest

?????文件??????40960??2015-06-08?11:12??OpenCvRotate\bin\OpenCvSharp.Blob.dll

?????文件?????496640??2015-06-08?11:12??OpenCvRotate\bin\OpenCvSharp.dll

?????文件??????35840??2015-06-08?11:12??OpenCvRotate\bin\OpenCvSharp.Extensions.dll

?????文件??????13312??2015-06-08?11:12??OpenCvRotate\bin\OpenCvSharp.UserInterface.dll

?????文件?????319692??2013-11-02?00:11??OpenCvRotate\bin\source.jpg

............此處省略30個文件信息

評論

共有 條評論