364 A Computational Introduction to Digital Image Processing, Second Edition
FIGURE 12.7: Boundary pixels
Note that as this transform is not shifted, the first term will be the DC coefficient, and low
frequency terms occur after the DC coefficient, and at the end. What we can do is pick a
value k, and keep k terms after the DC coefficient, and at the end:
MATLAB/Octave
>> k = 2
>> cf2 = cf;
>> N = len(cf);
>> cf2(k+2:N-k) = 0;
At this stage, 9 of the original 14 values have been removed. They can be plotted with lines
and points, and to ensure the lines meet up the first values will b e repeated as the last:
MATLAB/Octave
>> bdy2 = ifft(cf2);
>> bdy2 = [bdy2;bdy2(1,:)];
>> plot(bdy2,’.-’,"markersize",10),axis([1,7,1,6]),axis equal
The result is shown in Figure 12.8(a).
Images (b) and (c) show the result by keeping a few more pairs of transform values.
However even with k = 2 there is enough information to gauge the size and rough shape of
the object; and with k = 4 (five transf orm values removed) the result is very close.
Recall that in an unshifted transform, the DC coefficient is at the start, and the high
frequency values are toward the middle, as shown in Figure 12.9.
In this figure, the arrows give the direction of increasing frequency; the elements labeled
X and Y are those of highest frequency. Around those central values, and excluding the
DC coefficient, all other elements can be paired together with equal frequencies, as shown.