مقایسه دستور fspecial disk و fspecial motion
با استفاده از یک برنامه کوچک به صورت عملی تفاوت دستورات fspecial disk و fspecial motion را نشان خواهیم داد.
هدف از مقایسه این دو فیلتر این است که بفهمیم کدام یک برای تار کردن تصویر مناسب تر است.
'disk' : Circular averaging filter (pillbox)
h = fspecial('disk', radius) returns a circular averaging filter (pillbox) within the square matrix of side 2*radius+1. The default radius is 5.
'motion' :Approximates the linear motion of a camera
h = fspecial('motion', len, theta) returns a filter to approximate, once convolved with an image, the linear motion of a camera by len pixels, with an angle of theta degrees in a counterclockwise direction. The filter becomes a vector for horizontal and vertical motions. The default len is 9 and the default theta is 0, which corresponds to a horizontal motion of nine pixels.
To compute the filter coefficients, h, for 'motion':
Construct an ideal line segment with the desired length and angle, centered at the center coefficient of h.
For each coefficient location (i,j), compute the nearest distance between that location and the ideal line segment.
h = max(1 - nearest_distance, 0);
Normalize h:h = h/(sum(h(:))