I am about to write a java program which can smooth an image (2D Array) by a 3 by 3 mask and hesitate about which of the following strategies is right for application of the mask to the image:
1- Apply the mask to a portion of the image and immediately change the target pixel in the original image and move the mask to calculate the value of the next target pixel and so on.
2- Copy the original image into another backup image, then apply the mask to a portion of the original image and then change the target pixel in the copy image instead of original image.
In the second way, the original image would not change during the application of mask; only the new values are inserted into the backup image during smoothing. So the backup image will contain the smoothed image. Thanks.