# Which kernel produces sharper image

kernel A =

[ 0 -1 0 -1 4 -1   0 -1 0 ]

and B =
[-1 0 -1  0 4 0 -1 0 -1 ]

i have found the frequency spectrums with freqz2 function of Matlab.

A's spectrum has the highest magnitudes in the corners (1,1),(-1,-1),(1,-1),(-1,1) and B's in (1,0),(0,1),(-1,0),(0,-1).

I know that the center of the frequency spectrum has the low frequency information and the corners the high frequency information such as edges. It appears that B filter produces a sharper image although A has higher magnitude in the corners. Why is this happening ?

The sharpness of an image depends on acutance and resolution. The quantification of image sharpness seems image content dependent to me, since (i) sometimes the noise at the low SNR region may be enhanced with an high-pass kernel, and (ii) your A and B work on the edges with different orientations.

Take a very simple example:

T = [1 0 1;...
0 1 0;...
1 0 1];


conv(T,A,'same') gives you

   [4  -3  4;...
-3  4  -3;...
4  -3  4];


while conv(T,B,'same') results in:

   [3 0 3;...
0 0 0;...
3 0 3];


Looks like kernel A is better in sharpening the 45 degree edges. Yet with

  T = [0 1 0;...
1 1 1;...
0 1 0];


The performance of two kernels looks reversed (B appears to be better in horizontal and vertical edges enhancement).