Esempio n. 1
0
        /// <summary>
        /// Perspective transform of an image.<para/>
        /// This function operates using given transform coefficients that
        /// can be obtained by using nppiGetPerspectiveTransform function or set
        /// explicitly. The function operates on source and destination regions
        /// of interest. The perspective warp function transforms the source image
        /// pixel coordinates (x,y) according to the following formulas:<para/>
        /// X_new = (C_00 * x + C_01 * y + C_02) / (C_20 * x + C_21 * y + C_22)<para/>
        /// Y_new = (C_10 * x + C_11 * y + C_12) / (C_20 * x + C_21 * y + C_22)<para/>
        /// The transformed part of the source image is resampled using the specified
        /// interpolation method and written to the destination ROI.
        /// The functions nppiGetPerspectiveQuad and nppiGetPerspectiveBound can help
        /// with destination ROI specification.<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="dest">Destination image</param>
        /// <param name="coeffs">Perspective transform coefficients [3,3]</param>
        /// <param name="eInterpolation">Interpolation mode: can be <see cref="InterpolationMode.NearestNeighbor"/>, <see cref="InterpolationMode.Linear"/> or <see cref="InterpolationMode.Cubic"/></param>
        public void WarpPerspective(NPPImage_16fC4 dest, double[,] coeffs, InterpolationMode eInterpolation)
        {
            NppiRect rectIn  = new NppiRect(_pointRoi, _sizeRoi);
            NppiRect rectOut = new NppiRect(dest.PointRoi, dest.SizeRoi);

            status = NPPNativeMethods.NPPi.PerspectiveTransforms.nppiWarpPerspective_16f_C4R(_devPtr, _sizeOriginal, _pitch, rectIn, dest.DevicePointer, dest.Pitch, rectOut, coeffs, eInterpolation);
            Debug.WriteLine(String.Format("{0:G}, {1}: {2}", DateTime.Now, "nppiWarpPerspective_16f_C4R", status));
            NPPException.CheckNppStatus(status, this);
        }
Esempio n. 2
0
 /// <summary>
 /// 32-bit float convolution filter with border control.
 /// </summary>
 /// <param name="dest">Destination image</param>
 /// <param name="pKernel">Pointer to the start address of the kernel coefficient array. Coeffcients are expected to be stored in reverse order</param>
 /// <param name="nKernelSize">Width and Height of the rectangular kernel.</param>
 /// <param name="oAnchor">X and Y offsets of the kernel origin frame of reference relative to the source pixel.</param>
 /// <param name="eBorderType">The border type operation to be applied at source image border boundaries.</param>
 /// <param name="filterArea">The area where the filter is allowed to read pixels. The point is relative to the ROI set to source image, the size is the total size starting from the filterArea point. Default value is the set ROI.</param>
 public void FilterBorder(NPPImage_16fC4 dest, CudaDeviceVariable <float> pKernel, NppiSize nKernelSize, NppiPoint oAnchor, NppiBorderType eBorderType, NppiRect filterArea = new NppiRect())
 {
     if (filterArea.Size == new NppiSize())
     {
         filterArea.Size = _sizeRoi;
     }
     status = NPPNativeMethods.NPPi.FilterBorder32f.nppiFilterBorder32f_16f_C4R(_devPtrRoi, _pitch, filterArea.Size, filterArea.Location, dest.DevicePointerRoi, dest.Pitch, dest.SizeRoi, pKernel.DevicePointer, nKernelSize, oAnchor, eBorderType);
     Debug.WriteLine(String.Format("{0:G}, {1}: {2}", DateTime.Now, "nppiFilterBorder32f_16f_C4R", status));
     NPPException.CheckNppStatus(status, this);
 }
Esempio n. 3
0
 /// <summary>
 /// Resizes images.
 /// </summary>
 /// <param name="dest">Destination image</param>
 /// <param name="eInterpolation">Interpolation mode</param>
 public void Resize(NPPImage_16fC4 dest, InterpolationMode eInterpolation)
 {
     status = NPPNativeMethods.NPPi.GeometricTransforms.nppiResize_16f_C4R(_devPtr, _pitch, _sizeOriginal, new NppiRect(_pointRoi, _sizeRoi), dest.DevicePointer, dest.Pitch, dest.Size, new NppiRect(dest.PointRoi, dest.SizeRoi), eInterpolation);
     Debug.WriteLine(String.Format("{0:G}, {1}: {2}", DateTime.Now, "nppiResize_16f_C4R", status));
     NPPException.CheckNppStatus(status, this);
 }
Esempio n. 4
0
 /// <summary>
 /// Image copy.
 /// </summary>
 /// <param name="dst">Destination image</param>
 public void Copy(NPPImage_16fC4 dst)
 {
     status = NPPNativeMethods.NPPi.MemCopy.nppiCopy_16f_C4R(_devPtrRoi, _pitch, dst.DevicePointerRoi, dst.Pitch, _sizeRoi);
     Debug.WriteLine(String.Format("{0:G}, {1}: {2}", DateTime.Now, "nppiCopy_16f_C4R", status));
     NPPException.CheckNppStatus(status, this);
 }
Esempio n. 5
0
 /// <summary>
 /// convolution filter.
 /// </summary>
 /// <param name="dst">Destination-Image</param>
 /// <param name="pKernel">Pointer to the start address of the kernel coefficient array.<para/>
 /// Coefficients are expected to be stored in reverse order.</param>
 /// <param name="oKernelSize">Width and Height of the rectangular kernel.</param>
 /// <param name="oAnchor">X and Y offsets of the kernel origin frame of reference</param>
 public void Filter(NPPImage_16fC4 dst, CudaDeviceVariable <float> pKernel, NppiSize oKernelSize, NppiPoint oAnchor)
 {
     status = NPPNativeMethods.NPPi.Convolution.nppiFilter32f_16f_C4R(_devPtrRoi, _pitch, dst.DevicePointerRoi, dst.Pitch, _sizeRoi, pKernel.DevicePointer, oKernelSize, oAnchor);
     Debug.WriteLine(String.Format("{0:G}, {1}: {2}", DateTime.Now, "nppiFilter32f_16f_C4R", status));
     NPPException.CheckNppStatus(status, this);
 }
Esempio n. 6
0
 /// <summary>
 /// In place image division.
 /// </summary>
 /// <param name="src2">2nd source image</param>
 public void Div(NPPImage_16fC4 src2)
 {
     status = NPPNativeMethods.NPPi.Div.nppiDiv_16f_C4IR(src2.DevicePointerRoi, src2.Pitch, _devPtrRoi, _pitch, _sizeRoi);
     Debug.WriteLine(String.Format("{0:G}, {1}: {2}", DateTime.Now, "nppiDiv_16f_C4IR", status));
     NPPException.CheckNppStatus(status, this);
 }
Esempio n. 7
0
 /// <summary>
 /// Divide constant to image.
 /// </summary>
 /// <param name="nConstant">Value</param>
 /// <param name="dest">Destination image</param>
 public void Div(float[] nConstant, NPPImage_16fC4 dest)
 {
     status = NPPNativeMethods.NPPi.DivConst.nppiDivC_16f_C4R(_devPtrRoi, _pitch, nConstant, dest.DevicePointerRoi, dest.Pitch, _sizeRoi);
     Debug.WriteLine(String.Format("{0:G}, {1}: {2}", DateTime.Now, "nppiDivC_16f_C4R", status));
     NPPException.CheckNppStatus(status, this);
 }
Esempio n. 8
0
 /// <summary>
 /// 4 channel 16-bit floating point color twist with 4x4 matrix and constant vector addition.
 /// An input 4x4 color twist matrix with floating-point coefficient values with an additional constant vector addition
 /// is applied within ROI.  For this particular version of the function the result is generated as shown below.
 ///  \code
 ///      dst[0] = aTwist[0][0]		/// src[0] + aTwist[0][1]		/// src[1] + aTwist[0][2]		/// src[2] + aTwist[0][3]		/// src[3] + aConstants[0]
 ///      dst[1] = aTwist[1][0]		/// src[0] + aTwist[1][1]		/// src[1] + aTwist[1][2]		/// src[2] + aTwist[1][3]		/// src[3] + aConstants[1]
 ///      dst[2] = aTwist[2][0]		/// src[0] + aTwist[2][1]		/// src[1] + aTwist[2][2]		/// src[2] + aTwist[2][3]		/// src[3] + aConstants[2]
 ///      dst[3] = aTwist[3][0]		/// src[0] + aTwist[3][1]		/// src[1] + aTwist[3][2]		/// src[2] + aTwist[3][3]		/// src[3] + aConstants[3]
 ///  \endcode
 /// </summary>
 /// <param name="dest">Destination image</param>
 /// <param name="twistMatrix">The color twist matrix with floating-point coefficient values [4,4].</param>
 /// <param name="aConstants">fixed size array of constant values, one per channel [4]</param>
 public void ColorTwistC(NPPImage_16fC4 dest, float[,] twistMatrix, float[] aConstants)
 {
     status = NPPNativeMethods.NPPi.ColorTwist.nppiColorTwist32fC_16f_C4R(_devPtrRoi, _pitch, dest.DevicePointerRoi, dest.Pitch, _sizeRoi, twistMatrix, aConstants);
     Debug.WriteLine(String.Format("{0:G}, {1}: {2}", DateTime.Now, "nppiColorTwist32fC_16f_C4R", status));
     NPPException.CheckNppStatus(status, this);
 }
 /// <summary>
 /// Image absolute value.
 /// </summary>
 /// <param name="dest">Destination image</param>
 /// <param name="nppStreamCtx">NPP stream context.</param>
 public void Abs(NPPImage_16fC4 dest, NppStreamContext nppStreamCtx)
 {
     status = NPPNativeMethods_Ctx.NPPi.Abs.nppiAbs_16f_C4R_Ctx(_devPtrRoi, _pitch, dest.DevicePointerRoi, dest.Pitch, _sizeRoi, nppStreamCtx);
     Debug.WriteLine(String.Format("{0:G}, {1}: {2}", DateTime.Now, "nppiAbs_16f_C4R_Ctx", status));
     NPPException.CheckNppStatus(status, this);
 }
Esempio n. 10
0
 /// <summary>
 /// In place image multiplication.
 /// </summary>
 /// <param name="src2">2nd source image</param>
 /// <param name="nppStreamCtx">NPP stream context.</param>
 public void Mul(NPPImage_16fC4 src2, NppStreamContext nppStreamCtx)
 {
     status = NPPNativeMethods_Ctx.NPPi.Mul.nppiMul_16f_C4IR_Ctx(src2.DevicePointerRoi, src2.Pitch, _devPtrRoi, _pitch, _sizeRoi, nppStreamCtx);
     Debug.WriteLine(String.Format("{0:G}, {1}: {2}", DateTime.Now, "nppiMul_16f_C4IR_Ctx", status));
     NPPException.CheckNppStatus(status, this);
 }
Esempio n. 11
0
 /// <summary>
 /// 32-bit float convolution filter with border control.
 /// </summary>
 /// <param name="dest">Destination image</param>
 /// <param name="pKernel">Pointer to the start address of the kernel coefficient array. Coeffcients are expected to be stored in reverse order</param>
 /// <param name="nKernelSize">Width and Height of the rectangular kernel.</param>
 /// <param name="oAnchor">X and Y offsets of the kernel origin frame of reference relative to the source pixel.</param>
 /// <param name="eBorderType">The border type operation to be applied at source image border boundaries.</param>
 /// <param name="nppStreamCtx">NPP stream context.</param>
 public void FilterBorder(NPPImage_16fC4 dest, CudaDeviceVariable <float> pKernel, NppiSize nKernelSize, NppiPoint oAnchor, NppiBorderType eBorderType, NppStreamContext nppStreamCtx)
 {
     status = NPPNativeMethods_Ctx.NPPi.FilterBorder32f.nppiFilterBorder32f_16f_C4R_Ctx(_devPtr, _pitch, _sizeOriginal, _pointRoi, dest.DevicePointerRoi, dest.Pitch, dest.SizeRoi, pKernel.DevicePointer, nKernelSize, oAnchor, eBorderType, nppStreamCtx);
     Debug.WriteLine(String.Format("{0:G}, {1}: {2}", DateTime.Now, "nppiFilterBorder32f_16f_C4R_Ctx", status));
     NPPException.CheckNppStatus(status, this);
 }
Esempio n. 12
0
 /// <summary>
 /// An input color twist matrix with floating-point pixel values is applied
 /// within ROI.
 /// </summary>
 /// <param name="dest">Destination image</param>
 /// <param name="twistMatrix">The color twist matrix with floating-point pixel values [3,4].</param>
 /// <param name="nppStreamCtx">NPP stream context.</param>
 public void ColorTwist(NPPImage_16fC4 dest, float[,] twistMatrix, NppStreamContext nppStreamCtx)
 {
     status = NPPNativeMethods_Ctx.NPPi.ColorTwist.nppiColorTwist32f_16f_C4R_Ctx(_devPtr, _pitch, dest.DevicePointer, dest.Pitch, _sizeRoi, twistMatrix, nppStreamCtx);
     Debug.WriteLine(String.Format("{0:G}, {1}: {2}", DateTime.Now, "nppiColorTwist32f_16f_C4R_Ctx", status));
     NPPException.CheckNppStatus(status, this);
 }