0

I want to join the vertical and horizontal edges together to get all edges in an image in order to use it for the Harris Corner detection.

I'm using Sobel filters to get vertical and horizontal edges:

I = imread('CleanFingerprint.jpg'); // read the image
I = im2double(I); // convert it to double
G = rgb2gray(I); // convert it to gray

vert = [-1 -2 -1;
         0 0 0;
         1 2 1]* 0.25; // vertical filter

hor = [-1 0 1;
       -2 0 2;
       -1 0 1]* 0.25; // horizontal filter

OutputV = conv2(G, vert); // applying the filter to the image
OutputH = conv2(G, hor); 

It's working great. Then whenI try to join them together, and I use this formula:

// sqrt((OutputV^2) + (OutputH^2))
Output = OutputV ^2;
Output1 = OutputH ^2;

Output2 = Output + Output1;
Output3 = sqrt(Output2);

I get a very strange image. Any Suggestions

N4LN
  • 95
  • 3
  • 10
  • 2
    Not sure what you are exactly doing, but when you use OutputV^2, you are actually doing OutputV*OutputV, matrix multiplication. What you might want to do is OutputV.^2, that does OutputV.*OutputV, scalar product, which in this case will square each element of the matrix – Inox Mar 19 '14 at 14:07
  • Thanks Inox, It works now, I changed it to .^2 – N4LN Mar 19 '14 at 14:18

1 Answers1

0

You should use the "Per Pixel" square operation by:

Output = sqrt((OutputV .^ 2) + (OutputH .^ 2));

The you wrote it MATLAB executed a matrix multiplication (Instead of entry wise operation).

Royi
  • 4,640
  • 6
  • 46
  • 64