gpt4 book ai didi

opencv - 有功能计算两个图像中所有像素的大小吗?

转载 作者:行者123 更新时间:2023-12-02 17:24:07 25 4
gpt4 key购买 nike

我有关于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循环

谢谢 :)

最佳答案

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);

关于opencv - 有功能计算两个图像中所有像素的大小吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60447588/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com