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

Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

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  |

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
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  |
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Web Development

From novice to tech pro — start learning today.