GLProgramming.com

home :: about :: development guides :: irc :: forums :: search :: paste :: links :: contribute :: code dump

-> Click here to learn how to get live help <-


New Paste :: Recent Pastes:: No Line Numbers


explanation of blur by baldurk
1
 
// Here are your pixels, say 8x8

// 0  1  2  3  4  5  6  7
// 8  9  10 11 12 13 14 15
// 16 17 18 19 20 21 22 23
// 24 25 26 27 28 29 30 31
// 32 33 34 35 36 37 38 39
// 40 41 42 43 44 45 46 47
// 48 49 50 51 52 53 54 55
// 56 57 58 59 60 61 62 63

// Let's average the pixels in the block 9 .. 49 and 9 .. 14.
// This block is in the middle. Pick any pixel in it, and it
// has 8 neighbours. Itself and one to the left, right, top
// bottom, topleft, etc. So we total all of them up and divide
// by 9. However, the groups 0 .. 7, 0 .. 56, 56 .. 63 and 7 .. 63
// are on the edge. This means each of them only have 5 neighbours.
// e.g. the ones on the top (0 .. 7) only have to the left, right,
// bottom, bottom-left and bottom-right. So we total them up but
// only divide by 6 because there are only 6 pixels.
// This way we avoid going off the edge by accident.