@pimms.value<EOL><INDENT>def cleaned_visual_areas(visual_areas, faces):<DEDENT>
area_ids = np.array(visual_areas)<EOL>boundaryNeis = {}<EOL>for (b,inside) in [(b, set(inside))<EOL>for t in faces.T<EOL>for (bound, inside) in [([i for i in t if area_ids[i] == <NUM_LIT:0>],<EOL>[i for i in t if area_ids[i] != <NUM_LIT:0>])]<EOL>if len(bound) > <NUM_LIT:0> and len(inside) > <NUM_LIT:0><EOL>for b in bound]:<EOL><INDENT>if b in boundaryNeis: boundaryNeis[b] |= inside<EOL>else:                 boundaryNeis[b] =  inside<EOL><DEDENT>for (b,neis) in six.iteritems(boundaryNeis):<EOL><INDENT>area_ids[b] = np.argmax(np.bincount(area_ids[list(neis)]))<EOL><DEDENT>return pimms.imm_array(np.asarray(area_ids, dtype=np.int))<EOL>
mdl.cleaned_visual_areas is the same as mdl.visual_areas except that vertices with visual
area values of 0 (boundary values) are given the mode of their neighbors.