/// <summary> /// per element Divide /// </summary> /// <param name="src"></param> /// <param name="value"></param> /// <returns></returns> public static NppiPoint Divide(NppiPoint src, int value) { NppiPoint ret = new NppiPoint(src.x / value, src.y / value); return ret; }
/// <summary> /// per element Add /// </summary> /// <param name="src"></param> /// <param name="value"></param> /// <returns></returns> public static NppiPoint Add(int src, NppiPoint value) { NppiPoint ret = new NppiPoint(src + value.x, src + value.y); return ret; }
/// <summary> /// Erosion computes the output pixel as the minimum pixel value of the pixels under the mask. Pixels who’s /// corresponding mask values are zero to not participate in the maximum search, not affecting Alpha. /// </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 ErodeA(NPPImage_8uC4 dest, CudaDeviceVariable<byte> Mask, NppiSize aMaskSize, NppiPoint oAnchor) { status = NPPNativeMethods.NPPi.MorphologyFilter2D.nppiErode_8u_AC4R(_devPtrRoi, _pitch, dest.DevicePointerRoi, dest.Pitch, _sizeRoi, Mask.DevicePointer, aMaskSize, oAnchor); Debug.WriteLine(String.Format("{0:G}, {1}: {2}", DateTime.Now, "nppiErode_8u_AC4R", status)); NPPException.CheckNppStatus(status, this); }
/// <summary> /// per element Add /// </summary> /// <param name="src"></param> /// <param name="value"></param> /// <returns></returns> public static NppiRect Divide(NppiPoint src, NppiRect value) { NppiRect ret = new NppiRect(src.x / value.x, src.y / value.y, value.width, value.height); return ret; }
/// <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; }
/// <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; }
/// <summary> /// per element Add /// </summary> /// <param name="src"></param> /// <param name="value"></param> /// <returns></returns> public static NppiRect Subtract(NppiPoint src, NppiRect value) { NppiRect ret = new NppiRect(src.x - value.x, src.y - value.y, value.width, value.height); return ret; }
/// <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); }
/// <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); }
/// <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); }
/// <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); }
/// <summary> /// Computes the average pixel values of the pixels under a rectangular mask. Not affecting Alpha. /// </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> public void FilterBoxA(NPPImage_8uC4 dest, NppiSize oMaskSize, NppiPoint oAnchor) { status = NPPNativeMethods.NPPi.LinearFixedFilters2D.nppiFilterBox_8u_AC4R(_devPtrRoi, _pitch, dest.DevicePointerRoi, dest.Pitch, _sizeRoi, oMaskSize, oAnchor); Debug.WriteLine(String.Format("{0:G}, {1}: {2}", DateTime.Now, "nppiFilterBox_8u_AC4R", status)); NPPException.CheckNppStatus(status, this); }
/// <summary> /// Pixels under the mask are multiplied by the respective weights in the mask and the results are summed.<para/> /// Before writing the result pixel the sum is scaled back via division by nDivisor. Not affecting Alpha. /// </summary> /// <param name="dest">Destination image</param> /// <param name="Kernel">Pointer to the start address of the kernel coefficient array. Coeffcients are expected to be stored in reverse order.</param> /// <param name="aKernelSize">Width and Height of the rectangular kernel.</param> /// <param name="oAnchor">X and Y offsets of the kernel origin frame of reference w.r.t the source pixel.</param> /// <param name="nDivisor">The factor by which the convolved summation from the Filter operation should be divided. If equal to the sum of coefficients, this will keep the maximum result value within full scale.</param> public void FilterA(NPPImage_8uC4 dest, CudaDeviceVariable<int> Kernel, NppiSize aKernelSize, NppiPoint oAnchor, int nDivisor) { status = NPPNativeMethods.NPPi.Convolution.nppiFilter_8u_AC4R(_devPtrRoi, _pitch, dest.DevicePointerRoi, dest.Pitch, _sizeRoi, Kernel.DevicePointer, aKernelSize, oAnchor, nDivisor); Debug.WriteLine(String.Format("{0:G}, {1}: {2}", DateTime.Now, "nppiFilter_8u_AC4R", status)); NPPException.CheckNppStatus(status, this); }
/// <summary> /// Erosion computes the output pixel as the minimum 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, ignoring alpha-channel. /// </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 ErodeBorderA(NPPImage_8uC4 dest, CudaDeviceVariable<byte> Mask, NppiSize aMaskSize, NppiPoint oAnchor, NppiBorderType eBorderType) { status = NPPNativeMethods.NPPi.ErosionWithBorderControl.nppiErodeBorder_8u_AC4R(_devPtr, _pitch, _sizeOriginal, _pointRoi, dest.DevicePointerRoi, dest.Pitch, _sizeRoi, Mask.DevicePointer, aMaskSize, oAnchor, eBorderType); Debug.WriteLine(String.Format("{0:G}, {1}: {2}", DateTime.Now, "nppiErodeBorder_8u_AC4R", status)); NPPException.CheckNppStatus(status, this); }
/// <summary> /// per element Divide /// </summary> /// <param name="src"></param> /// <param name="value"></param> /// <returns></returns> public static NppiPoint Divide(int src, NppiPoint value) { NppiPoint ret = new NppiPoint(src / value.x, src / value.y); return ret; }
/// <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); }
/// <summary> /// /// </summary> /// <param name="value"></param> /// <returns></returns> public bool Equals(NppiPoint value) { bool ret = true; ret &= this.x == value.x; ret &= this.y == value.y; return ret; }
/// <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; }
/// <summary> /// per element Add /// </summary> /// <param name="src"></param> /// <param name="value"></param> /// <returns></returns> public static NppiRect Add(NppiPoint src, NppiRect value) { NppiRect ret = new NppiRect(src.x + value.x, src.y + value.y, value.width, value.height); return ret; }
/// <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; }
/// <summary> /// per element Add /// </summary> /// <param name="src"></param> /// <param name="value"></param> /// <returns></returns> public static NppiRect Multiply(NppiPoint src, NppiRect value) { NppiRect ret = new NppiRect(src.x * value.x, src.y * value.y, value.width, value.height); return ret; }
/// <summary> /// per element Multiply /// </summary> /// <param name="src"></param> /// <param name="value"></param> /// <returns></returns> public static NppiPoint Multiply(NppiPoint src, int value) { NppiPoint ret = new NppiPoint(src.x * value, src.y * value); return ret; }
/// <summary> /// Determines if the specified point is contained within this Rectangle structure. /// </summary> /// <param name="point"></param> /// <returns></returns> public bool Contains(NppiPoint point) { return (point.x >= Left) && (point.x <= Right) && (point.y >= Top) && (point.y <= Bottom); }
/// <summary> /// per element Multiply /// </summary> /// <param name="src"></param> /// <param name="value"></param> /// <returns></returns> public static NppiPoint Multiply(int src, NppiPoint value) { NppiPoint ret = new NppiPoint(src * value.x, src * value.y); return ret; }
/// <summary> /// per element Add /// </summary> /// <param name="src"></param> /// <param name="value"></param> /// <returns></returns> public static NppiPoint Add(NppiPoint src, int value) { NppiPoint ret = new NppiPoint(src.x + value, src.y + value); return ret; }
/// <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; }
/// <summary> /// per element Substract /// </summary> /// <param name="src"></param> /// <param name="value"></param> /// <returns></returns> public static NppiPoint Subtract(NppiPoint src, NppiPoint value) { NppiPoint ret = new NppiPoint(src.x - value.x, src.y - value.y); return ret; }
/// <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> public void FilterMax(NPPImage_16uC3 dest, NppiSize oMaskSize, NppiPoint oAnchor) { status = NPPNativeMethods.NPPi.RankFilters.nppiFilterMax_16u_C3R(_devPtrRoi, _pitch, dest.DevicePointerRoi, dest.Pitch, _sizeRoi, oMaskSize, oAnchor); Debug.WriteLine(String.Format("{0:G}, {1}: {2}", DateTime.Now, "nppiFilterMax_16u_C3R", status)); NPPException.CheckNppStatus(status, this); }