Matlab gradient equivalent in opencv

前端 未结 5 950
感情败类
感情败类 2020-12-10 21:54

I am trying to migrate some code from Matlab to Opencv and need an exact replica of the gradient function. I have tried the cv::Sobel function but for some reason the values

5条回答
  •  感情败类
    2020-12-10 22:37

    You have to call Sobel 2 times, with arguments:

    xorder = 1, yorder = 0
    

    and

    xorder = 0, yorder = 1
    

    You have to select the appropriate kernel size.

    See documentation

    It might still be that the MatLab implementation was different, ideally you should retrieve which kernel was used there...

    Edit:

    If you need to specify your own kernel, you can use the more generic filter2D. Your destination depth will be CV_16S (16bit signed).

提交回复
热议问题