我有关于索贝尔手术的代码
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循环
谢谢:)
是,'cv :: magnitude'检查此链接https://docs.opencv.org/2.4/modules/core/doc/operations_on_arrays.html#magnitude
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);
Image<Gray, double> final = new Image<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);
CvInvoke.Magnitude(test_x, test_y, final);