user3396218
user3396218

Reputation: 255

How to plot field orientation map? I have the gradients. OpenCV C++

I used the Scharr filter and I have the x and y gradients from here. May I know how I can plot the orientation map from here? Here's the picture of my Scharr filter result. It's a fingerprint image.

And this is the code i used.

Mat src,grad;
Mat grad_x,grad_y;
Mat abs_grad_x,abs_grad_y;

int scale=1;
int delta=0;
int ddepth=CV_16S;
int c;
src=cv::imread("remove_noise.bmp",CV_LOAD_IMAGE_UNCHANGED);

Scharr(src,grad_x,ddepth,1,0,scale,delta,BORDER_DEFAULT);
convertScaleAbs(grad_x,abs_grad_x);
Scharr( src, grad_y, ddepth, 0, 1, scale, delta, BORDER_DEFAULT );
convertScaleAbs(grad_y,abs_grad_y);

addWeighted(abs_grad_x,0.5,abs_grad_y,0.5,0,grad);
cv::imwrite("SobelScharr.bmp",grad);

Upvotes: 0

Views: 1167

Answers (1)

Ritesh
Ritesh

Reputation: 256

I have implemented ridge orientation few months back using matlab..i have used velocity plot for plotting ridges..i don't have knowledge on opencv..I assume this might help you..here is my code..

% Orientation vectors
        vec_u = len/2*cos(p_theta);
        vec_u = filter2(smooth,vec_u);
        vec_v = len/2*sin(p_theta);
        vec_v = filter2(smooth,vec_v);

        quiver(x,y,vec_u,vec_v,0,'.','linewidth',1.2, 'color','k');
    %     imshow('FillValues',255);
       axis equal,axis ij,axis off; hold off;

This might also help you..

www.mathworks.com/help/matlab/ref/quiver.html‎

Upvotes: 1

Related Questions