edge filter algorithm