Inheritance: NPPImageBase
Example #1
0
 /// <summary>
 /// Natural logarithm, scale by 2^(-nScaleFactor), then clamp to saturated value.
 /// </summary>
 /// <param name="dest">Destination image</param>
 /// <param name="nScaleFactor">scaling factor</param>
 public void Ln(NPPImage_8uC3 dest, int nScaleFactor)
 {
     status = NPPNativeMethods.NPPi.Ln.nppiLn_8u_C3RSfs(_devPtrRoi, _pitch, dest.DevicePointerRoi, dest.Pitch, _sizeRoi, nScaleFactor);
     Debug.WriteLine(String.Format("{0:G}, {1}: {2}", DateTime.Now, "nppiLn_8u_C3RSfs", status));
     NPPException.CheckNppStatus(status, this);
 }
Example #2
0
        private void btn_Resize_Click(object sender, EventArgs e)
        {
            if ((Bitmap)pic_Image.Image == null) return;

            Bitmap bmp = (Bitmap)pic_Image.Image;
            int w = bmp.Width;
            int h = bmp.Height;

            if ((w <= 16 || h <= 16) && trk_Size.Value < 100)
            {
                MessageBox.Show("Image is too small for resizing.");
                return;
            }

            int newW = (int)(trk_Size.Value / 100.0f * w);
            int newH = (int)(trk_Size.Value / 100.0f * h);

            if (newW % 16 != 0)
            {
                newW = newW - (newW % 16);
            }
            if (newW < 16) newW = 16;

            if (newH % 16 != 0)
            {
                newH = newH - (newH % 16);
            }
            if (newH < 16) newH = 16;

            double ratioW = newW / (double)w;
            double ratioH = newH / (double)h;

            if (ratioW == 1 && ratioH == 1)
                return;

            if (bmp.PixelFormat != System.Drawing.Imaging.PixelFormat.Format24bppRgb)
            {
                MessageBox.Show("Only three channel color images are supported!");
                return;
            }

            NPPImage_8uC3 imgIn = new NPPImage_8uC3(w, h);
            NPPImage_8uC3 imgOut = new NPPImage_8uC3(newW, newH);

            InterpolationMode interpol = InterpolationMode.SuperSampling;
            if (ratioH >= 1 || ratioW >= 1)
                interpol = InterpolationMode.Lanczos;

            imgIn.CopyToDevice(bmp);
            imgIn.ResizeSqrPixel(imgOut, ratioW, ratioH, 0, 0, interpol);
            Bitmap bmpRes = new Bitmap(newW, newH, System.Drawing.Imaging.PixelFormat.Format24bppRgb);
            imgOut.CopyToHost(bmpRes);
            pic_Image.Image = bmpRes;

            imgIn.Dispose();
            imgOut.Dispose();
        }
Example #3
0
		/// <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_8uC3 dst, NppHintAlgorithm hint)
		{
			NppiRect srcRect = new NppiRect(_pointRoi, _sizeRoi);
			status = NPPNativeMethods.NPPi.Scale.nppiScale_16u8u_C3R(_devPtrRoi, _pitch, dst.DevicePointerRoi, dst.Pitch, _sizeRoi, hint);
			Debug.WriteLine(String.Format("{0:G}, {1}: {2}", DateTime.Now, "nppiScale_16u8u_C3R", status));
			NPPException.CheckNppStatus(status, this);
		}
Example #4
0
 /// <summary>
 /// In place image logical Xor.
 /// </summary>
 /// <param name="src2">2nd source image</param>
 public void Xor(NPPImage_8uC3 src2)
 {
     status = NPPNativeMethods.NPPi.Xor.nppiXor_8u_C3IR(src2.DevicePointerRoi, src2.Pitch, _devPtrRoi, _pitch, _sizeRoi);
     Debug.WriteLine(String.Format("{0:G}, {1}: {2}", DateTime.Now, "nppiXor_8u_C3IR", status));
     NPPException.CheckNppStatus(status, this);
 }
Example #5
0
 /// <summary>
 /// 3 channel 8-bit unsigned packed YUV to 3 channel 8-bit unsigned packed RGB color conversion.
 /// </summary>
 /// <param name="dest">Destination image</param>  
 public void YUVToRGB(NPPImage_8uC3 dest)
 {
     NppStatus status = NPPNativeMethods.NPPi.YUVToRGB.nppiYUVToRGB_8u_C3R(_devPtrRoi, _pitch, dest.DevicePointerRoi, dest.Pitch, _sizeRoi);
     Debug.WriteLine(String.Format("{0:G}, {1}: {2}", DateTime.Now, "nppiYUVToRGB_8u_C3R", status));
     NPPException.CheckNppStatus(status, null);
 }
Example #6
0
 /// <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_8uC3 dest, byte[] nThreshold, byte[] nValue, NppCmpOp eComparisonOperation)
 {
     status = NPPNativeMethods.NPPi.Threshold.nppiThreshold_Val_8u_C3R(_devPtrRoi, _pitch, dest.DevicePointerRoi, dest.Pitch, _sizeRoi, nThreshold, nValue, eComparisonOperation);
     Debug.WriteLine(String.Format("{0:G}, {1}: {2}", DateTime.Now, "nppiThreshold_Val_8u_C3R", status));
     NPPException.CheckNppStatus(status, this);
 }
Example #7
0
 /// <summary>
 /// image transpose
 /// </summary>
 /// <param name="dest">Destination image</param>
 public void Transpose(NPPImage_8uC3 dest)
 {
     status = NPPNativeMethods.NPPi.Transpose.nppiTranspose_8u_C3R(_devPtrRoi, _pitch, dest.DevicePointerRoi, dest.Pitch, _sizeRoi);
     Debug.WriteLine(String.Format("{0:G}, {1}: {2}", DateTime.Now, "nppiTranspose_8u_C3R", status));
     NPPException.CheckNppStatus(status, this);
 }
Example #8
0
        /// <summary>
        /// image NormDiff_Inf. Buffer is internally allocated and freed.
        /// </summary>
        /// <param name="tpl">template image.</param>
        /// <param name="pNormDiff">Pointer to the computed Inf-norm of differences. (3 * sizeof(double))</param>
        public void NormDiff_Inf(NPPImage_8uC3 tpl, CudaDeviceVariable<double> pNormDiff)
        {
            int bufferSize = NormDiffInfGetBufferHostSize();
            CudaDeviceVariable<byte> buffer = new CudaDeviceVariable<byte>(bufferSize);

            status = NPPNativeMethods.NPPi.NormDiff.nppiNormDiff_Inf_8u_C3R(_devPtrRoi, _pitch, tpl.DevicePointerRoi, tpl.Pitch, _sizeRoi, pNormDiff.DevicePointer, buffer.DevicePointer);
            Debug.WriteLine(String.Format("{0:G}, {1}: {2}", DateTime.Now, "nppiNormDiff_Inf_8u_C3R", status));
            buffer.Dispose();
            NPPException.CheckNppStatus(status, this);
        }
Example #9
0
        /// <summary>
        /// image NormRel_L2.
        /// </summary>
        /// <param name="tpl">template image.</param>
        /// <param name="pNormRel">Pointer to the computed relative error for the infinity norm of two images. (3 * sizeof(double))</param>
        /// <param name="buffer">Allocated device memory with size of at <see cref="NormRelL2GetBufferHostSize()"/></param>
        public void NormRel_L2(NPPImage_8uC3 tpl, CudaDeviceVariable<double> pNormRel, CudaDeviceVariable<byte> buffer)
        {
            int bufferSize = NormRelL2GetBufferHostSize();
            if (bufferSize > buffer.Size) throw new NPPException("Provided buffer is too small.");

            status = NPPNativeMethods.NPPi.NormRel.nppiNormRel_L2_8u_C3R(_devPtrRoi, _pitch, tpl.DevicePointerRoi, tpl.Pitch, _sizeRoi, pNormRel.DevicePointer, buffer.DevicePointer);
            Debug.WriteLine(String.Format("{0:G}, {1}: {2}", DateTime.Now, "nppiNormRel_L2_8u_C3R", status));
            NPPException.CheckNppStatus(status, this);
        }
Example #10
0
        /// <summary>
        /// image maximum 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 MaximumRelativeError operation.</param>
        public void MaximumRelativeError(NPPImage_8uC3 src2, CudaDeviceVariable<double> pError, CudaDeviceVariable<byte> buffer)
        {
            int bufferSize = MaximumRelativeErrorGetBufferHostSize();
            if (bufferSize > buffer.Size) throw new NPPException("Provided buffer is too small.");

            status = NPPNativeMethods.NPPi.MaximumRelativeError.nppiMaximumRelativeError_8u_C3R(_devPtrRoi, _pitch, src2.DevicePointerRoi, src2.Pitch, _sizeRoi, pError.DevicePointer, buffer.DevicePointer);
            Debug.WriteLine(String.Format("{0:G}, {1}: {2}", DateTime.Now, "nppiMaximumRelativeError_8u_C3R", status));
            NPPException.CheckNppStatus(status, this);
        }
Example #11
0
 /// <summary>
 /// Mirror image.
 /// </summary>
 /// <param name="dest">Destination image</param>
 /// <param name="flip">Specifies the axis about which the image is to be mirrored.</param>
 public void Mirror(NPPImage_8uC3 dest, NppiAxis flip)
 {
     status = NPPNativeMethods.NPPi.GeometricTransforms.nppiMirror_8u_C3R(_devPtrRoi, _pitch, dest.DevicePointerRoi, dest.Pitch, dest.SizeRoi, flip);
     Debug.WriteLine(String.Format("{0:G}, {1}: {2}", DateTime.Now, "nppiMirror_8u_C3R", status));
     NPPException.CheckNppStatus(status, this);
 }
Example #12
0
 /// <summary>
 /// range restricted palette look-up-table color conversion.
 /// The LUT is derived from a set of user defined mapping points in a palette and 
 /// source pixels are then processed using a restricted bit range when looking up palette values.
 /// </summary>
 /// <param name="dst">Destination-Image</param>
 /// <param name="pTable">Host pointer to an array of 3 device memory pointers, one per color CHANNEL, pointing to user defined OUTPUT palette values.</param>
 /// <param name="nBitSize">Number of least significant bits (must be &gt; 0 and &lt;= 8) of each source pixel value to use as index into palette table during conversion.</param>
 public void LUTPalette(NPPImage_8uC3 dst, CudaDeviceVariable<byte>[] pTable, int nBitSize)
 {
     CUdeviceptr[] ptrsT = new CUdeviceptr[] { pTable[0].DevicePointer, pTable[1].DevicePointer, pTable[2].DevicePointer };
     status = NPPNativeMethods.NPPi.ColorLUTPalette.nppiLUTPalette_8u_C3R(_devPtrRoi, _pitch, dst.DevicePointerRoi, dst.Pitch, _sizeRoi, ptrsT, nBitSize);
     Debug.WriteLine(String.Format("{0:G}, {1}: {2}", DateTime.Now, "nppiLUTPalette_8u_C3R", status));
     NPPException.CheckNppStatus(status, this);
 }
Example #13
0
 /// <summary>
 /// cubic interpolated look-up-table color conversion.
 /// The LUT is derived from a set of user defined mapping points through cubic interpolation. 
 /// </summary>
 /// <param name="dst">Destination-Image</param>
 /// <param name="pValues">Host pointer to an array of 3 device memory pointers, one per color CHANNEL, pointing to user defined OUTPUT values.</param>
 /// <param name="pLevels">Host pointer to an array of 3 device memory pointers, one per color CHANNEL, pointing to user defined INPUT values. pLevels.Size gives nLevels.</param>
 public void LUTCubic(NPPImage_8uC3 dst, CudaDeviceVariable<int>[] pValues, CudaDeviceVariable<int>[] pLevels)
 {
     CUdeviceptr[] ptrsV = new CUdeviceptr[] { pValues[0].DevicePointer, pValues[1].DevicePointer, pValues[2].DevicePointer };
     CUdeviceptr[] ptrsL = new CUdeviceptr[] { pLevels[0].DevicePointer, pLevels[1].DevicePointer, pLevels[2].DevicePointer };
     int[] size = new int[] { (int)pLevels[0].Size, (int)pLevels[1].Size, (int)pLevels[2].Size };
     status = NPPNativeMethods.NPPi.ColorLUTCubic.nppiLUT_Cubic_8u_C3R(_devPtrRoi, _pitch, dst.DevicePointerRoi, dst.Pitch, _sizeRoi, ptrsV, ptrsL, size);
     Debug.WriteLine(String.Format("{0:G}, {1}: {2}", DateTime.Now, "nppiLUT_Cubic_8u_C3R", status));
     NPPException.CheckNppStatus(status, this);
 }
Example #14
0
        /// <summary>
        /// look-up-table color conversion.<para/>
        /// The LUT is derived from a set of user defined mapping points through linear interpolation.
        /// </summary>
        /// <param name="dest">Destination image</param>
        /// <param name="values0">array of user defined OUTPUT values, channel 0</param>
        /// <param name="levels0">array of user defined INPUT values, channel 0</param>
        /// <param name="values1">array of user defined OUTPUT values, channel 1</param>
        /// <param name="levels1">array of user defined INPUT values, channel 1</param>
        /// <param name="values2">array of user defined OUTPUT values, channel 2</param>
        /// <param name="levels2">array of user defined INPUT values, channel 2</param>
        public void Lut(NPPImage_8uC3 dest, CudaDeviceVariable<int> values0, CudaDeviceVariable<int> levels0, CudaDeviceVariable<int> values1, CudaDeviceVariable<int> levels1, CudaDeviceVariable<int> values2, CudaDeviceVariable<int> levels2)
        {
            if (values0.Size != levels0.Size) throw new ArgumentException("values0 and levels0 must have same size.");
            if (values1.Size != levels1.Size) throw new ArgumentException("values1 and levels1 must have same size.");
            if (values2.Size != levels2.Size) throw new ArgumentException("values2 and levels2 must have same size.");

            CUdeviceptr[] values = new CUdeviceptr[3];
            CUdeviceptr[] levels = new CUdeviceptr[3];
            int[] levelLengths = new int[3];

            values[0] = values0.DevicePointer;
            values[1] = values1.DevicePointer;
            values[2] = values2.DevicePointer;
            levels[0] = levels0.DevicePointer;
            levels[1] = levels1.DevicePointer;
            levels[2] = levels2.DevicePointer;

            levelLengths[0] = (int)levels0.Size;
            levelLengths[1] = (int)levels1.Size;
            levelLengths[2] = (int)levels2.Size;

            status = NPPNativeMethods.NPPi.ColorProcessing.nppiLUT_Linear_8u_C3R(_devPtrRoi, _pitch, dest.DevicePointerRoi, dest.Pitch, _sizeRoi, values, levels, levelLengths);

            Debug.WriteLine(String.Format("{0:G}, {1}: {2}", DateTime.Now, "nppiLUT_Linear_8u_C3R", status));
            NPPException.CheckNppStatus(status, this);
        }
Example #15
0
 /// <summary>
 /// image SqrDistanceValid_Norm.
 /// </summary>
 /// <param name="tpl">template image.</param>
 /// <param name="dst">Destination-Image</param>
 /// <param name="nScaleFactor">Integer Result Scaling.</param>
 public void SqrDistanceValid_Norm(NPPImage_8uC3 tpl, NPPImage_8uC3 dst, int nScaleFactor)
 {
     status = NPPNativeMethods.NPPi.ImageProximity.nppiSqrDistanceValid_Norm_8u_C3RSfs(_devPtrRoi, _pitch, _sizeRoi, tpl.DevicePointerRoi, tpl.Pitch, tpl.SizeRoi, dst.DevicePointerRoi, dst.Pitch, nScaleFactor);
     Debug.WriteLine(String.Format("{0:G}, {1}: {2}", DateTime.Now, "nppiSqrDistanceValid_Norm_8u_C3RSfs", status));
     NPPException.CheckNppStatus(status, this);
 }
Example #16
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_8uC3 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_8u_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_8u_C3CMR", status));
            buffer.Dispose();
            NPPException.CheckNppStatus(status, this);
        }
Example #17
0
 /// <summary>
 /// In place image subtraction, 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 Sub(NPPImage_8uC3 src2, int nScaleFactor)
 {
     status = NPPNativeMethods.NPPi.Sub.nppiSub_8u_C3IRSfs(src2.DevicePointerRoi, src2.Pitch, _devPtrRoi, _pitch, _sizeRoi, nScaleFactor);
     Debug.WriteLine(String.Format("{0:G}, {1}: {2}", DateTime.Now, "nppiSub_8u_C3IRSfs", status));
     NPPException.CheckNppStatus(status, this);
 }
Example #18
0
        /// <summary>
        /// image QualityIndex.
        /// </summary>
        /// <param name="src2">2nd source image</param>
        /// <param name="dst">Pointer to the quality index. (3 * sizeof(float))</param>
        public void QualityIndex(NPPImage_8uC3 src2, CudaDeviceVariable<float> dst)
        {
            int bufferSize = QualityIndexGetBufferHostSize();
            CudaDeviceVariable<byte> buffer = new CudaDeviceVariable<byte>(bufferSize);

            status = NPPNativeMethods.NPPi.QualityIndex.nppiQualityIndex_8u32f_C3R(_devPtrRoi, _pitch, src2.DevicePointerRoi, src2.Pitch, _sizeRoi, dst.DevicePointer, buffer.DevicePointer);
            Debug.WriteLine(String.Format("{0:G}, {1}: {2}", DateTime.Now, "nppiQualityIndex_8u32f_C3R", status));
            buffer.Dispose();
            NPPException.CheckNppStatus(status, this);
        }
Example #19
0
 /// <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_8uC3 dest, byte[] nThresholdLT, byte[] nValueLT, byte[] nThresholdGT, byte[] nValueGT)
 {
     status = NPPNativeMethods.NPPi.Threshold.nppiThreshold_LTValGTVal_8u_C3R(_devPtrRoi, _pitch, dest.DevicePointerRoi, dest.Pitch, _sizeRoi, nThresholdLT, nValueLT, nThresholdGT, nValueGT);
     Debug.WriteLine(String.Format("{0:G}, {1}: {2}", DateTime.Now, "nppiThreshold_LTValGTVal_8u_C3R", status));
     NPPException.CheckNppStatus(status, this);
 }
Example #20
0
 /// <summary>
 /// image remap.
 /// </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 Remap(NPPImage_8uC3 dst, NPPImage_32fC1 pXMap, NPPImage_32fC1 pYMap, InterpolationMode eInterpolation)
 {
     NppiRect srcRect = new NppiRect(_pointRoi, _sizeRoi);
     status = NPPNativeMethods.NPPi.Remap.nppiRemap_8u_C3R(_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_C3R", status));
     NPPException.CheckNppStatus(status, this);
 }
Example #21
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="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_8uC3 dest, double[,] destQuad, InterpolationMode eInterpolation)
 {
     NppiRect rectIn = new NppiRect(_pointRoi, _sizeRoi);
     NppiRect rectOut = new NppiRect(dest.PointRoi, dest.SizeRoi);
     status = NPPNativeMethods.NPPi.PerspectiveTransforms.nppiWarpPerspectiveQuad_8u_C3R(_devPtr, _sizeOriginal, _pitch, rectIn, srcQuad, dest.DevicePointer, dest.Pitch, rectOut, destQuad, eInterpolation);
     Debug.WriteLine(String.Format("{0:G}, {1}: {2}", DateTime.Now, "nppiWarpPerspectiveQuad_8u_C3R", status));
     NPPException.CheckNppStatus(status, this);
 }
Example #22
0
 /// <summary>
 /// Resizes images.
 /// </summary>
 /// <param name="dest">Destination image</param>
 /// <param name="xFactor">X scaling factor</param>
 /// <param name="yFactor">Y scaling factor</param>
 /// <param name="eInterpolation">Interpolation mode</param>
 public void Resize(NPPImage_8uC3 dest, double xFactor, double yFactor, InterpolationMode eInterpolation)
 {
     status = NPPNativeMethods.NPPi.GeometricTransforms.nppiResize_8u_C3R(_devPtr, _sizeOriginal, _pitch, new NppiRect(_pointRoi, _sizeRoi), dest.DevicePointerRoi, dest.Pitch, dest.SizeRoi, xFactor, yFactor, eInterpolation);
     Debug.WriteLine(String.Format("{0:G}, {1}: {2}", DateTime.Now, "nppiResize_8u_C3R", status));
     NPPException.CheckNppStatus(status, this);
 }
Example #23
0
 /// <summary>
 /// Image logical Xor with constant.
 /// </summary>
 /// <param name="nConstant">Value (Array length = 3)</param>
 /// <param name="dest">Destination image</param>
 public void Xor(byte[] nConstant, NPPImage_8uC3 dest)
 {
     status = NPPNativeMethods.NPPi.XorConst.nppiXorC_8u_C3R(_devPtrRoi, _pitch, nConstant, dest.DevicePointerRoi, dest.Pitch, _sizeRoi);
     Debug.WriteLine(String.Format("{0:G}, {1}: {2}", DateTime.Now, "nppiAdd_8u_C3RSfs", status));
     NPPException.CheckNppStatus(status, this);
 }
Example #24
0
 /// <summary>
 /// image resize.
 /// </summary>
 /// <param name="dst">Destination-Image</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 void ResizeSqrPixel(NPPImage_8uC3 dst, double nXFactor, double nYFactor, double nXShift, double nYShift, InterpolationMode eInterpolation)
 {
     NppiRect srcRect = new NppiRect(_pointRoi, _sizeRoi);
     NppiRect dstRect = new NppiRect(dst.PointRoi, dst.SizeRoi);
     status = NPPNativeMethods.NPPi.ResizeSqrPixel.nppiResizeSqrPixel_8u_C3R(_devPtr, _sizeRoi, _pitch, srcRect, dst.DevicePointer, dst.Pitch, dstRect, nXFactor, nYFactor, nXShift, nYShift, eInterpolation);
     Debug.WriteLine(String.Format("{0:G}, {1}: {2}", DateTime.Now, "nppiResizeSqrPixel_8u_C3R", status));
     NPPException.CheckNppStatus(status, this);
 }
Example #25
0
 /// <summary>
 /// 3 channel 8-bit unsigned planar YCbCr411 to 3 channel 8-bit unsigned packed RGB 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 YCbCr411ToRGB(NPPImage_8uC1 src0, NPPImage_8uC1 src1, NPPImage_8uC1 src2, NPPImage_8uC3 dest)
 {
     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_P3C3R(arraySrc, arrayPitch, dest.DevicePointerRoi, dest.Pitch, dest.SizeRoi);
     Debug.WriteLine(String.Format("{0:G}, {1}: {2}", DateTime.Now, "nppiYCbCr411ToRGB_8u_P3C3R", status));
     NPPException.CheckNppStatus(status, null);
 }
Example #26
0
 /// <summary>
 /// Rotate images.
 /// </summary>
 /// <param name="dest">Destination image</param>
 /// <param name="nAngle">The angle of rotation in degrees.</param>
 /// <param name="nShiftX">Shift along horizontal axis</param>
 /// <param name="nShiftY">Shift along vertical axis</param>
 /// <param name="eInterpolation">Interpolation mode</param>
 public void Rotate(NPPImage_8uC3 dest, double nAngle, double nShiftX, double nShiftY, InterpolationMode eInterpolation)
 {
     status = NPPNativeMethods.NPPi.GeometricTransforms.nppiRotate_8u_C3R(_devPtr, _sizeRoi, _pitch, new NppiRect(_pointRoi, _sizeRoi),
         dest.DevicePointer, dest.Pitch, new NppiRect(dest.PointRoi, dest.SizeRoi), nAngle, nShiftX, nShiftY, eInterpolation);
     Debug.WriteLine(String.Format("{0:G}, {1}: {2}", DateTime.Now, "nppiRotate_8u_C3R", status));
     NPPException.CheckNppStatus(status, this);
 }
Example #27
0
		/// <summary>
		/// 16-bit unsigned to 8-bit unsigned conversion.
		/// </summary>
		/// <param name="dst">Destination image</param>
		public void Convert(NPPImage_8uC3 dst)
		{
			status = NPPNativeMethods.NPPi.BitDepthConversion.nppiConvert_16u8u_C3R(_devPtrRoi, _pitch, dst.DevicePointerRoi, dst.Pitch, _sizeRoi);
			Debug.WriteLine(String.Format("{0:G}, {1}: {2}", DateTime.Now, "nppiConvert_16u8u_C3R", status));
			NPPException.CheckNppStatus(status, this);
		}
Example #28
0
 /// <summary>
 /// horizontal Sobel filter.
 /// </summary>
 /// <param name="dst">Destination-Image</param>
 public void SobelHoriz(NPPImage_8uC3 dst)
 {
     status = NPPNativeMethods.NPPi.FixedFilters.nppiFilterSobelHoriz_8u_C3R(_devPtrRoi, _pitch, dst.DevicePointerRoi, dst.Pitch, _sizeRoi);
     Debug.WriteLine(String.Format("{0:G}, {1}: {2}", DateTime.Now, "nppiFilterSobelHoriz_8u_C3R", status));
     NPPException.CheckNppStatus(status, this);
 }
Example #29
0
		/// <summary>
		/// Swap channels.
		/// </summary>
		/// <param name="dest">Destination image</param>
		/// <param name="aDstOrder">Host memory integer array describing how channel values are permutated. The n-th entry
		/// of the array contains the number of the channel that is stored in the n-th channel of
		/// the output image. <para/>E.g. Given an RGBA image, aDstOrder = [2,1,0] converts this to a 3 channel BGR
		/// channel order.</param>
		public void SwapChannels(NPPImage_8uC3 dest, int[] aDstOrder)
		{
			status = NPPNativeMethods.NPPi.SwapChannel.nppiSwapChannels_8u_C4C3R(_devPtrRoi, _pitch, dest.DevicePointerRoi, dest.Pitch, _sizeRoi, aDstOrder);
			Debug.WriteLine(String.Format("{0:G}, {1}: {2}", DateTime.Now, "nppiSwapChannels_8u_C4C3R", status));
			NPPException.CheckNppStatus(status, this);
		}
Example #30
0
        /// <summary>
        /// Filters the image using a unsharp-mask sharpening filter kernel with border control.<para/>
        /// The algorithm involves the following steps:<para/>
        /// Smooth the original image with a Gaussian filter, with the width controlled by the nRadius.<para/>
        /// Subtract the smoothed image from the original to create a high-pass filtered image.<para/>
        /// Apply any clipping needed on the high-pass image, as controlled by the nThreshold.<para/>
        /// Add a certain percentage of the high-pass filtered image to the original image, 
        /// with the percentage controlled by the nWeight.
        /// In pseudocode this algorithm can be written as:<para/>
        /// HighPass = Image - Gaussian(Image)<para/>
        /// Result = Image + nWeight * HighPass * ( |HighPass| >= nThreshold ) <para/>
        /// where nWeight is the amount, nThreshold is the threshold, and >= indicates a Boolean operation, 1 if true, or 0 otherwise.
        /// <para/>
        /// If any portion of the mask overlaps the source image boundary, the requested border type 
        /// operation is applied to all mask pixels which fall outside of the source image.
        /// </summary>
        /// <param name="dst">Destination-Image</param>
        /// <param name="nRadius">The radius of the Gaussian filter, in pixles, not counting the center pixel.</param>
        /// <param name="nSigma">The standard deviation of the Gaussian filter, in pixel.</param>
        /// <param name="nWeight">The percentage of the difference between the original and the high pass image that is added back into the original.</param>
        /// <param name="nThreshold">The threshold needed to apply the difference amount.</param>
        /// <param name="eBorderType">The border type operation to be applied at source image border boundaries.</param>
        /// <param name="buffer">Pointer to the user-allocated device scratch buffer required for the unsharp operation.</param>
        public void FilterUnsharpBorder(NPPImage_8uC3 dst, float nRadius, float nSigma, float nWeight, float nThreshold, NppiBorderType eBorderType, CudaDeviceVariable<byte> buffer)
        {
            if (buffer.Size < FilterUnsharpGetBufferSize(nRadius, nSigma))
                throw new NPPException("Provided buffer is too small.");

            status = NPPNativeMethods.NPPi.FixedFilters.nppiFilterUnsharpBorder_8u_C3R(_devPtr, _pitch, _pointRoi, dst.DevicePointerRoi, dst.Pitch, _sizeRoi, nRadius, nSigma, nWeight, nThreshold, eBorderType, buffer.DevicePointer);
            Debug.WriteLine(String.Format("{0:G}, {1}: {2}", DateTime.Now, "nppiFilterUnsharpBorder_8u_C3R", status));
            NPPException.CheckNppStatus(status, this);
        }