예제 #1
0
        public void FourierFilter(NPPImage_32fC1 img, int clearAxis, float aHighPass, float aHighPassSigma)
        {
            forward.Exec(img.DevicePointerRoi, imgToTrackCplx.DevicePointer);
            fourierFilterKernel.RunSafe(imgToTrackCplx, width, height, clearAxis, 1, aHighPass, 1, aHighPassSigma);
            backward.Exec(imgToTrackCplx.DevicePointer, img.DevicePointerRoi);
            img.Div(img.WidthRoi * img.HeightRoi);
            CudaDeviceVariable <float> minVal = new CudaDeviceVariable <float>(x.DevicePointer, 4);
            CudaDeviceVariable <float> maxVal = new CudaDeviceVariable <float>(y.DevicePointer, 4);

            img.MinMax(minVal, maxVal, buffer);
            float min = minVal;
            float max = maxVal;

            img.ThresholdLTGT(0, 0, 1, 1);
        }
예제 #2
0
        public (int, int) TestCC(NPPImage_32fC1 img, int shiftX, int shiftY)
        {
            Matrix3x3 mat = Matrix3x3.ShiftAffine(shiftX, shiftY);

            img.WarpAffine(imgToTrackRotated, mat.ToAffine(), InterpolationMode.NearestNeighbor);

            forward.Exec(imgToTrackRotated.DevicePointerRoi, imgToTrackCplx.DevicePointer);
            conjKernel.RunSafe(imgRefCplx, imgToTrackCplx);
            fftshiftKernel.RunSafe(imgToTrackCplx, width, height);
            backward.Exec(imgToTrackCplx.DevicePointer, img.DevicePointerRoi);
            img.Div(img.WidthRoi * img.HeightRoi);

            img.MaxIndex(val, x, y);

            float v  = val;
            int   hx = x;
            int   hy = y;

            hx -= imgToTrackRotated.WidthRoi / 2;
            hy -= imgToTrackRotated.HeightRoi / 2;


            CudaDeviceVariable <float> minVal = new CudaDeviceVariable <float>(x.DevicePointer, 4);
            CudaDeviceVariable <float> maxVal = new CudaDeviceVariable <float>(y.DevicePointer, 4);

            img.MinMax(minVal, maxVal, buffer);
            float min = minVal;
            float max = maxVal;

            img.Sub(min);
            img.Div(max - min);


            img.ThresholdLTGT(0, 0, 1, 1);

            return(hx, hy);
        }