Analysis of neighborhood relationships in biomedical images