0

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.

Mohammadreza
  • 450
  • 2
  • 4
  • 14
  • If this is for Java then please tag your question "java", thanks. – RenniePet Oct 05 '14 at 01:32
  • Also, what exactly do you mean by "smoothing" an image? And the "smoothing" tag may not be applicable to your question, it seems to be concerned with statistical smoothing. Or is image smoothing and statistical smoothing the same thing? – RenniePet Oct 05 '14 at 01:35
  • Yes. Image smoothing is actually a statistical smoothing, Especially when you are dealing with an image as a 2D array it would be nothing except some statistical manipulation. – Mohammadreza Oct 05 '14 at 01:51
  • Any idea please? Is my question clear enough? – Mohammadreza Oct 07 '14 at 04:22
  • Don't have any knowledge of this area, sorry. I notice only 14 people have viewed your question, don't know why so few. You could maybe add "image-processing" tag instead of just "image", that is more specific, and also when you edit your question it reappears on the front page. – RenniePet Oct 07 '14 at 04:49

1 Answers1

0

Does not feel so good to answer my own question but in the spirit of helping others that have an image processing course and work with binary images, my experience might be helpful. After doing some trial-and-error experiments, I found that actually the second way is the right way and the first one is Wrong. Because changing the original values of a matrix while you are scanning it (at the same time) will lead to an inconsistency. I mean you will have a messed matrix at the end which won't maintain the original shape and instead of smoothing (removing noise pixels) it is just scrambling and ruining the original image. So, first I had to copy the original matrix and in each step of applying the mask, I just changed the target value in the copy matrix. Finally, the copied matrix would be your smoothed binary image.

Mohammadreza
  • 450
  • 2
  • 4
  • 14