我有我的代码是关于sobel操作的
        Image<Gray, double> test_x= new Image<Gray, double>(img_gray.Size);
        Image<Gray, double> test_y = new Image<Gray, double>(img_gray.Size);
        Image<Gray, byte> final = new Image<Gray, byte>(img_gray.Size);
        CvInvoke.Sobel(img_gray, test_x, DepthType.Cv64F,1,0);
        CvInvoke.Sobel(img_gray, test_y, DepthType.Cv64F, 0, 1);
        for (int x = 0; x < img_gray.Cols; x++)
        {
            for (int y = 0; y < img_gray.Rows; y++)
            {
                double mag = Math.Pow(test_x[y, x].Intensity, 2) + Math.Pow(test_y[y, x].Intensity, 2);
                mag = Math.Sqrt(mag);
                if (mag > 125)
                {
                    final[y, x] = new Gray(255);
                }
                else
                {
                    final[y, x] = new Gray(0);
                }
            }
        }
        imageBox2.Image = final;这段代码花了很长时间向我展示结果。
opencv中是否有任何函数来计算所有像素的大小,而不访问所有像素的for循环。
谢谢:)
发布于 2020-02-28 08:16:14
EmguCv有一个函数。有多快我就让你来决定
Image<Gray, double> test_x= new Image<Gray, double>(img_gray.Size);
Image<Gray, double> test_y = new Image<Gray, double>(img_gray.Size);
CudaImage<Gray, double> final = new CudaImage<Gray, double>(img_gray.Size);
CvInvoke.Sobel(img_gray, test_x, DepthType.Cv64F,1,0);
CvInvoke.Sobel(img_gray, test_y, DepthType.Cv64F, 0, 1);
CudaImage<Gray, double> xCuda = new CudaImage<Gray, double>(test_x);
CudaImage<Gray, double> yCuda = new CudaImage<Gray, double>(test_y);
CudaInvoke.Magnitude(xCuda, yCuda, final);发布于 2020-02-28 08:15:00
是的,“履历::规模”:
计算二维矢量的大小。C++:虚空震级( InputArray x,InputArray y,OutputArray震级) Python: cv2.等(x,y,震级)→震级参数:x-浮点阵x-矢量坐标。矢量的y-坐标的y浮点数组;它必须具有与x相同的大小和类型的数量级输出阵列。函数大小计算由x和y阵列的相应元素形成的2D矢量的大小:
检查此链接:https://docs.opencv.org/2.4/modules/core/doc/operations_on_arrays.html#magnitude
https://stackoverflow.com/questions/60447588
复制相似问题