[Webinar] Streamline your web hosting managementRegister Today

  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 487
  • Last Modified:

image smoothing N(p) = 8

i have an image and for each pixel i want sum the neighbours of the pixel in the following way:
suppose that P is the pixel:
N1  N2 N3
N8  P   N4
N7 N6 N5
the part of the algorithm that i don't understand is d_8(h,p) = 1:

for each neighbor h of P / d_8(h,p) = 1 do
   S = S + S0(h)

S = S/8;

does that mean that the sum must be equal to 1? can i force it to be equal to 1 whatever the value of the neighbours? i didn't understand it. can u give me an example please???

%Is there something missing for the condition d_8(h,p) = 1???
Dx1 = (Dx(x1,y1) + Dx(x2,y2)+ Dx(x3,y3) + Dx(x4,y4)...
              + Dx(x5,y5)+ Dx(x6,y6)+ Dx(x7,y7)+ Dx(x8,y8));
Dx1 = Dx1 / 8;

Open in new window

2 Solutions
Jose ParrotGraphics ExpertCommented:
I don't know what notation is d_8(h,p) = 1 about, but as you are talking about smoothness, I will assume a "8-neighborhood" property to make pixel P to receive influence of the pixels around, thus lowering the crispness of the image.
When we use a 3x3 matrix (being the focused pixel in the middle of such matrix) we can decide how much the pixels around will combine with the central pixel P. What we do is to define, for example, a factor of A for each of the 8 pixels around and a factor B for the target pixel P. If you decide for A=1 and B=1, you simply add the values and divide them by 9. If you want more weight for P, then you decide, for instance, for B=3 and divide the sum of all the 9 pixels by 11.
New P = ( A(N1+..+N8)  +  B*P) / (8A + B)

That way, the matrix is
|  1   1   1  |
|  1   3   1  |
|  1   1   1  |
dadadudeAuthor Commented:
Thank you Jose. i think that d8(h,p) = 1 means the weight for the pixels around p and B = 0 the weight of the center pixel.

the initial formula was:
(1/N(p) )* Summation(8-neighbors)

with N(p) = 8 so A = 1 and B = 0.

Dx1 = (A*(Dx(x1,y1) + Dx(x2,y2)+ Dx(x3,y3) + Dx(x4,y4)+ Dx(x5,y5)+ Dx(x6,y6)+ Dx(x7,y7)+ Dx(x8,y8)) + B * Dx(i1,j1))/(8*A + B);

Open in new window

For smoothing the sum of all the entries must be 1 else you will loss energy(brightness) from the image. Think of an image of constant values, smoothing should have no effect which requires the sum of the values in the matrix to be 1

         |  1   1   1  |
1/12*|  1   4   1  |
         |  1   1   1  |

Featured Post

Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now