本文整理汇总了C#中ManagedCuda.NPP.NppiRect类的典型用法代码示例。如果您正苦于以下问题:C# NppiRect类的具体用法?C# NppiRect怎么用?C# NppiRect使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
NppiRect类属于ManagedCuda.NPP命名空间,在下文中一共展示了NppiRect类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: RemapA
/// <summary>
/// image remap. Not affecting Alpha.
/// </summary>
/// <param name="dst">Destination-Image</param>
/// <param name="pXMap">Device memory pointer to 2D image array of X coordinate values to be used when sampling source image. </param>
/// <param name="pYMap">Device memory pointer to 2D image array of Y coordinate values to be used when sampling source image. </param>
/// <param name="eInterpolation">The type of eInterpolation to perform resampling.</param>
public void RemapA(NPPImage_8uC4 dst, NPPImage_32fC1 pXMap, NPPImage_32fC1 pYMap, InterpolationMode eInterpolation)
{
NppiRect srcRect = new NppiRect(_pointRoi, _sizeRoi);
status = NPPNativeMethods.NPPi.Remap.nppiRemap_8u_AC4R(_devPtr, _sizeRoi, _pitch, srcRect, pXMap.DevicePointerRoi, pXMap.Pitch, pYMap.DevicePointerRoi, pYMap.Pitch, dst.DevicePointerRoi, dst.Pitch, dst.SizeRoi, eInterpolation);
Debug.WriteLine(String.Format("{0:G}, {1}: {2}", DateTime.Now, "nppiRemap_8u_AC4R", status));
NPPException.CheckNppStatus(status, this);
}
示例2: Contains
/// <summary>
/// Determines if the rectangular region represented by rect is entirely contained within this Rectangle structure.
/// </summary>
/// <param name="rect"></param>
/// <returns></returns>
public bool Contains(NppiRect rect)
{
return Contains(rect.Location) && Contains(rect.Location + rect.Size);
}
示例3: Intersect
/// <summary>
/// Returns a third Rectangle structure that represents the intersection of two other Rectangle structures.If there is no intersection, an empty Rectangle is returned.
/// </summary>
/// <param name="rectA"></param>
/// <param name="rectB"></param>
/// <returns></returns>
public static NppiRect Intersect(NppiRect rectA, NppiRect rectB)
{
int iX = rectA.Left;
if (iX < rectB.Left)
{
iX = rectB.Left;
}
int iY = rectA.Top;
if (iY < rectB.Top)
{
iY = rectB.Top;
}
int iX2 = rectA.Right;
if (iX2 > rectB.Right)
{
iX2 = rectB.Right;
}
int iY2 = rectA.Bottom;
if (iY2 > rectB.Bottom)
{
iY2 = rectB.Bottom;
}
int iWidth = iX2 - iX + 1;
int iHeight = iY2 - iY + 1;
if (iWidth <= 0 || iHeight <= 0)
{
iX = 0;
iY = 0;
iWidth = 0;
iHeight = 0;
}
return new NppiRect(iX, iY, iWidth, iHeight);
}
示例4: Divide
/// <summary>
/// per element Divide
/// </summary>
/// <param name="src"></param>
/// <param name="value"></param>
/// <returns></returns>
public static NppiRect Divide(int src, NppiRect value)
{
NppiRect ret = new NppiRect(src / value.x, src / value.y, src / value.width, src / value.height);
return ret;
}
示例5: Multiply
/// <summary>
/// per element Multiply
/// </summary>
/// <param name="src"></param>
/// <param name="value"></param>
/// <returns></returns>
public static NppiRect Multiply(int src, NppiRect value)
{
NppiRect ret = new NppiRect(src * value.x, src * value.y, src * value.width, src * value.height);
return ret;
}
示例6: WarpPerspectiveQuadA
/// <summary>
/// Perspective transform of an image. Not affecting Alpha channel.<para/>
/// This function performs perspective warping of a the specified
/// quadrangle in the source image to the specified quadrangle in the
/// destination image. The function nppiWarpPerspectiveQuad uses the same
/// formulas for pixel mapping as in nppiWarpPerspective function. The
/// transform coefficients are computed internally.
/// The transformed part of the source image is resampled using the specified
/// interpolation method and written to the destination ROI.<para/>
/// NPPI specific recommendation: <para/>
/// The function operates using 2 types of kernels: fast and accurate. The fast
/// method is about 4 times faster than its accurate variant,
/// but doesn't perform memory access checks and requires the destination ROI
/// to be 64 bytes aligned. Hence any destination ROI is
/// chunked into 3 vertical stripes: the first and the third are processed by
/// accurate kernels and the central one is processed by the fast one.
/// In order to get the maximum available speed of execution, the projection of
/// destination ROI onto image addresses must be 64 bytes aligned. This is
/// always true if the values <para/>
/// <code>(int)((void *)(pDst + dstRoi.x))</code> and <para/>
/// <code>(int)((void *)(pDst + dstRoi.x + dstRoi.width))</code> <para/>
/// are multiples of 64. Another rule of thumb is to specify destination ROI in
/// such way that left and right sides of the projected image are separated from
/// the ROI by at least 63 bytes from each side. However, this requires the
/// whole ROI to be part of allocated memory. In case when the conditions above
/// are not satisfied, the function may decrease in speed slightly and will
/// return NPP_MISALIGNED_DST_ROI_WARNING warning.
/// </summary>
/// <param name="srcQuad">Source quadrangle [4,2]</param>
/// <param name="dest">Destination image</param>
/// <param name="destQuad">Destination quadrangle [4,2]</param>
/// <param name="eInterpolation">Interpolation mode: can be <see cref="InterpolationMode.NearestNeighbor"/>, <see cref="InterpolationMode.Linear"/> or <see cref="InterpolationMode.Cubic"/></param>
public void WarpPerspectiveQuadA(double[,] srcQuad, NPPImage_32sC4 dest, double[,] destQuad, InterpolationMode eInterpolation)
{
NppiRect rectIn = new NppiRect(_pointRoi, _sizeRoi);
NppiRect rectOut = new NppiRect(dest.PointRoi, dest.SizeRoi);
status = NPPNativeMethods.NPPi.PerspectiveTransforms.nppiWarpPerspectiveQuad_32s_AC4R(_devPtr, _sizeOriginal, _pitch, rectIn, srcQuad, dest.DevicePointer, dest.Pitch, rectOut, destQuad, eInterpolation);
Debug.WriteLine(String.Format("{0:G}, {1}: {2}", DateTime.Now, "nppiWarpPerspectiveQuad_32s_AC4R", status));
NPPException.CheckNppStatus(status, this);
}
示例7: WarpPerspectiveQuad
/// <summary>
/// Perspective transform of an image.<para/>
/// This function performs perspective warping of a the specified
/// quadrangle in the source image to the specified quadrangle in the
/// destination image. The function nppiWarpPerspectiveQuad uses the same
/// formulas for pixel mapping as in nppiWarpPerspective function. The
/// transform coefficients are computed internally.
/// The transformed part of the source image is resampled using the specified
/// interpolation method and written to the destination ROI.<para/>
/// NPPI specific recommendation: <para/>
/// The function operates using 2 types of kernels: fast and accurate. The fast
/// method is about 4 times faster than its accurate variant,
/// but doesn't perform memory access checks and requires the destination ROI
/// to be 64 bytes aligned. Hence any destination ROI is
/// chunked into 3 vertical stripes: the first and the third are processed by
/// accurate kernels and the central one is processed by the fast one.
/// In order to get the maximum available speed of execution, the projection of
/// destination ROI onto image addresses must be 64 bytes aligned. This is
/// always true if the values <para/>
/// <code>(int)((void *)(pDst + dstRoi.x))</code> and <para/>
/// <code>(int)((void *)(pDst + dstRoi.x + dstRoi.width))</code> <para/>
/// are multiples of 64. Another rule of thumb is to specify destination ROI in
/// such way that left and right sides of the projected image are separated from
/// the ROI by at least 63 bytes from each side. However, this requires the
/// whole ROI to be part of allocated memory. In case when the conditions above
/// are not satisfied, the function may decrease in speed slightly and will
/// return NPP_MISALIGNED_DST_ROI_WARNING warning.
/// </summary>
/// <param name="src0">Source image (Channel 0)</param>
/// <param name="src1">Source image (Channel 1)</param>
/// <param name="src2">Source image (Channel 2)</param>
/// <param name="srcQuad">Source quadrangle [4,2]</param>
/// <param name="dest0">Destination image (Channel 0)</param>
/// <param name="dest1">Destination image (Channel 1)</param>
/// <param name="dest2">Destination image (Channel 2)</param>
/// <param name="destQuad">Destination quadrangle [4,2]</param>
/// <param name="eInterpolation">Interpolation mode: can be <see cref="InterpolationMode.NearestNeighbor"/>, <see cref="InterpolationMode.Linear"/> or <see cref="InterpolationMode.Cubic"/></param>
public static void WarpPerspectiveQuad(NPPImage_32sC1 src0, NPPImage_32sC1 src1, NPPImage_32sC1 src2, double[,] srcQuad, NPPImage_32sC1 dest0, NPPImage_32sC1 dest1, NPPImage_32sC1 dest2, double[,] destQuad, InterpolationMode eInterpolation)
{
NppiRect rectIn = new NppiRect(src0.PointRoi, src0.SizeRoi);
NppiRect rectOut = new NppiRect(dest0.PointRoi, dest0.SizeRoi);
CUdeviceptr[] src = new CUdeviceptr[] { src0.DevicePointer, src1.DevicePointer, src2.DevicePointer };
CUdeviceptr[] dst = new CUdeviceptr[] { dest0.DevicePointer, dest1.DevicePointer, dest2.DevicePointer };
NppStatus status = NPPNativeMethods.NPPi.PerspectiveTransforms.nppiWarpPerspectiveQuad_32s_P4R(src, src0.Size, src0.Pitch, rectIn, srcQuad, dst, dest0.Pitch, rectOut, destQuad, eInterpolation);
Debug.WriteLine(String.Format("{0:G}, {1}: {2}", DateTime.Now, "nppiWarpPerspectiveQuad_32s_P4R", status));
NPPException.CheckNppStatus(status, null);
}
示例8: GetAffineQuad
/// <summary>
/// Calculates affine transform projection of given source rectangular ROI
/// </summary>
/// <param name="coeffs">Affine transform coefficients [2,3]</param>
/// <returns>Destination quadrangle [4,2]</returns>
public double[,] GetAffineQuad(double[,] coeffs)
{
double[,] quad = new double[4, 2];
NppiRect rect = new NppiRect(_pointRoi, _sizeRoi);
status = NPPNativeMethods.NPPi.AffinTransforms.nppiGetAffineQuad(rect, quad, coeffs);
Debug.WriteLine(String.Format("{0:G}, {1}: {2}", DateTime.Now, "nppiGetAffineQuad", status));
NPPException.CheckNppStatus(status, this);
return quad;
}
示例9: GetPerspectiveBound
/// <summary>
/// Calculates bounding box of the affine transform projection of the given source rectangular ROI
/// </summary>
/// <param name="coeffs">Perspective transform coefficients [3,3]</param>
/// <returns>Destination quadrangle [2,2]</returns>
public double[,] GetPerspectiveBound(double[,] coeffs)
{
double[,] bound = new double[2, 2];
NppiRect rect = new NppiRect(_pointRoi, _sizeRoi);
status = NPPNativeMethods.NPPi.PerspectiveTransforms.nppiGetPerspectiveBound(rect, bound, coeffs);
Debug.WriteLine(String.Format("{0:G}, {1}: {2}", DateTime.Now, "nppiGetPerspectiveBound", status));
NPPException.CheckNppStatus(status, this);
return bound;
}
示例10: Remap
/// <summary>
/// planar image remap.
/// </summary>
/// <param name="src0">Source image (Channel 0)</param>
/// <param name="src1">Source image (Channel 1)</param>
/// <param name="src2">Source image (Channel 2)</param>
/// <param name="src3">Source image (Channel 3)</param>
/// <param name="dest0">Destination image (Channel 0)</param>
/// <param name="dest1">Destination image (Channel 1)</param>
/// <param name="dest2">Destination image (Channel 2)</param>
/// <param name="dest3">Destination image (Channel 3)</param>
/// <param name="pXMap">Device memory pointer to 2D image array of X coordinate values to be used when sampling source image. </param>
/// <param name="pYMap">Device memory pointer to 2D image array of Y coordinate values to be used when sampling source image. </param>
/// <param name="eInterpolation">The type of eInterpolation to perform resampling.</param>
public static void Remap(NPPImage_8uC1 src0, NPPImage_8uC1 src1, NPPImage_8uC1 src2, NPPImage_8uC1 src3, NPPImage_8uC1 dest0, NPPImage_8uC1 dest1, NPPImage_8uC1 dest2, NPPImage_8uC1 dest3, NPPImage_32fC1 pXMap, NPPImage_32fC1 pYMap, InterpolationMode eInterpolation)
{
CUdeviceptr[] src = new CUdeviceptr[] { src0.DevicePointer, src1.DevicePointer, src2.DevicePointer, src3.DevicePointer };
CUdeviceptr[] dst = new CUdeviceptr[] { dest0.DevicePointerRoi, dest1.DevicePointerRoi, dest2.DevicePointerRoi, dest3.DevicePointerRoi };
NppiRect srcRect = new NppiRect(src0.PointRoi, src0.SizeRoi);
NppStatus status = NPPNativeMethods.NPPi.Remap.nppiRemap_8u_P4R(src, src0.SizeRoi, src0.Pitch, srcRect, pXMap.DevicePointerRoi, pXMap.Pitch, pYMap.DevicePointerRoi, pYMap.Pitch, dst, dest0.Pitch, dest0.SizeRoi, eInterpolation);
Debug.WriteLine(String.Format("{0:G}, {1}: {2}", DateTime.Now, "nppiRemap_8u_P4R", status));
NPPException.CheckNppStatus(status, null);
}
示例11: ResizeSqrPixel
/// <summary>
/// planar image resize.
/// </summary>
/// <param name="src0">Source image (Channel 0)</param>
/// <param name="src1">Source image (Channel 1)</param>
/// <param name="src2">Source image (Channel 2)</param>
/// <param name="src3">Source image (Channel 3)</param>
/// <param name="dest0">Destination image (Channel 0)</param>
/// <param name="dest1">Destination image (Channel 1)</param>
/// <param name="dest2">Destination image (Channel 2)</param>
/// <param name="dest3">Destination image (Channel 3)</param>
/// <param name="nXFactor">Factor by which x dimension is changed. </param>
/// <param name="nYFactor">Factor by which y dimension is changed. </param>
/// <param name="nXShift">Source pixel shift in x-direction.</param>
/// <param name="nYShift">Source pixel shift in y-direction.</param>
/// <param name="eInterpolation">The type of eInterpolation to perform resampling.</param>
public static void ResizeSqrPixel(NPPImage_8uC1 src0, NPPImage_8uC1 src1, NPPImage_8uC1 src2, NPPImage_8uC1 src3, NPPImage_8uC1 dest0, NPPImage_8uC1 dest1, NPPImage_8uC1 dest2, NPPImage_8uC1 dest3, double nXFactor, double nYFactor, double nXShift, double nYShift, InterpolationMode eInterpolation)
{
CUdeviceptr[] src = new CUdeviceptr[] { src0.DevicePointer, src1.DevicePointer, src2.DevicePointer, src3.DevicePointer };
CUdeviceptr[] dst = new CUdeviceptr[] { dest0.DevicePointer, dest1.DevicePointer, dest2.DevicePointer, dest3.DevicePointer };
NppiRect srcRect = new NppiRect(src0.PointRoi, src0.SizeRoi);
NppiRect dstRect = new NppiRect(dest0.PointRoi, dest0.SizeRoi);
NppStatus status = NPPNativeMethods.NPPi.ResizeSqrPixel.nppiResizeSqrPixel_8u_P4R(src, src0.SizeRoi, src0.Pitch, srcRect, dst, dest0.Pitch, dstRect, nXFactor, nYFactor, nXShift, nYShift, eInterpolation);
Debug.WriteLine(String.Format("{0:G}, {1}: {2}", DateTime.Now, "nppiResizeSqrPixel_8u_P4R", status));
NPPException.CheckNppStatus(status, null);
}
示例12: ScaleA
/// <summary>
/// image conversion. Not affecting Alpha.
/// </summary>
/// <param name="dst">Destination-Image</param>
/// <param name="nMin">specifies the minimum saturation value to which every output value will be clamped.</param>
/// <param name="nMax">specifies the maximum saturation value to which every output value will be clamped.</param>
public void ScaleA(NPPImage_32fC4 dst, float nMin, float nMax)
{
NppiRect srcRect = new NppiRect(_pointRoi, _sizeRoi);
status = NPPNativeMethods.NPPi.Scale.nppiScale_8u32f_AC4R(_devPtrRoi, _pitch, dst.DevicePointerRoi, dst.Pitch, _sizeRoi, nMin, nMax);
Debug.WriteLine(String.Format("{0:G}, {1}: {2}", DateTime.Now, "nppiScale_8u32f_AC4R", status));
NPPException.CheckNppStatus(status, this);
}
示例13: Subtract
/// <summary>
/// per element Add
/// </summary>
/// <param name="src"></param>
/// <param name="value"></param>
/// <returns></returns>
public static NppiRect Subtract(NppiSize src, NppiRect value)
{
NppiRect ret = new NppiRect(value.x, value.y, src.width - value.width, src.height - value.height);
return ret;
}
示例14: Scale
/// <summary>
/// image conversion.
/// </summary>
/// <param name="dst">Destination-Image</param>
/// <param name="hint">algorithm performance or accuracy selector, currently ignored</param>
public void Scale(NPPImage_8uC4 dst, NppHintAlgorithm hint)
{
NppiRect srcRect = new NppiRect(_pointRoi, _sizeRoi);
status = NPPNativeMethods.NPPi.Scale.nppiScale_32s8u_C4R(_devPtrRoi, _pitch, dst.DevicePointerRoi, dst.Pitch, _sizeRoi, hint);
Debug.WriteLine(String.Format("{0:G}, {1}: {2}", DateTime.Now, "nppiScale_32s8u_C4R", status));
NPPException.CheckNppStatus(status, this);
}
示例15: Add
/// <summary>
/// per element Add
/// </summary>
/// <param name="src"></param>
/// <param name="value"></param>
/// <returns></returns>
public static NppiRect Add(NppiRect src, int value)
{
NppiRect ret = new NppiRect(src.x + value, src.y + value, src.width + value, src.height + value);
return ret;
}