Esempio n. 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);
 }
Esempio n. 2
0
		/// <summary>
		/// 
		/// </summary>
		/// <param name="size">Graph size</param>
		public GraphCut4(NppiSize size)
		{
			_size = size;
			int bufferSize = 0;
			status = NPPNativeMethods.NPPi.ImageLabeling.nppiGraphcutGetSize(_size, ref bufferSize);
			Debug.WriteLine(String.Format("{0:G}, {1}: {2}", DateTime.Now, "nppiGraphcutGetSize", status));
			NPPException.CheckNppStatus(status, this);

			_buffer = new CudaDeviceVariable<byte>(bufferSize);

			_state = new NppiGraphcutState();
			status = NPPNativeMethods.NPPi.ImageLabeling.nppiGraphcutInitAlloc(_size, ref _state, _buffer.DevicePointer);
			Debug.WriteLine(String.Format("{0:G}, {1}: {2}", DateTime.Now, "nppiGraphcutInitAlloc", status));
			NPPException.CheckNppStatus(status, this);
		}
Esempio n. 3
0
		/// <summary>
		/// Reduces this Rectangle by the specified amount.
		/// </summary>
		/// <param name="val"></param>
		public void Deflate(NppiSize val)
		{
			Deflate(val.width, val.height);
		}
Esempio n. 4
0
		/// <summary>
		/// per element Add
		/// </summary>
		/// <param name="src"></param>
		/// <param name="value"></param>
		/// <returns></returns>
		public static NppiRect Divide(NppiSize src, NppiRect value)
		{
			NppiRect ret = new NppiRect(value.x, value.y, src.width / value.width, src.height / value.height);
			return ret;
		}
Esempio n. 5
0
		/// <summary>
		/// per element Add
		/// </summary>
		/// <param name="src"></param>
		/// <param name="value"></param>
		/// <returns></returns>
		public static NppiRect Subtract(NppiSize src, NppiRect value)
		{
			NppiRect ret = new NppiRect(value.x, value.y, src.width - value.width, src.height - value.height);
			return ret;
		}
Esempio n. 6
0
		/// <summary>
		/// Non-default constructor
		/// </summary>
		/// <param name="aPoint"></param>
		/// <param name="aSize"></param>
		public NppiRect(NppiPoint aPoint, NppiSize aSize)
		{
			x = aPoint.x;
			y = aPoint.y;
			width = aSize.width;
			height = aSize.height;
		}
Esempio n. 7
0
		/// <summary>
		/// per element Divide
		/// </summary>
		/// <param name="src"></param>
		/// <param name="value"></param>
		/// <returns></returns>
		public static NppiSize Divide(int src, NppiSize value)
		{
			NppiSize ret = new NppiSize(src / value.width, src / value.height);
			return ret;
		}
Esempio n. 8
0
		/// <summary>
		/// per element Multiply
		/// </summary>
		/// <param name="src"></param>
		/// <param name="value"></param>
		/// <returns></returns>
		public static NppiSize Multiply(int src, NppiSize value)
		{
			NppiSize ret = new NppiSize(src * value.width, src * value.height);
			return ret;
		}
Esempio n. 9
0
		/// <summary>
		/// convolution filter.
		/// </summary>
		/// <param name="dst">Destination-Image</param>
		/// <param name="pKernel">Pointer to the start address of the kernel coefficient array.<para/>
		/// Coefficients are expected to be stored in reverse order.</param>
		/// <param name="oKernelSize">Width and Height of the rectangular kernel.</param>
		/// <param name="oAnchor">X and Y offsets of the kernel origin frame of reference</param>
		public void Filter(NPPImage_32sC4 dst, CudaDeviceVariable<float> pKernel, NppiSize oKernelSize, NppiPoint oAnchor)
		{
			status = NPPNativeMethods.NPPi.Convolution.nppiFilter32f_32s_C4R(_devPtrRoi, _pitch, dst.DevicePointerRoi, dst.Pitch, _sizeRoi, pKernel.DevicePointer, oKernelSize, oAnchor);
			Debug.WriteLine(String.Format("{0:G}, {1}: {2}", DateTime.Now, "nppiFilter32f_32s_C4R", status));
			NPPException.CheckNppStatus(status, this);
		}
Esempio n. 10
0
		/// <summary>
		/// Creates a new NPPImage from allocated device ptr.
		/// </summary>
		/// <param name="devPtr">Already allocated device ptr.</param>
		/// <param name="size">Image size</param>
		/// <param name="pitch">Pitch / Line step</param>
		public NPPImage_32sC4(CUdeviceptr devPtr, NppiSize size, int pitch)
			: this(devPtr, size.width, size.height, pitch)
		{

		}
Esempio n. 11
0
		/// <summary>
		/// Allocates new memory on device using NPP-Api.
		/// </summary>
		/// <param name="size">Image size</param>
		public NPPImage_32sC4(NppiSize size)
			: this(size.width, size.height)
		{ 
			
		}
Esempio n. 12
0
		/// <summary>
		/// Result pixel value is the maximum of pixel values under the rectangular mask region.
		/// </summary>
		/// <param name="dest">Destination image</param>
		/// <param name="oMaskSize">Width and Height of the neighborhood region for the local Avg operation.</param>
		/// <param name="oAnchor">X and Y offsets of the kernel 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 FilterMaxBorderA(NPPImage_8uC4 dest, NppiSize oMaskSize, NppiPoint oAnchor, NppiBorderType eBorderType)
		{
			status = NPPNativeMethods.NPPi.RankFilters.nppiFilterMaxBorder_8u_AC4R(_devPtr, _pitch, _sizeOriginal, _pointRoi, dest.DevicePointerRoi, dest.Pitch, _sizeRoi, oMaskSize, oAnchor, eBorderType);
			Debug.WriteLine(String.Format("{0:G}, {1}: {2}", DateTime.Now, "nppiFilterMaxBorder_8u_AC4R", status));
			NPPException.CheckNppStatus(status, this);
		}
Esempio n. 13
0
		/// <summary>
		/// Device scratch buffer size (in bytes) for FilterMedian, ignoring alpha channel.
		/// </summary>
		/// <returns></returns>
		public int FilterMedianGetBufferHostSizeA(NppiSize oMaskSize)
		{
			uint bufferSize = 0;
			status = NPPNativeMethods.NPPi.ImageMedianFilter.nppiFilterMedianGetBufferSize_8u_AC4R(_sizeRoi, oMaskSize, ref bufferSize);
			Debug.WriteLine(String.Format("{0:G}, {1}: {2}", DateTime.Now, "nppiFilterMedianGetBufferSize_8u_AC4R", status));
			NPPException.CheckNppStatus(status, this);
			return (int)bufferSize; //We stay consistent with other GetBufferHostSize functions and convert to int.
		}
Esempio n. 14
0
		/// <summary>
		/// Result pixel value is the median of pixel values under the rectangular mask region, ignoring alpha channel.
		/// </summary>
		/// <param name="dst">Destination-Image</param>
		/// <param name="oMaskSize">Width and Height of the neighborhood region for the local Median operation.</param>
		/// <param name="oAnchor">X and Y offsets of the kernel origin frame of reference relative to the source pixel.</param>
		/// <param name="buffer">Pointer to the user-allocated scratch buffer required for the Median operation.</param>
		public void FilterMedianA(NPPImage_8uC4 dst, NppiSize oMaskSize, NppiPoint oAnchor, CudaDeviceVariable<byte> buffer)
		{
			int bufferSize = FilterMedianGetBufferHostSizeA(oMaskSize);
			if (bufferSize > buffer.Size) throw new NPPException("Provided buffer is too small.");

			status = NPPNativeMethods.NPPi.ImageMedianFilter.nppiFilterMedian_8u_AC4R(_devPtrRoi, _pitch, dst.DevicePointerRoi, dst.Pitch, _sizeRoi, oMaskSize, oAnchor, buffer.DevicePointer);
			Debug.WriteLine(String.Format("{0:G}, {1}: {2}", DateTime.Now, "nppiFilterMedian_8u_AC4R", status));
			NPPException.CheckNppStatus(status, this);
		}
Esempio n. 15
0
		/// <summary>
		/// Result pixel value is the median of pixel values under the rectangular mask region.
		/// </summary>
		/// <param name="dst">Destination-Image</param>
		/// <param name="oMaskSize">Width and Height of the neighborhood region for the local Median operation.</param>
		/// <param name="oAnchor">X and Y offsets of the kernel origin frame of reference relative to the source pixel.</param>
		public void FilterMedian(NPPImage_8uC4 dst, NppiSize oMaskSize, NppiPoint oAnchor)
		{
			int bufferSize = FilterMedianGetBufferHostSize(oMaskSize);
			CudaDeviceVariable<byte> buffer = new CudaDeviceVariable<byte>(bufferSize);
			status = NPPNativeMethods.NPPi.ImageMedianFilter.nppiFilterMedian_8u_C4R(_devPtrRoi, _pitch, dst.DevicePointerRoi, dst.Pitch, _sizeRoi, oMaskSize, oAnchor, buffer.DevicePointer);
			Debug.WriteLine(String.Format("{0:G}, {1}: {2}", DateTime.Now, "nppiFilterMedian_8u_C4R", status));
			buffer.Dispose();
			NPPException.CheckNppStatus(status, this);
		}
Esempio n. 16
0
		/// <summary>
		/// per element Substract
		/// </summary>
		/// <param name="src"></param>
		/// <param name="value"></param>
		/// <returns></returns>
		public static NppiSize Subtract(int src, NppiSize value)
		{
			NppiSize ret = new NppiSize(src - value.width, src - value.height);
			return ret;
		}
Esempio n. 17
0
		/// <summary>
		/// per element Multiply
		/// </summary>
		/// <param name="src"></param>
		/// <param name="value"></param>
		/// <returns></returns>
		public static NppiSize Multiply(NppiSize src, int value)
		{
			NppiSize ret = new NppiSize(src.width * value, src.height * value);
			return ret;
		}
Esempio n. 18
0
		/// <summary>
		/// Four channel 32-bit signed convolution filter with border control, ignoring alpha channel.<para/>
		/// General purpose 2D convolution filter using floating-point weights with border control.<para/>
		/// Pixels under the mask are multiplied by the respective weights in the mask
		/// and the results are summed. Before writing the result pixel the sum is scaled
		/// back via division by nDivisor. 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. <para/>
		/// </summary>
		/// <param name="dest">Destination image</param>
		/// <param name="pKernel">Pointer to the start address of the kernel coefficient array. Coeffcients are expected to be stored in reverse order</param>
		/// <param name="nKernelSize">Width and Height of the rectangular kernel.</param>
		/// <param name="oAnchor">X and Y offsets of the kernel origin frame of reference relative to the source pixel.</param>
		/// <param name="eBorderType">The border type operation to be applied at source image border boundaries.</param>
		public void FilterBorderA(NPPImage_32sC4 dest, CudaDeviceVariable<float> pKernel, NppiSize nKernelSize, NppiPoint oAnchor, NppiBorderType eBorderType)
		{
			status = NPPNativeMethods.NPPi.FilterBorder32f.nppiFilterBorder32f_32s_AC4R(_devPtr, _pitch, _sizeOriginal, _pointRoi, dest.DevicePointerRoi, dest.Pitch, dest.SizeRoi, pKernel.DevicePointer, nKernelSize, oAnchor, eBorderType);
			Debug.WriteLine(String.Format("{0:G}, {1}: {2}", DateTime.Now, "nppiFilterBorder32f_32s_AC4R", status));
			NPPException.CheckNppStatus(status, this);
		}
Esempio n. 19
0
		/// <summary>
		/// per element Divide
		/// </summary>
		/// <param name="src"></param>
		/// <param name="value"></param>
		/// <returns></returns>
		public static NppiSize Divide(NppiSize src, int value)
		{
			NppiSize ret = new NppiSize(src.width / value, src.height / value);
			return ret;
		}
Esempio n. 20
0
		/// <summary>
		/// per element Substract
		/// </summary>
		/// <param name="src"></param>
		/// <param name="value"></param>
		/// <returns></returns>
		public static NppiPoint Subtract(NppiPoint src, NppiSize value)
		{
			NppiPoint ret = new NppiPoint(src.x - value.width, src.y - value.height);
			return ret;
		}
Esempio n. 21
0
		/// <summary>
		/// 
		/// </summary>
		/// <param name="value"></param>
		/// <returns></returns>
		public bool Equals(NppiSize value)
		{
			bool ret = true;
			ret &= this.width == value.width;
			ret &= this.height == value.height;
			return ret;
		}
Esempio n. 22
0
		/// <summary>
		/// per element Multiply
		/// </summary>
		/// <param name="src"></param>
		/// <param name="value"></param>
		/// <returns></returns>
		public static NppiPoint Multiply(NppiPoint src, NppiSize value)
		{
			NppiPoint ret = new NppiPoint(src.x * value.width, src.y * value.height);
			return ret;
		}
Esempio n. 23
0
		/// <summary>
		/// per element Add
		/// </summary>
		/// <param name="src"></param>
		/// <param name="value"></param>
		/// <returns></returns>
		public static NppiRect Add(NppiSize src, NppiRect value)
		{
			NppiRect ret = new NppiRect(value.x, value.y, src.width + value.width, src.height + value.height);
			return ret;
		}
Esempio n. 24
0
		/// <summary>
		/// per element Divide
		/// </summary>
		/// <param name="src"></param>
		/// <param name="value"></param>
		/// <returns></returns>
		public static NppiPoint Divide(NppiPoint src, NppiSize value)
		{
			NppiPoint ret = new NppiPoint(src.x / value.width, src.y / value.height);
			return ret;
		}
Esempio n. 25
0
		/// <summary>
		/// per element Add
		/// </summary>
		/// <param name="src"></param>
		/// <param name="value"></param>
		/// <returns></returns>
		public static NppiRect Multiply(NppiSize src, NppiRect value)
		{
			NppiRect ret = new NppiRect(value.x, value.y, src.width * value.width, src.height * value.height);
			return ret;
		}
Esempio n. 26
0
		/// <summary>
		/// per element Add
		/// </summary>
		/// <param name="src"></param>
		/// <param name="value"></param>
		/// <returns></returns>
		public static NppiSize Add(NppiSize src, int value)
		{
			NppiSize ret = new NppiSize(src.width + value, src.height + value);
			return ret;
		}
Esempio n. 27
0
		/// <summary>
		/// Enlarges this Rectangle by the specified amount.
		/// </summary>
		/// <param name="val"></param>
		public void Inflate(NppiSize val)
		{
			Inflate(val.width, val.height);
		}
Esempio n. 28
0
		/// <summary>
		/// per element Add
		/// </summary>
		/// <param name="src"></param>
		/// <param name="value"></param>
		/// <returns></returns>
		public static NppiSize Add(int src, NppiSize value)
		{
			NppiSize ret = new NppiSize(src + value.width, src + value.height);
			return ret;
		}
Esempio n. 29
0
		/// <summary>
		/// per element Add
		/// </summary>
		/// <param name="src"></param>
		/// <param name="value"></param>
		/// <returns></returns>
		public static NppiPoint Add(NppiPoint src, NppiSize value)
		{
			NppiPoint ret = new NppiPoint(src.x + value.width, src.y + value.height);
			return ret;
		}
Esempio n. 30
0
		/// <summary>
		/// per element Substract
		/// </summary>
		/// <param name="src"></param>
		/// <param name="value"></param>
		/// <returns></returns>
		public static NppiSize Subtract(NppiSize src, int value)
		{
			NppiSize ret = new NppiSize(src.width - value, src.height - value);
			return ret;
		}