I would said that this function is limited to small images only, if you change the int8(x) and int8(y) by int16(x) and int16(y), you may be able to work with bigger and difficult images. the black issue seams not solved. can you explain us the functioning or maybe an example so we use your function! Great function!!!!