Blur Sharpen 0 1 0 0 -1 0 1 5 1 -1 5 -1 0 1 0 0 -1 0The **Apply** button applies the filter kernel to the image. At a minimum, the button need only apply the filter kernel if the sum of the filter kernel weights is a positive value. For example, if the user enters 0 for all the filter weights, applying the filter can produce unpredictable results. The weights in the array specifying the filter kernel should sum to 1. Since the blur filter kernel has values that sum to 9 (0+1+0+1+5+1+0+1+0), each value must be divided by 9. The following code applies the **Blur** filter kernel: ``` double[] kernel = { 0.0, 1.0/9, 0.0, 1.0/9, 5.0/9, 1.0/9, 0.0, 1.0/9, 0.0}; Image blurredImage = ImageUtil.convolve(originalImage, kernel); ``` The values for filter kernel for **Sharpen** sum to 1 (5-1-1-1-1) so the weights in the array here would be: ``` double[] kernel = { 0.0, -1.0, 0.0, -1.0, 5.0, -1.0, 0.0, -1.0, 0.0}; ```
2) This is a slight simplification from the actual transformation. You may chose to implement the actual transformation, if you choose to (you'll need to look it up). Be sure to indicate with a comment if you choose to do this.
3) You may choose to make a 5 x 5, 7 x 7, or 9 x 9 grid instead.