/// <summary> /// Image threshold.<para/> /// If for a comparison operations sourcePixel is less than nThresholdLT is true, the pixel is set /// to nValueLT, else if sourcePixel is greater than nThresholdGT the pixel is set to nValueGT, otherwise it is set to sourcePixel. /// </summary> /// <param name="dest">Destination image</param> /// <param name="nThresholdLT">The thresholdLT value.</param> /// <param name="nValueLT">The thresholdLT replacement value.</param> /// <param name="nThresholdGT">The thresholdGT value.</param> /// <param name="nValueGT">The thresholdGT replacement value.</param> public void ThresholdLTGT(NPPImage_16uC1 dest, ushort nThresholdLT, ushort nValueLT, ushort nThresholdGT, ushort nValueGT) { status = NPPNativeMethods.NPPi.Threshold.nppiThreshold_LTValGTVal_16u_C1R(_devPtrRoi, _pitch, dest.DevicePointerRoi, dest.Pitch, _sizeRoi, nThresholdLT, nValueLT, nThresholdGT, nValueGT); Debug.WriteLine(String.Format("{0:G}, {1}: {2}", DateTime.Now, "nppiThreshold_LTValGTVal_16u_C1R", status)); NPPException.CheckNppStatus(status, this); }
/// <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="dest0">Destination image (Channel 0)</param> /// <param name="dest1">Destination image (Channel 1)</param> /// <param name="dest2">Destination image (Channel 2)</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_16uC1 src0, NPPImage_16uC1 src1, NPPImage_16uC1 src2, NPPImage_16uC1 dest0, NPPImage_16uC1 dest1, NPPImage_16uC1 dest2, double xFactor, double yFactor, InterpolationMode eInterpolation) { CUdeviceptr[] src = new CUdeviceptr[] { src0.DevicePointer, src1.DevicePointer, src2.DevicePointer }; CUdeviceptr[] dst = new CUdeviceptr[] { dest0.DevicePointerRoi, dest1.DevicePointerRoi, dest2.DevicePointerRoi }; NppStatus status = NPPNativeMethods.NPPi.GeometricTransforms.nppiResize_16u_P3R(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_16u_P3R", status)); NPPException.CheckNppStatus(status, null); }
/// <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="dest0">Destination image (Channel 0)</param> /// <param name="dest1">Destination image (Channel 1)</param> /// <param name="dest2">Destination image (Channel 2)</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_16uC1 src0, NPPImage_16uC1 src1, NPPImage_16uC1 src2, NPPImage_16uC1 dest0, NPPImage_16uC1 dest1, NPPImage_16uC1 dest2, NPPImage_32fC1 pXMap, NPPImage_32fC1 pYMap, InterpolationMode eInterpolation) { CUdeviceptr[] src = new CUdeviceptr[] { src0.DevicePointer, src1.DevicePointer, src2.DevicePointer }; CUdeviceptr[] dst = new CUdeviceptr[] { dest0.DevicePointerRoi, dest1.DevicePointerRoi, dest2.DevicePointerRoi }; NppiRect srcRect = new NppiRect(src0.PointRoi, src0.SizeRoi); NppStatus status = NPPNativeMethods.NPPi.Remap.nppiRemap_16u_P3R(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_16u_P3R", status)); NPPException.CheckNppStatus(status, null); }
/// <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_16uC1 dst, int channel) { if (channel < 0 | channel >= _channels) throw new ArgumentOutOfRangeException("channel", "channel must be in range [0..2]."); status = NPPNativeMethods.NPPi.MemCopy.nppiCopy_16u_C3C1R(_devPtrRoi + channel * _typeSize, _pitch, dst.DevicePointerRoi, dst.Pitch, _sizeRoi); Debug.WriteLine(String.Format("{0:G}, {1}: {2}", DateTime.Now, "nppiCopy_16u_C3C1R", status)); NPPException.CheckNppStatus(status, this); }
/// <summary> /// Three-channel 8-bit unsigned planar to packed image copy. /// </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 Copy(NPPImage_16uC1 src0, NPPImage_16uC1 src1, NPPImage_16uC1 src2, NPPImage_16uC3 dest) { CUdeviceptr[] array = new CUdeviceptr[] { src0.DevicePointerRoi, src1.DevicePointerRoi, src2.DevicePointerRoi }; NppStatus status = NPPNativeMethods.NPPi.MemCopy.nppiCopy_16u_P3C3R(array, src0.Pitch, dest.DevicePointerRoi, dest.Pitch, dest.SizeRoi); Debug.WriteLine(String.Format("{0:G}, {1}: {2}", DateTime.Now, "nppiCopy_16u_P3C3R", status)); NPPException.CheckNppStatus(status, null); }
/// <summary> /// In place image division, scale by 2^(-nScaleFactor), then clamp to saturated value. /// </summary> /// <param name="src2">2nd source image</param> /// <param name="nScaleFactor">scaling factor</param> public void Div(NPPImage_16uC1 src2, int nScaleFactor) { status = NPPNativeMethods.NPPi.Div.nppiDiv_16u_C1IRSfs(src2.DevicePointerRoi, src2.Pitch, _devPtrRoi, _pitch, _sizeRoi, nScaleFactor); Debug.WriteLine(String.Format("{0:G}, {1}: {2}", DateTime.Now, "nppiDiv_16u_C1IRSfs", status)); NPPException.CheckNppStatus(status, this); }
/// <summary> /// 32-bit unsigned to 16-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_16uC1 dst, NppRoundMode roundMode, int scaleFactor) { status = NPPNativeMethods.NPPi.BitDepthConversion.nppiConvert_32u16u_C1RSfs(_devPtrRoi, _pitch, dst.DevicePointerRoi, dst.Pitch, _sizeRoi, roundMode, scaleFactor); Debug.WriteLine(String.Format("{0:G}, {1}: {2}", DateTime.Now, "nppiConvert_32u16u_C1RSfs", status)); NPPException.CheckNppStatus(status, this); }
/// <summary> /// Compare pSrc1's pixels with corresponding pixels in pSrc2. /// </summary> /// <param name="src2">2nd source image</param> /// <param name="dest">Destination image</param> /// <param name="eComparisonOperation">Specifies the comparison operation to be used in the pixel comparison.</param> public void Compare(NPPImage_16uC1 src2, NPPImage_8uC1 dest, NppCmpOp eComparisonOperation) { status = NPPNativeMethods.NPPi.Compare.nppiCompare_16u_C1R(_devPtrRoi, _pitch, src2.DevicePointerRoi, src2.Pitch, dest.DevicePointerRoi, dest.Pitch, _sizeRoi, eComparisonOperation); Debug.WriteLine(String.Format("{0:G}, {1}: {2}", DateTime.Now, "nppiCompare_16u_C1R", status)); NPPException.CheckNppStatus(status, this); }
/// <summary> /// Masked Operation 8-bit unsigned image copy. /// </summary> /// <param name="dst">Destination image</param> /// <param name="mask">Mask image</param> public void Copy(NPPImage_16uC1 dst, NPPImage_8uC1 mask) { status = NPPNativeMethods.NPPi.MemCopy.nppiCopy_16u_C1MR(_devPtrRoi, _pitch, dst.DevicePointerRoi, dst.Pitch, _sizeRoi, mask.DevicePointerRoi, mask.Pitch); Debug.WriteLine(String.Format("{0:G}, {1}: {2}", DateTime.Now, "nppiCopy_16u_C1MR", status)); NPPException.CheckNppStatus(status, this); }
/// <summary> /// In place image logical Xor. /// </summary> /// <param name="src2">2nd source image</param> public void Xor(NPPImage_16uC1 src2) { status = NPPNativeMethods.NPPi.Xor.nppiXor_16u_C1IR(src2.DevicePointerRoi, src2.Pitch, _devPtrRoi, _pitch, _sizeRoi); Debug.WriteLine(String.Format("{0:G}, {1}: {2}", DateTime.Now, "nppiXor_16u_C1IR", status)); NPPException.CheckNppStatus(status, this); }
/// <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> public void ColorTwist(NPPImage_16uC1 dest, float[,] twistMatrix) { status = NPPNativeMethods.NPPi.ColorProcessing.nppiColorTwist32f_16u_C1R(_devPtr, _pitch, dest.DevicePointer, dest.Pitch, _sizeRoi, twistMatrix); Debug.WriteLine(String.Format("{0:G}, {1}: {2}", DateTime.Now, "nppiColorTwist32f_16u_C1R", status)); NPPException.CheckNppStatus(status, this); }
/// <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="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 WarpPerspectiveQuad(double[,] srcQuad, NPPImage_16uC1 dest, double[,] destQuad, InterpolationMode eInterpolation) { NppiRect rectIn = new NppiRect(_pointRoi, _sizeRoi); NppiRect rectOut = new NppiRect(dest.PointRoi, dest.SizeRoi); status = NPPNativeMethods.NPPi.PerspectiveTransforms.nppiWarpPerspectiveQuad_16u_C1R(_devPtr, _sizeOriginal, _pitch, rectIn, srcQuad, dest.DevicePointer, dest.Pitch, rectOut, destQuad, eInterpolation); Debug.WriteLine(String.Format("{0:G}, {1}: {2}", DateTime.Now, "nppiWarpPerspectiveQuad_16u_C1R", status)); NPPException.CheckNppStatus(status, this); }
/// <summary> /// image average relative error. /// </summary> /// <param name="src2">2nd source image</param> /// <param name="pError">Pointer to the computed error.</param> /// <param name="buffer">Pointer to the user-allocated scratch buffer required for the AverageRelativeError operation.</param> public void AverageRelativeError(NPPImage_16uC1 src2, CudaDeviceVariable<double> pError, CudaDeviceVariable<byte> buffer) { int bufferSize = AverageRelativeErrorGetBufferHostSize(); if (bufferSize > buffer.Size) throw new NPPException("Provided buffer is too small."); status = NPPNativeMethods.NPPi.AverageRelativeError.nppiAverageRelativeError_16u_C1R(_devPtrRoi, _pitch, src2.DevicePointerRoi, src2.Pitch, _sizeRoi, pError.DevicePointer, buffer.DevicePointer); Debug.WriteLine(String.Format("{0:G}, {1}: {2}", DateTime.Now, "nppiAverageRelativeError_16u_C1R", status)); NPPException.CheckNppStatus(status, this); }
/// <summary> /// image transpose /// </summary> /// <param name="dest">Destination image</param> public void Transpose(NPPImage_16uC1 dest) { status = NPPNativeMethods.NPPi.Transpose.nppiTranspose_16u_C1R(_devPtrRoi, _pitch, dest.DevicePointerRoi, dest.Pitch, _sizeRoi); Debug.WriteLine(String.Format("{0:G}, {1}: {2}", DateTime.Now, "nppiTranspose_16u_C1R", status)); NPPException.CheckNppStatus(status, this); }
/// <summary> /// 3x3 dilation with border control. /// </summary> /// <param name="dest">Destination image</param> /// <param name="eBorderType">The border type operation to be applied at source image border boundaries.</param> public void Dilate3x3Border(NPPImage_16uC1 dest, NppiBorderType eBorderType) { status = NPPNativeMethods.NPPi.Dilate3x3Border.nppiDilate3x3Border_16u_C1R(_devPtr, _pitch, _sizeOriginal, _pointRoi, dest.DevicePointerRoi, dest.Pitch, _sizeRoi, eBorderType); Debug.WriteLine(String.Format("{0:G}, {1}: {2}", DateTime.Now, "nppiDilate3x3Border_16u_C1R", status)); NPPException.CheckNppStatus(status, this); }
/// <summary> /// linearly interpolated source image subpixel coordinate color copy. /// </summary> /// <param name="dst">Destination-Image</param> /// <param name="nDx">Fractional part of source image X coordinate.</param> /// <param name="nDy">Fractional part of source image Y coordinate.</param> public void CopySubpix(NPPImage_16uC1 dst, float nDx, float nDy) { status = NPPNativeMethods.NPPi.CopySubpix.nppiCopySubpix_16u_C1R(_devPtrRoi, _pitch, dst.DevicePointerRoi, dst.Pitch, _sizeRoi, nDx, nDy); Debug.WriteLine(String.Format("{0:G}, {1}: {2}", DateTime.Now, "nppiCopySubpix_16u_C1R", status)); NPPException.CheckNppStatus(status, this); }
/// <summary> /// Dilation computes the output pixel as the maximum pixel value of the pixels under the mask. Pixels who’s /// corresponding mask values are zero to not participate in the maximum search. With border control. /// </summary> /// <param name="dest">Destination image</param> /// <param name="Mask">Pointer to the start address of the mask array.</param> /// <param name="aMaskSize">Width and Height mask array.</param> /// <param name="oAnchor">X and Y offsets of the mask origin frame of reference w.r.t the source pixel.</param> /// <param name="eBorderType">The border type operation to be applied at source image border boundaries.</param> public void DilateBorder(NPPImage_16uC1 dest, CudaDeviceVariable<byte> Mask, NppiSize aMaskSize, NppiPoint oAnchor, NppiBorderType eBorderType) { status = NPPNativeMethods.NPPi.DilationWithBorderControl.nppiDilateBorder_16u_C1R(_devPtr, _pitch, _sizeOriginal, _pointRoi, dest.DevicePointerRoi, dest.Pitch, _sizeRoi, Mask.DevicePointer, aMaskSize, oAnchor, eBorderType); Debug.WriteLine(String.Format("{0:G}, {1}: {2}", DateTime.Now, "nppiDilateBorder_16u_C1R", status)); NPPException.CheckNppStatus(status, this); }
/// <summary> /// image copy with the borders wrapped by replication of source image pixel colors. /// </summary> /// <param name="dst">Destination-Image</param> /// <param name="nTopBorderHeight">Height (in pixels) of the top border. The height of the border at the bottom of /// the destination ROI is implicitly defined by the size of the source ROI: nBottomBorderHeight = /// oDstSizeROI.height - nTopBorderHeight - oSrcSizeROI.height.</param> /// <param name="nLeftBorderWidth">Width (in pixels) of the left border. The width of the border at the right side of /// the destination ROI is implicitly defined by the size of the source ROI: nRightBorderWidth = /// oDstSizeROI.width - nLeftBorderWidth - oSrcSizeROI.width.</param> public void CopyWrapBorder(NPPImage_16uC1 dst, int nTopBorderHeight, int nLeftBorderWidth) { status = NPPNativeMethods.NPPi.CopyWrapBorder.nppiCopyWrapBorder_16u_C1R(_devPtrRoi, _pitch, _sizeRoi, dst.DevicePointerRoi, dst.Pitch, dst.SizeRoi, nTopBorderHeight, nLeftBorderWidth); Debug.WriteLine(String.Format("{0:G}, {1}: {2}", DateTime.Now, "nppiCopyWrapBorder_16u_C1R", status)); NPPException.CheckNppStatus(status, this); }
/// <summary> /// Divide constant to image, scale by 2^(-nScaleFactor), then clamp to saturated value. /// </summary> /// <param name="nConstant">Value</param> /// <param name="dest">Destination image</param> /// <param name="nScaleFactor">scaling factor</param> public void Div(ushort nConstant, NPPImage_16uC1 dest, int nScaleFactor) { status = NPPNativeMethods.NPPi.DivConst.nppiDivC_16u_C1RSfs(_devPtrRoi, _pitch, nConstant, dest.DevicePointerRoi, dest.Pitch, _sizeRoi, nScaleFactor); Debug.WriteLine(String.Format("{0:G}, {1}: {2}", DateTime.Now, "nppiDivC_16u_C1RSfs", status)); NPPException.CheckNppStatus(status, this); }
/// <summary> /// CrossCorrSame_NormLevel. /// </summary> /// <param name="tpl">template image.</param> /// <param name="dst">Destination image</param> /// <param name="buffer">Allocated device memory with size of at <see cref="SameNormLevelGetBufferHostSize()"/></param> public void CrossCorrSame_NormLevel(NPPImage_16uC1 tpl, NPPImage_32fC1 dst, CudaDeviceVariable<byte> buffer) { int bufferSize = SameNormLevelGetBufferHostSize(); if (bufferSize > buffer.Size) throw new NPPException("Provided buffer is too small."); status = NPPNativeMethods.NPPi.ImageProximity.nppiCrossCorrSame_NormLevel_16u32f_C1R(_devPtrRoi, _pitch, _sizeRoi, tpl.DevicePointerRoi, tpl.Pitch, tpl.SizeRoi, dst.DevicePointer, dst.Pitch, buffer.DevicePointer); Debug.WriteLine(String.Format("{0:G}, {1}: {2}", DateTime.Now, "nppiCrossCorrSame_NormLevel_16u32f_C1R", status)); NPPException.CheckNppStatus(status, this); }
/// <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_16uC1 src0, NPPImage_16uC1 src1, NPPImage_16uC1 src2, double[,] srcQuad, NPPImage_16uC1 dest0, NPPImage_16uC1 dest1, NPPImage_16uC1 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_16u_P3R(src, src0.Size, src0.Pitch, rectIn, srcQuad, dst, dest0.Pitch, rectOut, destQuad, eInterpolation); Debug.WriteLine(String.Format("{0:G}, {1}: {2}", DateTime.Now, "nppiWarpPerspectiveQuad_16u_P3R", status)); NPPException.CheckNppStatus(status, null); }
/// <summary> /// image CrossCorrValid_Norm. /// </summary> /// <param name="tpl">template image.</param> /// <param name="dst">Destination-Image</param> public void CrossCorrValid_Norm(NPPImage_16uC1 tpl, NPPImage_32fC1 dst) { status = NPPNativeMethods.NPPi.ImageProximity.nppiCrossCorrValid_Norm_16u32f_C1R(_devPtrRoi, _pitch, _sizeRoi, tpl.DevicePointerRoi, tpl.Pitch, tpl.SizeRoi, dst.DevicePointerRoi, dst.Pitch); Debug.WriteLine(String.Format("{0:G}, {1}: {2}", DateTime.Now, "nppiCrossCorrValid_Norm_16u32f_C1R", status)); NPPException.CheckNppStatus(status, this); }
/// <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> public void Copy(NPPImage_16uC1 dst0, NPPImage_16uC1 dst1, NPPImage_16uC1 dst2) { CUdeviceptr[] array = new CUdeviceptr[] { dst0.DevicePointerRoi, dst1.DevicePointerRoi, dst2.DevicePointerRoi }; status = NPPNativeMethods.NPPi.MemCopy.nppiCopy_16u_C3P3R(_devPtrRoi, _pitch, array, dst0.Pitch, _sizeRoi); Debug.WriteLine(String.Format("{0:G}, {1}: {2}", DateTime.Now, "nppiCopy_16u_C3P3R", status)); NPPException.CheckNppStatus(status, this); }
/// <summary> /// CrossCorrValid_NormLevel. Buffer is internally allocated and freed. /// </summary> /// <param name="tpl">template image.</param> /// <param name="dst">Destination image</param> public void CrossCorrValid_NormLevel(NPPImage_16uC1 tpl, NPPImage_32fC1 dst) { int bufferSize = ValidNormLevelGetBufferHostSize(); CudaDeviceVariable<byte> buffer = new CudaDeviceVariable<byte>(bufferSize); status = NPPNativeMethods.NPPi.ImageProximity.nppiCrossCorrValid_NormLevel_16u32f_C1R(_devPtrRoi, _pitch, _sizeRoi, tpl.DevicePointerRoi, tpl.Pitch, tpl.SizeRoi, dst.DevicePointer, dst.Pitch, buffer.DevicePointer); Debug.WriteLine(String.Format("{0:G}, {1}: {2}", DateTime.Now, "nppiCrossCorrValid_NormLevel_16u32f_C1R", status)); buffer.Dispose(); NPPException.CheckNppStatus(status, this); }
/// <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_16uC1 dest, float[] aCoeffs) { status = NPPNativeMethods.NPPi.ColorToGray.nppiColorToGray_16u_C3C1R(_devPtrRoi, _pitch, dest.DevicePointerRoi, dest.Pitch, _sizeRoi, aCoeffs); Debug.WriteLine(String.Format("{0:G}, {1}: {2}", DateTime.Now, "nppiColorToGray_16u_C3C1R", status)); NPPException.CheckNppStatus(status, this); }
/// <summary> /// Dilation computes the output pixel as the maximum pixel value of the pixels under the mask. Pixels who’s /// corresponding mask values are zero to not participate in the maximum search. /// </summary> /// <param name="dest">Destination image</param> /// <param name="Mask">Pointer to the start address of the mask array.</param> /// <param name="aMaskSize">Width and Height mask array.</param> /// <param name="oAnchor">X and Y offsets of the mask origin frame of reference w.r.t the source pixel.</param> public void Dilate(NPPImage_16uC1 dest, CudaDeviceVariable<byte> Mask, NppiSize aMaskSize, NppiPoint oAnchor) { status = NPPNativeMethods.NPPi.MorphologyFilter2D.nppiDilate_16u_C1R(_devPtrRoi, _pitch, dest.DevicePointerRoi, dest.Pitch, _sizeRoi, Mask.DevicePointer, aMaskSize, oAnchor); Debug.WriteLine(String.Format("{0:G}, {1}: {2}", DateTime.Now, "nppiDilate_16u_C1R", status)); NPPException.CheckNppStatus(status, this); }
/// <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="dest0">Destination image (Channel 0)</param> /// <param name="dest1">Destination image (Channel 1)</param> /// <param name="dest2">Destination image (Channel 2)</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_16uC1 src0, NPPImage_16uC1 src1, NPPImage_16uC1 src2, NPPImage_16uC1 dest0, NPPImage_16uC1 dest1, NPPImage_16uC1 dest2, double nXFactor, double nYFactor, double nXShift, double nYShift, InterpolationMode eInterpolation) { CUdeviceptr[] src = new CUdeviceptr[] { src0.DevicePointer, src1.DevicePointer, src2.DevicePointer }; CUdeviceptr[] dst = new CUdeviceptr[] { dest0.DevicePointer, dest1.DevicePointer, dest2.DevicePointer }; NppiRect srcRect = new NppiRect(src0.PointRoi, src0.SizeRoi); NppiRect dstRect = new NppiRect(dest0.PointRoi, dest0.SizeRoi); NppStatus status = NPPNativeMethods.NPPi.ResizeSqrPixel.nppiResizeSqrPixel_16u_P3R(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_16u_P3R", status)); NPPException.CheckNppStatus(status, null); }
/// <summary> /// 3x3 dilation. /// </summary> /// <param name="dst">Destination-Image</param> public void Dilate3x3(NPPImage_16uC1 dst) { status = NPPNativeMethods.NPPi.MorphologyFilter2D.nppiDilate3x3_16u_C1R(_devPtrRoi, _pitch, dst.DevicePointerRoi, dst.Pitch, _sizeRoi); Debug.WriteLine(String.Format("{0:G}, {1}: {2}", DateTime.Now, "nppiDilate3x3_16u_C1R", status)); NPPException.CheckNppStatus(status, this); }
/// <summary> /// 3 channel planar 8-bit unsigned inplace color twist. /// An input color twist matrix with floating-point pixel values is applied /// within ROI. /// </summary> /// <param name="srcDest0">Source / Destination image (Channel 0)</param> /// <param name="srcDest1">Source / Destinationimage (Channel 1)</param> /// <param name="srcDest2">Source / Destinationimage (Channel 2)</param> /// <param name="twistMatrix">The color twist matrix with floating-point pixel values [3,4].</param> public static void ColorTwist(NPPImage_16uC1 srcDest0, NPPImage_16uC1 srcDest1, NPPImage_16uC1 srcDest2, float[,] twistMatrix) { CUdeviceptr[] src = new CUdeviceptr[] { srcDest0.DevicePointerRoi, srcDest1.DevicePointerRoi, srcDest2.DevicePointerRoi }; NppStatus status = NPPNativeMethods.NPPi.ColorTwist.nppiColorTwist32f_16u_IP3R(src, srcDest0.Pitch, srcDest0.SizeRoi, twistMatrix); Debug.WriteLine(String.Format("{0:G}, {1}: {2}", DateTime.Now, "nppiColorTwist32f_16u_IP3R", status)); NPPException.CheckNppStatus(status, null); }
/// <summary> /// Image threshold.<para/> /// If for a comparison operations OP the predicate (sourcePixel OP nThreshold) is true, the pixel is set /// to nValue, otherwise it is set to sourcePixel. /// </summary> /// <param name="dest">Destination image</param> /// <param name="nThreshold">The threshold value.</param> /// <param name="nValue">The threshold replacement value.</param> /// <param name="eComparisonOperation">eComparisonOperation. Only allowed values are <see cref="NppCmpOp.Less"/> and <see cref="NppCmpOp.Greater"/></param> public void Threshold(NPPImage_16uC1 dest, ushort nThreshold, ushort nValue, NppCmpOp eComparisonOperation) { status = NPPNativeMethods.NPPi.Threshold.nppiThreshold_Val_16u_C1R(_devPtrRoi, _pitch, dest.DevicePointerRoi, dest.Pitch, _sizeRoi, nThreshold, nValue, eComparisonOperation); Debug.WriteLine(String.Format("{0:G}, {1}: {2}", DateTime.Now, "nppiThreshold_Val_16u_C1R", status)); NPPException.CheckNppStatus(status, this); }