-- random neighbor -- take random pixel value from current pixel neighbour and replace current pixel -- with random pixel if difference of original and random luminance is less then tolerance -- author: Sinisa Petric, (pixopedia@sigmapi-design.com), 2008 -- uses Pixopedia_24 vars and functions for images image_OUT = 0 image_INP = 1 seed_window = 9 seed_retries = 3 lum_tol = 40/255.0 -- get random pixel from neighborhood and check the luminance function get_random_rgb(x, y, window, retries) local rand_x, rand_y, r, g, b, lum1, lum2 r, g, b = fp24_getImageRGB(image_INP, x, y) for k = 0, retries do rand_x = x + math.floor((math.random(window + 1) - 1) - window/2) rand_y = y + math.floor((math.random(window + 1) - 1) - window/2) lum1 = fp24_getImageLuminance01(image_INP, rand_x, rand_y) lum2 = fp24_getImageLuminance01(image_INP, x, y) if math.abs(lum1 - lum2) < lum_tol then r, g, b = fp24_getImageRGB(image_INP, rand_x, rand_y) break end end return r, g, b end -- main routine math.randomseed( os.time() ) for y = 0, vp24_height-1 do for x = 0, vp24_width-1 do r,g,b = get_random_rgb(x,y, seed_window, seed_retries) fp24_setImageRGB(image_OUT, x, y, r, g, b) end fp24_showProgress(y, vp24_height) end