IEnumerable <Mat> PyrDownInternal( Mat image, Size minSize, float scale, InterpolationFlags filter) { var sizes = new List <Size>(); float width = image.Width; float height = image.Height; for (; ;) { width /= scale; height /= scale; if (width < minSize.Width || height < minSize.Height) { break; } sizes.Add(new Size(width, height)); } yield return(image); foreach (var size in sizes.Distinct()) { yield return(image.Resize(size, 0, 0, filter)); } }
/// <summary> /// Applies a generic geometrical transformation to an image. /// </summary> /// <param name="src">Source image.</param> /// <param name="dst">Destination image with the size the same as xmap and the type the same as src .</param> /// <param name="map1">X values. Only CV_32FC1 type is supported.</param> /// <param name="map2">Y values. Only CV_32FC1 type is supported.</param> /// <param name="interpolation">Interpolation method (see resize ). INTER_NEAREST , INTER_LINEAR and /// INTER_CUBIC are supported for now.</param> /// <param name="borderMode">Pixel extrapolation method (see borderInterpolate ). BORDER_REFLECT101 , /// BORDER_REPLICATE , BORDER_CONSTANT , BORDER_REFLECT and BORDER_WRAP are supported for now.</param> /// <param name="borderValue">Value used in case of a constant border. By default, it is 0.</param> /// <param name="stream">Stream for the asynchronous version.</param> public static void remap( InputArray src, OutputArray dst, InputArray map1, InputArray map2, InterpolationFlags interpolation = InterpolationFlags.Linear, BorderTypes borderMode = BorderTypes.Constant, Scalar?borderValue = null, Stream stream = null) { if (src == null) { throw new ArgumentNullException(nameof(src)); } if (dst == null) { throw new ArgumentNullException(nameof(dst)); } if (map1 == null) { throw new ArgumentNullException(nameof(map1)); } if (map2 == null) { throw new ArgumentNullException(nameof(map2)); } src.ThrowIfDisposed(); dst.ThrowIfNotReady(); map1.ThrowIfDisposed(); map2.ThrowIfDisposed(); Scalar borderValue0 = borderValue.GetValueOrDefault(Scalar.All(0)); NativeMethods.cuda_warping_remap(src.CvPtr, dst.CvPtr, map1.CvPtr, map2.CvPtr, (int)interpolation, (int)borderMode , borderValue0, stream?.CvPtr ?? Stream.Null.CvPtr); GC.KeepAlive(src); GC.KeepAlive(dst); dst.Fix(); GC.KeepAlive(map1); GC.KeepAlive(map2); }
private void CboxInterpolation_SelectedIndexChanged(object sender, EventArgs e) { switch (cboxInterpolation.SelectedIndex) { case 0: interpolation = InterpolationFlags.Nearest; break; case 1: interpolation = InterpolationFlags.Linear; break; case 2: interpolation = InterpolationFlags.Cubic; break; case 3: interpolation = InterpolationFlags.Area; break; case 4: interpolation = InterpolationFlags.Lanczos4; break; case 5: interpolation = InterpolationFlags.LinearExact; break; } if (image_in != null) { PicZoom(); } }
public override System.Collections.Generic.Queue <Moonfish.Tags.BlamPointer> ReadFields(System.IO.BinaryReader binaryReader) { System.Collections.Generic.Queue <Moonfish.Tags.BlamPointer> pointerQueue = new System.Collections.Generic.Queue <Moonfish.Tags.BlamPointer>(base.ReadFields(binaryReader)); this.UpdatesPerSecond = binaryReader.ReadInt16(); this.fieldpad = binaryReader.ReadBytes(2); this.DeadCellPenalty = binaryReader.ReadSingle(); this.LiveCellBonus = binaryReader.ReadSingle(); this.fieldpad0 = binaryReader.ReadBytes(80); this.Width = binaryReader.ReadInt16(); this.Height = binaryReader.ReadInt16(); this.CellWidth = binaryReader.ReadSingle(); this.Height0 = binaryReader.ReadSingle(); this.Velocity = binaryReader.ReadVector2(); this.fieldpad1 = binaryReader.ReadBytes(28); this.Marker = binaryReader.ReadStringID(); this.CellularAutomata2dInterpolationFlags = ((InterpolationFlags)(binaryReader.ReadInt32())); this.BaseColor = binaryReader.ReadColorR8G8B8(); this.PeakColor = binaryReader.ReadColorR8G8B8(); this.fieldpad2 = binaryReader.ReadBytes(76); this.Width0 = binaryReader.ReadInt16(); this.Height1 = binaryReader.ReadInt16(); this.CellWidth0 = binaryReader.ReadSingle(); this.Velocity0 = binaryReader.ReadVector2(); this.fieldpad3 = binaryReader.ReadBytes(48); this.Marker0 = binaryReader.ReadStringID(); this.TextureWidth = binaryReader.ReadInt16(); this.fieldpad4 = binaryReader.ReadBytes(2); this.fieldpad5 = binaryReader.ReadBytes(48); this.Texture = binaryReader.ReadTagReference(); this.fieldpad6 = binaryReader.ReadBytes(160); pointerQueue.Enqueue(binaryReader.ReadBlamPointer(84)); return(pointerQueue); }
public static void Remap(Mat src, Mat dst, Mat map1, Mat map2, InterpolationFlags interpolation, BorderTypes borderType = BorderTypes.Constant) { var borderValue = new Scalar(0, 0, 0); Remap(src, dst, map1, map2, interpolation, borderType, borderValue); }
/// <summary> /// Applies an affine transformation to an image. /// </summary> /// <param name="src">Source image. CV_8U , CV_16U , CV_32S , or CV_32F depth and 1, 3, or 4 channels are /// supported.</param> /// <param name="dst">Destination image with the same type as src . The size is dsize .</param> /// <param name="m">*2x3* transformation matrix.</param> /// <param name="dsize">Size of the destination image.</param> /// <param name="flags">Combination of interpolation methods (see resize) and the optional flag /// WARP_INVERSE_MAP specifying that M is an inverse transformation(dst=\>src ). Only /// INTER_NEAREST, INTER_LINEAR, and INTER_CUBIC interpolation methods are supported.</param> /// <param name="borderMode">pixel extrapolation method; when borderMode=BORDER_TRANSPARENT, /// it means that the pixels in the destination image corresponding to the "outliers" /// in the source image are not modified by the function.</param> /// <param name="borderValue">value used in case of a constant border; by default, it is 0.</param> /// <param name="stream">Stream for the asynchronous version.</param> public static void warpAffine( InputArray src, OutputArray dst, InputArray m, Size dsize, InterpolationFlags flags = InterpolationFlags.Linear, BorderTypes borderMode = BorderTypes.Constant, Scalar?borderValue = null, Stream stream = null) { if (src == null) { throw new ArgumentNullException(nameof(src)); } if (dst == null) { throw new ArgumentNullException(nameof(dst)); } if (m == null) { throw new ArgumentNullException(nameof(m)); } src.ThrowIfDisposed(); dst.ThrowIfDisposed(); m.ThrowIfDisposed(); Scalar borderValue0 = borderValue.GetValueOrDefault(Scalar.All(0)); NativeMethods.cuda_warping_warpAffine(src.CvPtr, dst.CvPtr, m.CvPtr, dsize, (int)flags, (int)borderMode, borderValue0, stream?.CvPtr ?? Stream.Null.CvPtr); GC.KeepAlive(src); GC.KeepAlive(dst); GC.KeepAlive(m); dst.Fix(); }
public static void Remap(Mat src, Mat dst, Mat map1, Mat map2, InterpolationFlags interpolation, BorderTypes borderType, Scalar borderValue) { Exception exception = new Exception(); au_cv_imgproc_remap(src.CppPtr, dst.CppPtr, map1.CppPtr, map2.CppPtr, (int)interpolation, (int)borderType, borderValue.CppPtr, exception.CppPtr); exception.Check(); }
public static NDArray ImResize(NDArray src, int w, int h, InterpolationFlags interp = InterpolationFlags.Linear) { //Mat mat = new Mat(); //Mat input = src; //Cv2.Resize(input, input, new Size(w, h), interpolation: interp); //return input; return(nd.Cvimresize(src, w, h, (int)interp)); }
public static double ClampSize(this Mat self, double maxsize, InterpolationFlags inter = InterpolationFlags.Nearest) { double scaleFactor = CalcScaleFactor(self, maxsize); if (scaleFactor != 1) { Resize(self, scaleFactor, inter); } return(scaleFactor); }
public override System.Collections.Generic.Queue <Moonfish.Tags.BlamPointer> ReadFields(System.IO.BinaryReader binaryReader) { System.Collections.Generic.Queue <Moonfish.Tags.BlamPointer> pointerQueue = new System.Collections.Generic.Queue <Moonfish.Tags.BlamPointer>(base.ReadFields(binaryReader)); this.LightFlags = ((Flags)(binaryReader.ReadInt32())); this.Type = ((TypeEnum)(binaryReader.ReadInt16())); this.fieldpad = binaryReader.ReadBytes(2); this.SizeModifer = binaryReader.ReadRange(); this.ShadowQualityBias = binaryReader.ReadSingle(); this.ShadowTapBias = ((ShadowTapBiasEnum)(binaryReader.ReadInt16())); this.fieldpad0 = binaryReader.ReadBytes(2); this.Radius = binaryReader.ReadSingle(); this.SpecularRadius = binaryReader.ReadSingle(); this.NearWidth = binaryReader.ReadSingle(); this.HeightStretch = binaryReader.ReadSingle(); this.FieldOfView = binaryReader.ReadSingle(); this.FalloffDistance = binaryReader.ReadSingle(); this.CutoffDistance = binaryReader.ReadSingle(); this.LightInterpolationFlags = ((InterpolationFlags)(binaryReader.ReadInt32())); this.BloomBounds = binaryReader.ReadRange(); this.SpecularLowerBound = binaryReader.ReadColorR8G8B8(); this.SpecularUpperBound = binaryReader.ReadColorR8G8B8(); this.DiffuseLowerBound = binaryReader.ReadColorR8G8B8(); this.DiffuseUpperBound = binaryReader.ReadColorR8G8B8(); this.BrightnessBounds = binaryReader.ReadRange(); this.GelMap = binaryReader.ReadTagReference(); this.SpecularMask = ((SpecularMaskEnum)(binaryReader.ReadInt16())); this.fieldpad1 = binaryReader.ReadBytes(2); this.fieldpad2 = binaryReader.ReadBytes(4); this.FalloffFunction = ((FalloffFunctionEnum)(binaryReader.ReadInt16())); this.DiffuseContrast = ((DiffuseContrastEnum)(binaryReader.ReadInt16())); this.SpecularContrast = ((SpecularContrastEnum)(binaryReader.ReadInt16())); this.FalloffGeometry = ((FalloffGeometryEnum)(binaryReader.ReadInt16())); this.LensFlare = binaryReader.ReadTagReference(); this.BoundingRadius = binaryReader.ReadSingle(); this.LightVolume = binaryReader.ReadTagReference(); this.DefaultLightmapSetting = ((DefaultLightmapSettingEnum)(binaryReader.ReadInt16())); this.fieldpad3 = binaryReader.ReadBytes(2); this.LightmapHalfLife = binaryReader.ReadSingle(); this.LightmapLightScale = binaryReader.ReadSingle(); this.Duration = binaryReader.ReadSingle(); this.fieldpad4 = binaryReader.ReadBytes(2); this.LightLightFalloffFunction = ((LightFalloffFunctionEnum)(binaryReader.ReadInt16())); this.IlluminationFade = ((IlluminationFadeEnum)(binaryReader.ReadInt16())); this.ShadowFade = ((ShadowFadeEnum)(binaryReader.ReadInt16())); this.SpecularFade = ((SpecularFadeEnum)(binaryReader.ReadInt16())); this.fieldpad5 = binaryReader.ReadBytes(2); this.LightLightFlags0 = ((LightFlags0)(binaryReader.ReadInt32())); pointerQueue.Enqueue(binaryReader.ReadBlamPointer(8)); pointerQueue.Enqueue(binaryReader.ReadBlamPointer(8)); pointerQueue.Enqueue(binaryReader.ReadBlamPointer(16)); this.Shader = binaryReader.ReadTagReference(); return(pointerQueue); }
private Mat ExtractFrame(Mat frame_in) { Size dsize = new Size(frame_in.Width * 2, frame_in.Height * 2); double fx = 0, fy = 0; InterpolationFlags interpolation = InterpolationFlags.Lanczos4; // InterpolationFlags interpolation = InterpolationFlags.Cubic; Mat frame_out = frame_in.Resize(dsize, fx, fy, interpolation); // MemoryStream ms = new MemoryStream(frame_out.ToBytes()); // Image image = System.Drawing.Image.FromStream(ms); // image.Save(Path.Combine(dir, string.Format("{0:d10}", index) + ".png")); return(frame_out); }
public Bitmap main(bool isPictureSmall, Bitmap canvas, float reSizeRate, System.Drawing.Point px0, System.Drawing.Point px1, System.Drawing.Point px2, System.Drawing.Point px3, ref double rate, int FinalPictureWidth, int FinalPictureHeight) { Image img = canvas; imgSizeX = FinalPictureWidth; imgSizeY = FinalPictureHeight; int[] x = new int[4]; int[] y = new int[4]; rate = solve_squere_line(isPictureSmall, reSizeRate, px0, px1, px2, px3, ref x, ref y); px0.X = x[0]; px0.Y = y[0]; px1.X = x[1]; px1.Y = y[1]; px2.X = x[2]; px2.Y = y[2]; px3.X = x[3]; px3.Y = y[3]; // 四角形で切り取って表示 System.Drawing.Point[] p2pt = { px0, px1, px2, px3 }; // p2の四角形を引き伸ばして表示する Mat src_img = BitmapConverter.ToMat((Bitmap)img); Mat dst_img = src_img; // 四角形の変換前と変換後の対応する頂点をそれぞれセットする Point2f[] src_pt = new Point2f[4]; src_pt[0] = new Point2f(px0.X, px0.Y); src_pt[1] = new Point2f(px1.X, px1.Y); src_pt[2] = new Point2f(px2.X, px2.Y); src_pt[3] = new Point2f(px3.X, px3.Y); Point2f[] dst_pt = new Point2f[4]; dst_pt[0] = new Point2f(0, 0); //左上 dst_pt[1] = new Point2f(0, imgSizeY); //左下 dst_pt[2] = new Point2f(imgSizeX, imgSizeY); //右下 dst_pt[3] = new Point2f(imgSizeX, 0); //右上 Mat map_matrix = Cv2.GetPerspectiveTransform(src_pt, dst_pt); // 指定された透視投影変換行列により,cvWarpPerspectiveを用いて画像を変換させる OpenCvSharp.Size mysize = new OpenCvSharp.Size(imgSizeX, imgSizeY); InterpolationFlags OIFLiner = InterpolationFlags.Linear; BorderTypes OBTDefault = BorderTypes.Default; Cv2.WarpPerspective(src_img, dst_img, map_matrix, mysize, OIFLiner, OBTDefault); //dst_img.SaveImage("trapezoidal.jpg"); //debug用 return(dst_img.ToBitmap()); }
public static void ShiftImage(float tx = 5, float ty = 5, InterpolationFlags ipf = InterpolationFlags.Linear) { Glb.DrawMatAndHist0(Glb.matSrc); Point2f t = new Point2f(tx, ty); Point2f[] vSrc = { new Point2f(0, 0), new Point2f(1, 0), new Point2f(0, 1) }; Point2f[] vDst = vSrc.Select(v => v + t).ToArray(); Mat mTrans = Cv2.GetAffineTransform(vSrc, vDst); Mat mDst = Glb.matSrc.WarpAffine(mTrans, Glb.matSrc.Size(), ipf); Glb.DrawMatAndHist1(mDst); mDst.Dispose(); }
//public static void MakeImage(int bw = 1000, int bh = 1000, int seed = 0, int holeSize = 22, int gaussainSize = 31, int distortSize = 20, int imgNum = 256) { // void DrawCircle(System.Drawing.Graphics g, int x, int y, int r, System.Drawing.Brush br) { // g.FillEllipse(br, x - r, y - r, r + r, r + r); // } // Random rndg = new Random(seed); // using (System.Drawing.Bitmap bmp = new System.Drawing.Bitmap(bw, bh)) { // Console.WriteLine($"Make Iamge by code: ({bmp.Width}x{bmp.Height})"); // for (int imgIdx = 0; imgIdx < imgNum; imgIdx++) { // using (var g = System.Drawing.Graphics.FromImage(bmp)) { // System.Drawing.Rectangle rect = new System.Drawing.Rectangle(0, 0, bmp.Width, bmp.Height); // System.Drawing.Brush br = new System.Drawing.SolidBrush(System.Drawing.Color.FromArgb(35, 35, 35)); // g.FillRectangle(br, rect); // br.Dispose(); // g.FillRectangle(System.Drawing.Brushes.White, 100, 100, 50, 150); // g.FillRectangle(System.Drawing.Brushes.White, 100, 100, 150, 50); // Random rnd = new Random(seed); // for (int i = 0; i < 7; i++) { // bool xdistort = rndg.Next() % 32 == 0; // bool ydistort = rndg.Next() % 32 == 0; // int x; // int y; // if (xdistort) // x = rnd.Next(1, 10) * 100 + rndg.Next(-distortSize, distortSize); // else // x = rnd.Next(1, 10) * 100; // if (ydistort) // y = rnd.Next(1, 10) * 100 + rndg.Next(-distortSize, distortSize); // else // y = rnd.Next(1, 10) * 100; // DrawCircle(g, x, y, holeSize, System.Drawing.Brushes.White); // } // } // var matGray = bmp.ToMat().CvtColor(ColorConversionCodes.BGR2GRAY); // var matBlur = matGray.GaussianBlur(new Size(gaussainSize, gaussainSize), gaussainSize, gaussainSize, BorderTypes.Replicate); // var matResult = matBlur.Resize(new Size(bw / 10, bh / 10), 0, 0, InterpolationFlags.Linear); // string filePath = $"c:\\test\\chole\\img_{imgIdx:00}.bmp"; // matResult.SaveImage(filePath); // Console.WriteLine($"SaveImge: ({filePath})"); // //Glb.DrawMatAndHist0(matGray); // //Glb.DrawMatAndHist1(matBlur); // //Glb.DrawMatAndHist2(matResult); // matGray.Dispose(); // matBlur.Dispose(); // matResult.Dispose(); // } // } //} public static void RoateImage(double rotDegree = 90, InterpolationFlags ipf = InterpolationFlags.Linear) { Glb.DrawMatAndHist0(Glb.matSrc); var matGray = Glb.matSrc.CvtColor(ColorConversionCodes.BGR2GRAY); Glb.DrawMatAndHist1(matGray); Size size = matGray.Size(); Mat matRot = Cv2.GetRotationMatrix2D(new Point2f(size.Width / 2, size.Height / 2), rotDegree, 1); Mat matDst = matGray.WarpAffine(matRot, size, ipf); Glb.DrawMatAndHist2(matDst); matRot.Dispose(); matDst.Dispose(); }
public static void Resize(double magnify = 8, InterpolationFlags interpolation = InterpolationFlags.Linear) { Glb.DrawMatAndHist0(Glb.matSrc); var matGray = Glb.matSrc.CvtColor(ColorConversionCodes.BGR2GRAY); Glb.DrawMatAndHist1(matGray); var sizeSrc = Glb.matSrc.Size(); var sizeDst = new Size(sizeSrc.Width * magnify, sizeSrc.Height * magnify); var matResize = matGray.Resize(sizeDst, interpolation: interpolation); Glb.DrawMatAndHist2(matResize); matGray.Dispose(); matResize.Dispose(); }
public static NDArray ResizeLong(NDArray src, int size, InterpolationFlags interp = InterpolationFlags.Area) { int new_w = 0; int new_h = 0; var(h, w) = src.Shape; if (h > w) { new_h = size; new_w = size * w / h; } else { new_h = size * h / w; new_w = size; } return(ImResize(src, new_w, new_h, interp: Img.GetInterp(interp, (h, w, new_h, new_w)))); }
public static void ResizeFloat(double magnify = 8, InterpolationFlags interpolation = InterpolationFlags.Linear) { Glb.DrawMatAndHist0(Glb.matSrc); var matFloat = new Mat(); Glb.matSrc.CvtColor(ColorConversionCodes.BGR2GRAY).ConvertTo(matFloat, MatType.CV_32FC1); Glb.DrawMatAndHist1(matFloat); var sizeSrc = Glb.matSrc.Size(); var sizeDst = new Size(sizeSrc.Width * magnify, sizeSrc.Height * magnify); var matResize = matFloat.Resize(sizeDst, interpolation: interpolation); Glb.DrawMatAndHist2(matResize); matFloat.Dispose(); matResize.Dispose(); }
public ISequence <Mat> PyrDown( [InputPin(Description = "", PropertyMode = PropertyMode.Never)] Mat image, [InputPin(Description = "", PropertyMode = PropertyMode.Default, DefaultValue = "1, 1")] Size minSize, [InputPin(Description = "", PropertyMode = PropertyMode.Default)] float scale = defaultScale, [InputPin(Description = "", PropertyMode = PropertyMode.Default)] InterpolationFlags filter = InterpolationFlags.Lanczos4 ) { if (scale <= 0) { throw new ArgumentException("'scale' must be positive.", "scale"); } if (minSize.Width <= 0 || minSize.Height <= 0) { throw new ArgumentException("'minSize' must be positive.", "minSize"); } return(PyrDownInternal(image, minSize, scale, filter).ToSequence()); }
/// <summary> /// Resizes an image. /// </summary> /// <param name="src">Source image.</param> /// <param name="dst">Destination image with the same type as src . The size is dsize (when it is non-zero) /// or the size is computed from src.size() , fx , and fy.</param> /// <param name="dsize">Destination image size. If it is zero, it is computed as: /// \f[\texttt{dsize = Size(round(fx* src.cols), round(fy* src.rows))}\f] /// Either dsize or both fx and fy must be non-zero.</param> /// <param name="fx">Scale factor along the horizontal axis. If it is zero, it is computed as: /// \f[\texttt{(double) dsize.width/src.cols}\f]</param> /// <param name="fy">Scale factor along the vertical axis. If it is zero, it is computed as: /// \f[\texttt{(double) dsize.height/src.rows}\f]</param> /// <param name="interpolation">interpolation Interpolation method. INTER_NEAREST , INTER_LINEAR and INTER_CUBIC are /// supported for now.</param> /// <param name="stream">Stream for the asynchronous version.</param> public static void Resize(InputArray src, OutputArray dst, Size dsize, double fx = 0, double fy = 0, InterpolationFlags interpolation = InterpolationFlags.Linear, Stream stream = null) { if (src == null) { throw new ArgumentNullException(nameof(src)); } if (dst == null) { throw new ArgumentNullException(nameof(dst)); } src.ThrowIfDisposed(); dst.ThrowIfNotReady(); NativeMethods.cuda_warping_resize(src.CvPtr, dst.CvPtr, dsize, fx, fy, (int)interpolation, stream?.CvPtr ?? Stream.Null.CvPtr); GC.KeepAlive(src); GC.KeepAlive(dst); dst.Fix(); }
/// <summary> /// Rotates an image around the origin (0,0) and then shifts it. /// </summary> /// <param name="src">Source image. Supports 1, 3 or 4 channels images with CV_8U , CV_16U or CV_32F /// depth.</param> /// <param name="dst">Destination image with the same type as src . The size is dsize .</param> /// <param name="dsize">Size of the destination image.</param> /// <param name="angle">Angle of rotation in degrees.</param> /// <param name="xShift">Shift along the horizontal axis.</param> /// <param name="yShift">Shift along the vertical axis.</param> /// <param name="flags">Interpolation method. Only INTER_NEAREST , INTER_LINEAR , and INTER_CUBIC /// are supported.</param> /// <param name="stream">Stream for the asynchronous version.</param> public static void rotate( InputArray src, OutputArray dst, Size dsize, double angle, double xShift = 0, double yShift = 0, InterpolationFlags flags = InterpolationFlags.Linear, Stream stream = null) { if (src == null) { throw new ArgumentNullException(nameof(src)); } if (dst == null) { throw new ArgumentNullException(nameof(dst)); } src.ThrowIfDisposed(); dst.ThrowIfDisposed(); NativeMethods.cuda_warping_rotate(src.CvPtr, dst.CvPtr, dsize, angle, xShift, yShift, (int)flags, stream?.CvPtr ?? Stream.Null.CvPtr); GC.KeepAlive(src); GC.KeepAlive(dst); dst.Fix(); }
/// <summary> /// Applies a perspective transformation to an image. /// </summary> /// <param name="m">3x3 transformation matrix.</param> /// <param name="dsize">size of the output image.</param> /// <param name="flags">combination of interpolation methods (INTER_LINEAR or INTER_NEAREST) /// and the optional flag WARP_INVERSE_MAP, that sets M as the inverse transformation (dst -> src).</param> /// <param name="borderMode">pixel extrapolation method (BORDER_CONSTANT or BORDER_REPLICATE).</param> /// <param name="borderValue">value used in case of a constant border; by default, it equals 0.</param> /// <returns>output image that has the size dsize and the same type as src.</returns> public Mat WarpPerspective(Mat m, Size dsize, InterpolationFlags flags = InterpolationFlags.Linear, BorderTypes borderMode = BorderTypes.Constant, Scalar? borderValue = null) { var dst = new Mat(); Cv2.WarpPerspective(this, dst, m, dsize, flags, borderMode, borderValue); return dst; }
public static void Remap(Core.Mat src, Core.Mat dst, Core.Mat map1, Core.Mat map2, InterpolationFlags interpolation) { Core.Exception exception = new Core.Exception(); au_cv_imgproc_remap3(src.cppPtr, dst.cppPtr, map1.cppPtr, map2.cppPtr, (int)interpolation, exception.cppPtr); exception.Check(); }
public static void Remap(Core.Mat src, Core.Mat dst, Core.Mat map1, Core.Mat map2, InterpolationFlags interpolation, BorderTypes borderType, Core.Scalar borderValue) { Core.Exception exception = new Core.Exception(); au_cv_imgproc_remap1(src.cppPtr, dst.cppPtr, map1.cppPtr, map2.cppPtr, (int)interpolation, (int)borderType, borderValue.cppPtr, exception.cppPtr); exception.Check(); }
/// <summary> /// 画像の透視変換を行います. /// </summary> /// <param name="src">入力画像</param> /// <param name="dst">サイズが dsize で src と同じタイプの出力画像</param> /// <param name="m">3x3 の変換行列</param> /// <param name="dsize">出力画像のサイズ</param> /// <param name="flags">補間手法</param> /// <param name="borderMode">ピクセル外挿手法. /// borderMode=BORDER_TRANSPARENT の場合,入力画像中の「はずれ値」に対応する /// 出力画像中のピクセルが,この関数では変更されないことを意味します</param> /// <param name="borderValue">定数境界モードで利用されるピクセル値.</param> #else /// <summary> /// Applies a perspective transformation to an image. /// </summary> /// <param name="src">input image.</param> /// <param name="dst">output image that has the size dsize and the same type as src.</param> /// <param name="m">3x3 transformation matrix.</param> /// <param name="dsize">size of the output image.</param> /// <param name="flags">combination of interpolation methods (INTER_LINEAR or INTER_NEAREST) /// and the optional flag WARP_INVERSE_MAP, that sets M as the inverse transformation (dst -> src).</param> /// <param name="borderMode">pixel extrapolation method (BORDER_CONSTANT or BORDER_REPLICATE).</param> /// <param name="borderValue">value used in case of a constant border; by default, it equals 0.</param> #endif public static void WarpPerspective( InputArray src, OutputArray dst, InputArray m, Size dsize, InterpolationFlags flags = InterpolationFlags.Linear, BorderTypes borderMode = BorderTypes.Constant, Scalar? borderValue = null) { if (src == null) throw new ArgumentNullException(nameof(src)); if (dst == null) throw new ArgumentNullException(nameof(dst)); if (m == null) throw new ArgumentNullException(nameof(m)); src.ThrowIfDisposed(); dst.ThrowIfDisposed(); m.ThrowIfDisposed(); Scalar borderValue0 = borderValue.GetValueOrDefault(Scalar.All(0)); NativeMethods.imgproc_warpPerspective_MisInputArray( src.CvPtr, dst.CvPtr, m.CvPtr, dsize, (int)flags, (int)borderMode, borderValue0); GC.KeepAlive(src); dst.Fix(); }
public ResizeAug(int size, InterpolationFlags interp = InterpolationFlags.Area) { Size = size; Interp = interp; }
public InterpolateAttribute(InterpolationFlags flags = InterpolationFlags.Default) { Smoothing = 0f; Flags = InterpolationFlags.Default; }
/// <summary> /// Applies a generic geometrical transformation to an image. /// </summary> /// <param name="src">Source image.</param> /// <param name="dst">Destination image. It has the same size as map1 and the same type as src</param> /// <param name="map1">The first map of either (x,y) points or just x values having the type CV_16SC2, CV_32FC1, or CV_32FC2.</param> /// <param name="map2">The second map of y values having the type CV_16UC1, CV_32FC1, or none (empty map if map1 is (x,y) points), respectively.</param> /// <param name="interpolation">Interpolation method. The method INTER_AREA is not supported by this function.</param> /// <param name="borderMode">Pixel extrapolation method. When borderMode=BORDER_TRANSPARENT, /// it means that the pixels in the destination image that corresponds to the "outliers" in /// the source image are not modified by the function.</param> /// <param name="borderValue">Value used in case of a constant border. By default, it is 0.</param> public static void Remap( InputArray src, OutputArray dst, InputArray map1, InputArray map2, InterpolationFlags interpolation = InterpolationFlags.Linear, BorderTypes borderMode = BorderTypes.Constant, Scalar? borderValue = null) { if (src == null) throw new ArgumentNullException(nameof(src)); if (dst == null) throw new ArgumentNullException(nameof(dst)); if (map1 == null) throw new ArgumentNullException(nameof(map1)); if (map2 == null) throw new ArgumentNullException(nameof(map2)); src.ThrowIfDisposed(); dst.ThrowIfNotReady(); map1.ThrowIfDisposed(); map2.ThrowIfDisposed(); Scalar borderValue0 = borderValue.GetValueOrDefault(Scalar.All(0)); NativeMethods.imgproc_remap(src.CvPtr, dst.CvPtr, map1.CvPtr, map2.CvPtr, (int)interpolation, (int)borderMode, borderValue0); GC.KeepAlive(src); dst.Fix(); }
/// <summary> /// Remaps an image to polar space. /// </summary> /// <param name="src">Source image</param> /// <param name="dst">Destination image</param> /// <param name="center">The transformation center</param> /// <param name="maxRadius">Inverse magnitude scale parameter</param> /// <param name="flags">A combination of interpolation methods, see cv::InterpolationFlags</param> public static void LinearPolar( InputArray src, OutputArray dst, Point2f center, double maxRadius, InterpolationFlags flags) { if (src == null) throw new ArgumentNullException(nameof(src)); if (dst == null) throw new ArgumentNullException(nameof(dst)); src.ThrowIfDisposed(); dst.ThrowIfNotReady(); NativeMethods.imgproc_linearPolar(src.CvPtr, dst.CvPtr, center, maxRadius, (int)flags); GC.KeepAlive(src); dst.Fix(); }
/// <summary> /// Resizes an image. /// </summary> /// <param name="dsize">output image size; if it equals zero, it is computed as: /// dsize = Size(round(fx*src.cols), round(fy*src.rows)) /// Either dsize or both fx and fy must be non-zero.</param> /// <param name="fx">scale factor along the horizontal axis; when it equals 0, /// it is computed as: (double)dsize.width/src.cols</param> /// <param name="fy">scale factor along the vertical axis; when it equals 0, /// it is computed as: (double)dsize.height/src.rows</param> /// <param name="interpolation">interpolation method</param> /// <returns>output image; it has the size dsize (when it is non-zero) or the size computed /// from src.size(), fx, and fy; the type of dst is the same as of src.</returns> public Mat Resize(Size dsize, double fx = 0, double fy = 0, InterpolationFlags interpolation = InterpolationFlags.Linear) { var dst = new Mat(); Cv2.Resize(this, dst, dsize, fx, fy, interpolation); return dst; }
public static NDArray ImResize(NDArray src, int w, int h, InterpolationFlags interp = InterpolationFlags.Linear) { var(oh, ow) = src.Shape; return(Img.ImResize(src, w, h, interp: Img.GetInterp(interp, (oh, ow, h, w)))); }
public static void Resize(this Mat self, double scaleFactor, InterpolationFlags inter = InterpolationFlags.Linear) { Resize(self, new Size(self.Width * scaleFactor, self.Height * scaleFactor), 0, 0, inter); }
public static NDArray ResizeShortWithin(NDArray src, int @short, int max_size, int mult_base = 1, InterpolationFlags interp = InterpolationFlags.Area) { var(h, w) = src.Shape; var _tup_2 = w > h ? (h, w) : (w, h); var im_size_min = _tup_2.Item1; var im_size_max = _tup_2.Item2; float scale = (float)@short / im_size_min; if (Math.Round(scale * im_size_max / mult_base) * mult_base > max_size) { // fit in max_size scale = (float)(Math.Floor(Convert.ToDouble(max_size) / mult_base) * mult_base) / im_size_max; } var(new_w, new_h) = (Convert.ToInt32(Math.Round(w * scale / mult_base) * mult_base), Convert.ToInt32(Math.Round(h * scale / mult_base) * mult_base)); return(ImResize(src, new_w, new_h, interp: Img.GetInterp(interp, (h, w, new_h, new_w)))); }
public static void Resize(this Mat self, Size size, double fx = 0, double fy = 0, InterpolationFlags inter = InterpolationFlags.Linear) { Resize(self, self, size, fx, fy, inter); }
private void FrmMain_Load(object sender, EventArgs e) { cboxInterpolation.SelectedIndex = 4; interpolation = InterpolationFlags.Lanczos4; }
public static void Resize(this Mat self, Mat output, Size size, double fx = 0, double fy = 0, InterpolationFlags inter = InterpolationFlags.Linear) { Cv2.Resize(self, output, size.ToCvSize(), fx, fy, inter); }
/// <summary> /// Applies a generic geometrical transformation to an image. /// </summary> /// <param name="map1">The first map of either (x,y) points or just x values having the type CV_16SC2, CV_32FC1, or CV_32FC2.</param> /// <param name="map2">The second map of y values having the type CV_16UC1, CV_32FC1, or none (empty map if map1 is (x,y) points), respectively.</param> /// <param name="interpolation">Interpolation method. The method INTER_AREA is not supported by this function.</param> /// <param name="borderMode">Pixel extrapolation method. When borderMode=BORDER_TRANSPARENT, /// it means that the pixels in the destination image that corresponds to the "outliers" in /// the source image are not modified by the function.</param> /// <param name="borderValue">Value used in case of a constant border. By default, it is 0.</param> /// <returns>Destination image. It has the same size as map1 and the same type as src</returns> public Mat Remap(InputArray map1, InputArray map2, InterpolationFlags interpolation = InterpolationFlags.Linear, BorderTypes borderMode = BorderTypes.Constant, Scalar? borderValue = null) { var dst = new Mat(); Cv2.Remap(this, dst, map1, map2, interpolation, borderMode, borderValue); return dst; }
/// <summary> /// Resizes an image. /// </summary> /// <param name="src">input image.</param> /// <param name="dst">output image; it has the size dsize (when it is non-zero) or the size computed /// from src.size(), fx, and fy; the type of dst is the same as of src.</param> /// <param name="dsize">output image size; if it equals zero, it is computed as: /// dsize = Size(round(fx*src.cols), round(fy*src.rows)) /// Either dsize or both fx and fy must be non-zero.</param> /// <param name="fx">scale factor along the horizontal axis; when it equals 0, /// it is computed as: (double)dsize.width/src.cols</param> /// <param name="fy">scale factor along the vertical axis; when it equals 0, /// it is computed as: (double)dsize.height/src.rows</param> /// <param name="interpolation">interpolation method</param> public static void Resize(InputArray src, OutputArray dst, Size dsize, double fx = 0, double fy = 0, InterpolationFlags interpolation = InterpolationFlags.Linear) { if (src == null) throw new ArgumentNullException(nameof(src)); if (dst == null) throw new ArgumentNullException(nameof(dst)); src.ThrowIfDisposed(); dst.ThrowIfNotReady(); NativeMethods.imgproc_resize(src.CvPtr, dst.CvPtr, dsize, fx, fy, (int)interpolation); GC.KeepAlive(src); dst.Fix(); }