Example #1
0
 /// <summary>
 /// Forward DCT, quantization and level shift part of the JPEG encoding.
 /// Input is expected in 8x8 macro blocks and output is expected to be in 64x1
 /// macro blocks.
 /// </summary>
 /// <param name="src">Source image.</param>
 /// <param name="dst">Destination image</param>
 /// <param name="QuantFwdTable">Forward quantization tables for JPEG encoding created using QuantInvTableInit()</param>
 /// <param name="oSizeRoi">Roi size (in macro blocks?).</param>
 public static void DCTQuantFwd8x8LS(NPPImage_8uC1 src, NPPImage_16sC1 dst, CudaDeviceVariable<ushort> QuantFwdTable, NppiSize oSizeRoi)
 {
     NppStatus status;
     status = NPPNativeMethods.NPPi.ImageCompression.nppiDCTQuantFwd8x8LS_JPEG_8u16s_C1R(src.DevicePointer, src.Pitch, dst.DevicePointer, dst.Pitch, QuantFwdTable.DevicePointer, oSizeRoi);
     Debug.WriteLine(String.Format("{0:G}, {1}: {2}", DateTime.Now, "nppiDCTQuantFwd8x8LS_JPEG_8u16s_C1R", status));
     NPPException.CheckNppStatus(status, null);
 }
Example #2
0
 /// <summary>
 /// 3 channel 8-bit unsigned packed RGB to 1 channel 8-bit unsigned packed Gray Gradient conversion.
 /// </summary>
 /// <param name="dest">Destination image</param>
 /// <param name="eNorm">Gradient distance method to use.</param>
 public void GradientColorToGray(NPPImage_8uC1 dest, NppiNorm eNorm)
 {
     NppStatus status = NPPNativeMethods.NPPi.GradientColorToGray.nppiGradientColorToGray_8u_C3C1R(DevicePointerRoi, Pitch, dest.DevicePointerRoi, dest.Pitch, SizeRoi, eNorm);
     Debug.WriteLine(String.Format("{0:G}, {1}: {2}", DateTime.Now, "nppiGradientColorToGray_8u_C3C1R", status));
     NPPException.CheckNppStatus(status, null);
 }
Example #3
0
		/// <summary>
		/// Masked Operation 8-bit unsigned image copy. Not affecting Alpha channel.
		/// </summary>
		/// <param name="dst">Destination image</param>
		/// <param name="mask">Mask image</param>
		public void CopyA(NPPImage_32sC4 dst, NPPImage_8uC1 mask)
		{
			status = NPPNativeMethods.NPPi.MemCopy.nppiCopy_32s_AC4MR(_devPtrRoi, _pitch, dst.DevicePointerRoi, dst.Pitch, _sizeRoi, mask.DevicePointerRoi, mask.Pitch);
			Debug.WriteLine(String.Format("{0:G}, {1}: {2}", DateTime.Now, "nppiCopy_32s_AC4MR", status));
			NPPException.CheckNppStatus(status, this);
		}
Example #4
0
		/// <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);
		}
Example #5
0
		/// <summary>
		/// resizes planar images.
		/// </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="xFactor">X scaling factor</param>
		/// <param name="yFactor">Y scaling factor</param>
		/// <param name="eInterpolation">Interpolation mode</param>
		public static void Resize(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 xFactor, double yFactor, 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 };
			NppStatus status = NPPNativeMethods.NPPi.GeometricTransforms.nppiResize_8u_P4R(src, src0.Size, src0.Pitch, new NppiRect(src0.PointRoi, src0.SizeRoi), dst, dest0.Pitch, dest0.SizeRoi, xFactor, yFactor, eInterpolation);
			Debug.WriteLine(String.Format("{0:G}, {1}: {2}", DateTime.Now, "nppiResize_8u_P4R", status));
			NPPException.CheckNppStatus(status, null);
		}
Example #6
0
		/// <summary>
		/// 4 channel 8-bit unsigned packed RGB with alpha to 3 channel 8-bit unsigned planar YCrCb420 color conversion.
		/// </summary>
		/// <param name="dest0">Destination image channel 0</param>
		/// <param name="dest1">Destination image channel 1</param>
		/// <param name="dest2">Destination image channel 2</param>
		public void RGBToYCrCb420(NPPImage_8uC1 dest0, NPPImage_8uC1 dest1, NPPImage_8uC1 dest2)
		{
			CUdeviceptr[] arrayDest = new CUdeviceptr[] { dest0.DevicePointerRoi, dest1.DevicePointerRoi, dest2.DevicePointerRoi };
			int[] arrayPitch = new int[] { dest0.Pitch, dest1.Pitch, dest2.Pitch };
			NppStatus status = NPPNativeMethods.NPPi.RGBToYCrCb.nppiRGBToYCrCb420_8u_AC4P3R(_devPtrRoi, _pitch, arrayDest, arrayPitch, _sizeRoi);
			Debug.WriteLine(String.Format("{0:G}, {1}: {2}", DateTime.Now, "nppiRGBToYCrCb420_8u_AC4P3R", status));
			NPPException.CheckNppStatus(status, null);
		}
Example #7
0
		/// <summary>
		/// 4 channel 8-bit unsigned planar BGR with alpha to 4 channel 8-bit unsigned planar HLS with alpha color conversion.
		/// </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 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="dest3">Destination image channel 3</param>
		public static void BGRToHLS(NPPImage_8uC1 src0, NPPImage_8uC1 src1, NPPImage_8uC1 src2, NPPImage_8uC1 src3, NPPImage_8uC1 dest0, NPPImage_8uC1 dest1, NPPImage_8uC1 dest2, NPPImage_8uC1 dest3)
		{
			CUdeviceptr[] arraySrc = new CUdeviceptr[] { src0.DevicePointerRoi, src1.DevicePointerRoi, src2.DevicePointerRoi, src3.DevicePointerRoi };
			CUdeviceptr[] arrayDest = new CUdeviceptr[] { dest0.DevicePointerRoi, dest1.DevicePointerRoi, dest2.DevicePointerRoi, dest3.DevicePointerRoi };
			NppStatus status = NPPNativeMethods.NPPi.BGRToHLS.nppiBGRToHLS_8u_AP4R(arraySrc, src0.Pitch, arrayDest, dest0.Pitch, src0.SizeRoi);
			Debug.WriteLine(String.Format("{0:G}, {1}: {2}", DateTime.Now, "nppiBGRToHLS_8u_AP4R", status));
			NPPException.CheckNppStatus(status, null);
		}
Example #8
0
		/// <summary>
		/// Three-channel 8-bit unsigned packed to planar image copy.
		/// </summary>
		/// <param name="dst0">Destination image channel 0</param>
		/// <param name="dst1">Destination image channel 1</param>
		/// <param name="dst2">Destination image channel 2</param>
		/// <param name="dst3">Destination image channel 3</param>
		public void Copy(NPPImage_8uC1 dst0, NPPImage_8uC1 dst1, NPPImage_8uC1 dst2, NPPImage_8uC1 dst3)
		{
			CUdeviceptr[] array = new CUdeviceptr[] { dst0.DevicePointerRoi, dst1.DevicePointerRoi, dst2.DevicePointerRoi, dst3.DevicePointerRoi };
			status = NPPNativeMethods.NPPi.MemCopy.nppiCopy_8u_C4P4R(_devPtrRoi, _pitch, array, dst0.Pitch, _sizeRoi);
			Debug.WriteLine(String.Format("{0:G}, {1}: {2}", DateTime.Now, "nppiCopy_8u_C4P4R", status));
			NPPException.CheckNppStatus(status, this);
		}
Example #9
0
 /// <summary>
 /// 3 channel 8-bit unsigned planar YCbCr411 to 4 channel 8-bit unsigned packed RGB color conversion with constant alpha.
 /// </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="dest">Destination image</param>
 /// <param name="nAval">8-bit unsigned alpha constant.</param>
 public static void YCbCr411ToRGB(NPPImage_8uC1 src0, NPPImage_8uC1 src1, NPPImage_8uC1 src2, NPPImage_8uC4 dest, byte nAval)
 {
     CUdeviceptr[] arraySrc = new CUdeviceptr[] { src0.DevicePointerRoi, src1.DevicePointerRoi, src2.DevicePointerRoi };
     int[] arrayPitch = new int[] { src0.Pitch, src1.Pitch, src2.Pitch };
     NppStatus status = NPPNativeMethods.NPPi.YCbCrToRGB.nppiYCbCr411ToRGB_8u_P3C4R(arraySrc, arrayPitch, dest.DevicePointerRoi, dest.Pitch, dest.SizeRoi, nAval);
     Debug.WriteLine(String.Format("{0:G}, {1}: {2}", DateTime.Now, "nppiYCbCr411ToRGB_8u_P3C4R", status));
     NPPException.CheckNppStatus(status, null);
 }
Example #10
0
		/// <summary>
		/// 32-bit unsigned to 8-bit unsigned conversion.
		/// </summary>
		/// <param name="dst">Destination image</param>
		/// <param name="roundMode">Round mode</param>
		/// <param name="scaleFactor">scaling factor</param>
		public void Convert(NPPImage_8uC1 dst, NppRoundMode roundMode, int scaleFactor)
		{
			status = NPPNativeMethods.NPPi.BitDepthConversion.nppiConvert_32u8u_C1RSfs(_devPtrRoi, _pitch, dst.DevicePointerRoi, dst.Pitch, _sizeRoi, roundMode, scaleFactor);
			Debug.WriteLine(String.Format("{0:G}, {1}: {2}", DateTime.Now, "nppiConvert_32u8u_C1RSfs", status));
			NPPException.CheckNppStatus(status, this);
		}
Example #11
0
 /// <summary>
 /// 3 channel 8-bit unsigned planar YCbCr411 to 3 channel 8-bit unsigned planar YCbCr422 sampling format conversion.
 /// </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="dest0">Destination image channel 0</param>  
 /// <param name="dest1">Destination image channel 1</param>  
 /// <param name="dest2">Destination image channel 2</param>   
 public static void YCbCr411ToYCbCr422(NPPImage_8uC1 src0, NPPImage_8uC1 src1, NPPImage_8uC1 src2, NPPImage_8uC1 dest0, NPPImage_8uC1 dest1, NPPImage_8uC1 dest2)
 {
     CUdeviceptr[] arraySrc = new CUdeviceptr[] { src0.DevicePointerRoi, src1.DevicePointerRoi, src2.DevicePointerRoi };
     int[] arrayPitchSrc = new int[] { src0.Pitch, src1.Pitch, src2.Pitch };
     CUdeviceptr[] arrayDest = new CUdeviceptr[] { dest0.DevicePointerRoi, dest1.DevicePointerRoi, dest2.DevicePointerRoi };
     int[] arrayPitchDest = new int[] { dest0.Pitch, dest1.Pitch, dest2.Pitch };
     NppStatus status = NPPNativeMethods.NPPi.YCbCrAndACrCbAndOther.nppiYCbCr411ToYCbCr422_8u_P3R(arraySrc, arrayPitchSrc, arrayDest, arrayPitchDest, src0.SizeRoi);
     Debug.WriteLine(String.Format("{0:G}, {1}: {2}", DateTime.Now, "nppiYCbCr411ToYCbCr422_8u_P3R", status));
     NPPException.CheckNppStatus(status, null);
 }
Example #12
0
 /// <summary>
 /// 3 channel 8-bit unsigned packed RGB to planar YCbCr420 color conversion.
 /// </summary>
 /// <param name="dst0">Destination image channel 0</param>
 /// <param name="dst1">Destination image channel 1</param>
 /// <param name="dst2">Destination image channel 2</param>
 public void RGBToYCbCr420(NPPImage_8uC1 dst0, NPPImage_8uC1 dst1, NPPImage_8uC1 dst2)
 {
     CUdeviceptr[] array = new CUdeviceptr[] { dst0.DevicePointerRoi, dst1.DevicePointerRoi, dst2.DevicePointerRoi };
     int[] arrayStep = new int[] { dst0.Pitch, dst1.Pitch, dst2.Pitch };
     status = NPPNativeMethods.NPPi.RGBToYCbCr.nppiRGBToYCbCr420_8u_C3P3R(_devPtrRoi, _pitch, array, arrayStep, _sizeRoi);
     Debug.WriteLine(String.Format("{0:G}, {1}: {2}", DateTime.Now, "nppiRGBToYCbCr420_8u_C3P3R", status));
     NPPException.CheckNppStatus(status, this);
 }
Example #13
0
 /// <summary>
 /// 3 channel 8-bit unsigned planar RGB to 3 channel 8-bit unsigned planar YUV420 color conversion.
 /// </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="dest0">Destination image channel 0</param>  
 /// <param name="dest1">Destination image channel 1</param>  
 /// <param name="dest2">Destination image channel 2</param>     
 public static void RGBToYUV420(NPPImage_8uC1 src0, NPPImage_8uC1 src1, NPPImage_8uC1 src2, NPPImage_8uC1 dest0, NPPImage_8uC1 dest1, NPPImage_8uC1 dest2)
 {
     CUdeviceptr[] arraySrc = new CUdeviceptr[] { src0.DevicePointerRoi, src1.DevicePointerRoi, src2.DevicePointerRoi };
     CUdeviceptr[] arrayDest = new CUdeviceptr[] { dest0.DevicePointerRoi, dest1.DevicePointerRoi, dest2.DevicePointerRoi };
     int[] arrayDestPitch = new int[] { dest0.Pitch, dest1.Pitch, dest2.Pitch };
     NppStatus status = NPPNativeMethods.NPPi.RGBToYUV420.nppiRGBToYUV420_8u_P3R(arraySrc, src0.Pitch, arrayDest, arrayDestPitch, src0.SizeRoi);
     Debug.WriteLine(String.Format("{0:G}, {1}: {2}", DateTime.Now, "nppiRGBToYUV420_8u_P3R", status));
     NPPException.CheckNppStatus(status, null);
 }
Example #14
0
        /// <summary>
        /// Image pixel minimum and maximum values with their indices. Buffer is internally allocated and freed.
        /// </summary>
        /// <param name="coi">Channel of interest (0, 1 or 2)</param>
        /// <param name="min">Allocated device memory with size of at least 1 * sizeof(byte)</param>
        /// <param name="max">Allocated device memory with size of at least 1 * sizeof(byte)</param>
        /// <param name="minIndex">Allocated device memory with size of at least 1 * sizeof(NppiPoint)</param>
        /// <param name="maxIndex">Allocated device memory with size of at least 1 * sizeof(NppiPoint)</param>
        /// <param name="mask">If the mask is filled with zeros, then all the returned values are zeros, i.e., pMinIndex = {0, 0}, pMaxIndex = {0, 0}, pMinValue = 0, pMaxValue = 0.</param>
        public void MinMaxIndex(int coi, CudaDeviceVariable<byte> min, CudaDeviceVariable<byte> max, CudaDeviceVariable<NppiPoint> minIndex, CudaDeviceVariable<NppiPoint> maxIndex, NPPImage_8uC1 mask)
        {
            int bufferSize = MinMaxIndexGetBufferHostSize();
            CudaDeviceVariable<byte> buffer = new CudaDeviceVariable<byte>(bufferSize);

            status = NPPNativeMethods.NPPi.MinMaxIndxNew.nppiMinMaxIndx_8u_C3CMR(_devPtrRoi, _pitch, mask.DevicePointerRoi, mask.Pitch, _sizeRoi, coi, min.DevicePointer, max.DevicePointer, minIndex.DevicePointer, maxIndex.DevicePointer, buffer.DevicePointer);
            Debug.WriteLine(String.Format("{0:G}, {1}: {2}", DateTime.Now, "nppiMinMaxIndx_8u_C3CMR", status));
            buffer.Dispose();
            NPPException.CheckNppStatus(status, this);
        }
Example #15
0
 /// <summary>
 /// 3 channel 8-bit unsigned planar RGB to 2 channel 8-bit unsigned packed YCrCb422 color conversion.
 /// </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="dest">Destination image</param>
 public static void RGBToYCrCb422(NPPImage_8uC1 src0, NPPImage_8uC1 src1, NPPImage_8uC1 src2, NPPImage_8uC2 dest)
 {
     CUdeviceptr[] arraySrc = new CUdeviceptr[] { src0.DevicePointerRoi, src1.DevicePointerRoi, src2.DevicePointerRoi };
     NppStatus status = NPPNativeMethods.NPPi.RGBToYCrCb.nppiRGBToYCrCb422_8u_P3C2R(arraySrc, src0.Pitch, dest.DevicePointerRoi, dest.Pitch, src0.SizeRoi);
     Debug.WriteLine(String.Format("{0:G}, {1}: {2}", DateTime.Now, "nppiRGBToYCrCb422_8u_P3C2R", status));
     NPPException.CheckNppStatus(status, null);
 }
Example #16
0
		/// <summary>
		/// Image copy.
		/// </summary>
		/// <param name="dst">Destination image</param>
		/// <param name="channel">Channel number. This number is added to the dst pointer</param>
		public void Copy(NPPImage_8uC1 dst, int channel)
		{
			if (channel < 0 | channel >= _channels) throw new ArgumentOutOfRangeException("channel", "channel must be in range [0..3].");
			status = NPPNativeMethods.NPPi.MemCopy.nppiCopy_8u_C4C1R(_devPtrRoi + channel * _typeSize, _pitch, dst.DevicePointerRoi, dst.Pitch, _sizeRoi);
			Debug.WriteLine(String.Format("{0:G}, {1}: {2}", DateTime.Now, "nppiCopy_8u_C4C1R", status));
			NPPException.CheckNppStatus(status, this);
		}
Example #17
0
		/// <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_8uC1 src0, NPPImage_8uC1 src1, NPPImage_8uC1 src2, double[,] srcQuad, NPPImage_8uC1 dest0, NPPImage_8uC1 dest1, NPPImage_8uC1 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_8u_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_8u_P4R", status));
			NPPException.CheckNppStatus(status, null);
		}
Example #18
0
		/// <summary>
		/// Graphcut of a flow network (32bit floating point edge capacities). The
		/// function computes the minimal cut (graphcut) of a 2D regular 8-connected
		/// graph. <para/>
		/// The inputs are the capacities of the horizontal (in transposed form),
		/// vertical and terminal (source and sink) edges. The capacities to source and
		/// sink 
		/// are stored as capacity differences in the terminals array 
		/// ( terminals(x) = source(x) - sink(x) ). The implementation assumes that the
		/// edge capacities 
		/// for boundary edges that would connect to nodes outside the specified domain
		/// are set to 0 (for example left(0,*) == 0). If this is not fulfilled the
		/// computed labeling may be wrong!<para/>
		/// The computed binary labeling is encoded as unsigned 8bit values (0 and >0).
		/// </summary>
		/// <param name="Terminals">Pointer to differences of terminal edge capacities</param>
		/// <param name="LeftTransposed">Pointer to transposed left edge capacities</param>
		/// <param name="RightTransposed">Pointer to transposed right edge capacities</param>
		/// <param name="Top">Pointer to top edge capacities (top(*,0) must be 0)</param>
		/// <param name="TopLeft">Pointer to top left edge capacities (topleft(*,0) </param>
		/// <param name="TopRight">Pointer to top right edge capacities (topright(*,0)</param>
		/// <param name="Bottom">Pointer to bottom edge capacities (bottom(*,height-1)</param>
		/// <param name="BottomLeft">Pointer to bottom left edge capacities </param>
		/// <param name="BottomRight">Pointer to bottom right edge capacities </param>
		/// <param name="Label">Pointer to destination label image </param>
		/// <returns></returns>
		public void GraphCut(NPPImage_32fC1 Terminals, NPPImage_32fC1 LeftTransposed, NPPImage_32fC1 RightTransposed,
			NPPImage_32fC1 Top, NPPImage_32fC1 TopLeft, NPPImage_32fC1 TopRight, NPPImage_32fC1 Bottom, NPPImage_32fC1 BottomLeft,
			NPPImage_32fC1 BottomRight, NPPImage_8uC1 Label)
		{
			status = NPPNativeMethods.NPPi.ImageLabeling.nppiGraphcut8_32f8u(Terminals.DevicePointer, LeftTransposed.DevicePointer, 
				RightTransposed.DevicePointer, Top.DevicePointer, TopLeft.DevicePointer, TopRight.DevicePointer, Bottom.DevicePointer, 
				BottomLeft.DevicePointer, BottomRight.DevicePointer, Terminals.Pitch, LeftTransposed.Pitch, _size, Label.DevicePointer, 
				Label.Pitch, _state);
			Debug.WriteLine(String.Format("{0:G}, {1}: {2}", DateTime.Now, "nppiGraphcut8_32f8u", status));
			NPPException.CheckNppStatus(status, this);
		}
Example #19
0
		/// <summary>
		/// Compare pSrc's pixels with constant value. Not affecting Alpha.
		/// </summary>
		/// <param name="constants">list of constants, one per color channel.</param>
		/// <param name="dest">Destination image</param>
		/// <param name="eComparisonOperation">Specifies the comparison operation to be used in the pixel comparison.</param>
		public void CompareA(byte[] constants, NPPImage_8uC1 dest, NppCmpOp eComparisonOperation)
		{
			status = NPPNativeMethods.NPPi.Compare.nppiCompareC_8u_AC4R(_devPtrRoi, _pitch, constants, dest.DevicePointerRoi, dest.Pitch, _sizeRoi, eComparisonOperation);
			Debug.WriteLine(String.Format("{0:G}, {1}: {2}", DateTime.Now, "nppiCompareC_8u_AC4R", status));
			NPPException.CheckNppStatus(status, this);
		}
Example #20
0
		/// <summary>
		/// Image pixel minimum and maximum values with their indices. No additional buffer is allocated.
		/// </summary>
		/// <param name="coi">Channel of interest (0, 1 or 2)</param>
		/// <param name="min">Allocated device memory with size of at least 1 * sizeof(ushort)</param>
		/// <param name="max">Allocated device memory with size of at least 1 * sizeof(ushort)</param>
		/// <param name="minIndex">Allocated device memory with size of at least 1 * sizeof(NppiPoint)</param>
		/// <param name="maxIndex">Allocated device memory with size of at least 1 * sizeof(NppiPoint)</param>
		/// <param name="buffer">Allocated device memory with size of at <see cref="MinMaxIndexMaskedGetBufferHostSize()"/></param>
		/// <param name="mask">If the mask is filled with zeros, then all the returned values are zeros, i.e., pMinIndex = {0, 0}, pMaxIndex = {0, 0}, pMinValue = 0, pMaxValue = 0.</param>
		public void MinMaxIndex(int coi, CudaDeviceVariable<ushort> min, CudaDeviceVariable<ushort> max, CudaDeviceVariable<NppiPoint> minIndex, CudaDeviceVariable<NppiPoint> maxIndex, NPPImage_8uC1 mask, CudaDeviceVariable<byte> buffer)
		{
			int bufferSize = MinMaxIndexMaskedGetBufferHostSize();
			if (bufferSize > buffer.Size) throw new NPPException("Provided buffer is too small.");

			status = NPPNativeMethods.NPPi.MinMaxIndxNew.nppiMinMaxIndx_16u_C3CMR(_devPtrRoi, _pitch, mask.DevicePointerRoi, mask.Pitch, _sizeRoi, coi, min.DevicePointer, max.DevicePointer, minIndex.DevicePointer, maxIndex.DevicePointer, buffer.DevicePointer);
			Debug.WriteLine(String.Format("{0:G}, {1}: {2}", DateTime.Now, "nppiMinMaxIndx_16u_C3CMR", status));
			NPPException.CheckNppStatus(status, this);
		}
Example #21
0
		/// <summary>
		/// 4 channel 8-bit unsigned planar HLS with alpha to 4 channel 8-bit unsigned packed BGR with alpha color conversion.
		/// </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 2</param>
		/// <param name="dest">Destination image</param>
		public static void HLSToBGR(NPPImage_8uC1 src0, NPPImage_8uC1 src1, NPPImage_8uC1 src2, NPPImage_8uC1 src3, NPPImage_8uC4 dest)
		{
			CUdeviceptr[] array = new CUdeviceptr[] { src0.DevicePointerRoi, src1.DevicePointerRoi, src2.DevicePointerRoi, src3.DevicePointerRoi };
			NppStatus status = NPPNativeMethods.NPPi.HLSToBGR.nppiHLSToBGR_8u_AP4C4R(array, src0.Pitch, dest.DevicePointerRoi, dest.Pitch, src0.SizeRoi);
			Debug.WriteLine(String.Format("{0:G}, {1}: {2}", DateTime.Now, "nppiHLSToBGR_8u_AP4C4R", status));
			NPPException.CheckNppStatus(status, null);
		}
Example #22
0
		/// <summary>
		/// image mean and standard deviation. Buffer is internally allocated and freed.
		/// </summary>
		/// <param name="coi">Channel of interest (0, 1 or 2)</param>
		/// <param name="mean">Allocated device memory with size of at least 1 * sizeof(double)</param>
		/// <param name="stdDev">Allocated device memory with size of at least 1 * sizeof(double)</param>
		/// <param name="mask">mask</param>
		public void MeanStdDev(int coi, CudaDeviceVariable<double> mean, CudaDeviceVariable<double> stdDev, NPPImage_8uC1 mask)
		{
			int bufferSize = MeanStdDevMaskedGetBufferHostSize();
			CudaDeviceVariable<byte> buffer = new CudaDeviceVariable<byte>(bufferSize);

			status = NPPNativeMethods.NPPi.MeanStdDevNew.nppiMean_StdDev_16u_C3CMR(_devPtrRoi, _pitch, mask.DevicePointerRoi, mask.Pitch, _sizeRoi, coi, buffer.DevicePointer, mean.DevicePointer, stdDev.DevicePointer);
			Debug.WriteLine(String.Format("{0:G}, {1}: {2}", DateTime.Now, "nppiMean_StdDev_16u_C3CMR", status));
			buffer.Dispose();
			NPPException.CheckNppStatus(status, this);
		}
Example #23
0
		/// <summary>
		/// Color to Gray conversion.
		/// </summary>
		/// <param name="dest">Destination image</param>
		/// <param name="aCoeffs">fixed size array of constant floating point conversion coefficient values, one per color channel.</param>
		public void ColorToGray(NPPImage_8uC1 dest, float[] aCoeffs)
		{
			status = NPPNativeMethods.NPPi.ColorToGray.nppiColorToGray_8u_C4C1R(_devPtrRoi, _pitch, dest.DevicePointerRoi, dest.Pitch, _sizeRoi, aCoeffs);
			Debug.WriteLine(String.Format("{0:G}, {1}: {2}", DateTime.Now, "nppiColorToGray_8u_C4C1R", status));
			NPPException.CheckNppStatus(status, this);
		}
Example #24
0
		/// <summary>
		/// image L1 norm. Buffer is internally allocated and freed.
		/// </summary>
		/// <param name="coi">Channel of interest (0, 1 or 2)</param>
		/// <param name="norm">Allocated device memory with size of at least 1 * sizeof(double)</param>
		/// <param name="mask">mask</param>
		public void NormL1(int coi, CudaDeviceVariable<double> norm, NPPImage_8uC1 mask)
		{
			int bufferSize = NormL1MaskedGetBufferHostSize();
			CudaDeviceVariable<byte> buffer = new CudaDeviceVariable<byte>(bufferSize);

			status = NPPNativeMethods.NPPi.NormL1.nppiNorm_L1_16u_C3CMR(_devPtrRoi, _pitch, mask.DevicePointerRoi, mask.Pitch, _sizeRoi, coi, norm.DevicePointer, buffer.DevicePointer);
			Debug.WriteLine(String.Format("{0:G}, {1}: {2}", DateTime.Now, "nppiNorm_L1_16u_C3CMR", status));
			buffer.Dispose();
			NPPException.CheckNppStatus(status, this);
		}
Example #25
0
		/// <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);
		}
Example #26
0
		/// <summary>
		/// image L2 norm. No additional buffer is allocated.
		/// </summary>
		/// <param name="coi">Channel of interest (0, 1 or 2)</param>
		/// <param name="norm">Allocated device memory with size of at least 1 * sizeof(double)</param>
		/// <param name="mask">mask</param>
		/// <param name="buffer">Allocated device memory with size of at <see cref="NormL2MaskedGetBufferHostSize()"/></param>
		public void NormL2(int coi, CudaDeviceVariable<double> norm, NPPImage_8uC1 mask, CudaDeviceVariable<byte> buffer)
		{
			int bufferSize = NormL2MaskedGetBufferHostSize();
			if (bufferSize > buffer.Size) throw new NPPException("Provided buffer is too small.");

			status = NPPNativeMethods.NPPi.NormL2.nppiNorm_L2_16u_C3CMR(_devPtrRoi, _pitch, mask.DevicePointerRoi, mask.Pitch, _sizeRoi, coi, norm.DevicePointer, buffer.DevicePointer);
			Debug.WriteLine(String.Format("{0:G}, {1}: {2}", DateTime.Now, "nppiNorm_L2_16u_C3CMR", status));
			NPPException.CheckNppStatus(status, this);
		}
Example #27
0
		/// <summary>
		/// 4 channel 8-bit unsigned packed BGR with alpha to 4 channel 8-bit unsigned planar YCbCr color conversion.
		/// </summary>
		/// <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>
		public void BGRToYCbCr(NPPImage_8uC1 dest0, NPPImage_8uC1 dest1, NPPImage_8uC1 dest2, NPPImage_8uC1 dest3)
		{
			CUdeviceptr[] arrayDest = new CUdeviceptr[] { dest0.DevicePointerRoi, dest1.DevicePointerRoi, dest2.DevicePointerRoi, dest3.DevicePointerRoi };
			NppStatus status = NPPNativeMethods.NPPi.BGRToYCbCr.nppiBGRToYCbCr_8u_AC4P4R(_devPtrRoi, _pitch, arrayDest, dest0.Pitch, _sizeRoi);
			Debug.WriteLine(String.Format("{0:G}, {1}: {2}", DateTime.Now, "nppiBGRToYCbCr_8u_AC4P4R", status));
			NPPException.CheckNppStatus(status, null);
		}
Example #28
0
		/// <summary>
		/// image NormRel_L1.
		/// </summary>
		/// <param name="tpl">template image.</param>
		/// <param name="pNormRel">Pointer to the computed relative error for the infinity norm of two images. (1 * sizeof(double))</param>
		/// <param name="nCOI">channel of interest.</param>
		/// <param name="pMask">Mask image.</param>
		/// <param name="buffer">Allocated device memory with size of at <see cref="NormRelL1MaskedGetBufferHostSize()"/></param>
		public void NormRel_L1(NPPImage_16uC3 tpl, CudaDeviceVariable<double> pNormRel, int nCOI, NPPImage_8uC1 pMask, CudaDeviceVariable<byte> buffer)
		{
			int bufferSize = NormRelL1MaskedGetBufferHostSize();
			if (bufferSize > buffer.Size) throw new NPPException("Provided buffer is too small.");

			status = NPPNativeMethods.NPPi.NormRel.nppiNormRel_L1_16u_C3CMR(_devPtrRoi, _pitch, tpl.DevicePointerRoi, tpl.Pitch, pMask.DevicePointerRoi, pMask.Pitch, _sizeRoi, nCOI, pNormRel.DevicePointer, buffer.DevicePointer);
			Debug.WriteLine(String.Format("{0:G}, {1}: {2}", DateTime.Now, "nppiNormRel_L1_16u_C3CMR", status));
			NPPException.CheckNppStatus(status, this);
		}
Example #29
0
		/// <summary>
		/// Set pixel values to nValue. <para/>
		/// The 8-bit mask image affects setting of the respective pixels in the destination image. <para/>
		/// If the mask value is zero (0) the pixel is not set, if the mask is non-zero, the corresponding
		/// destination pixel is set to specified value. Not affecting alpha channel.
		/// </summary>
		/// <param name="nValue">Value to be set (Array size = 3)</param>
		/// <param name="mask">Mask image</param>
		public void SetA(int[] nValue, NPPImage_8uC1 mask)
		{
			status = NPPNativeMethods.NPPi.MemSet.nppiSet_32s_AC4MR(nValue, _devPtrRoi, _pitch, _sizeRoi, mask.DevicePointerRoi, mask.Pitch);
			Debug.WriteLine(String.Format("{0:G}, {1}: {2}", DateTime.Now, "nppiSet_32s_AC4MR", status));
			NPPException.CheckNppStatus(status, this);
		}
Example #30
0
		/// <summary>
		/// image NormRel_L2. Buffer is internally allocated and freed.
		/// </summary>
		/// <param name="tpl">template image.</param>
		/// <param name="pNormRel">Pointer to the computed relative error for the infinity norm of two images. (1 * sizeof(double))</param>
		/// <param name="nCOI">channel of interest.</param>
		/// <param name="pMask">Mask image.</param>
		public void NormRel_L2(NPPImage_16uC3 tpl, CudaDeviceVariable<double> pNormRel, int nCOI, NPPImage_8uC1 pMask)
		{
			int bufferSize = NormRelL2MaskedGetBufferHostSize();
			CudaDeviceVariable<byte> buffer = new CudaDeviceVariable<byte>(bufferSize);

			status = NPPNativeMethods.NPPi.NormRel.nppiNormRel_L2_16u_C3CMR(_devPtrRoi, _pitch, tpl.DevicePointerRoi, tpl.Pitch, pMask.DevicePointerRoi, pMask.Pitch, _sizeRoi, nCOI, pNormRel.DevicePointer, buffer.DevicePointer);
			Debug.WriteLine(String.Format("{0:G}, {1}: {2}", DateTime.Now, "nppiNormRel_L2_16u_C3CMR", status));
			buffer.Dispose();
			NPPException.CheckNppStatus(status, this);
		}