<br>for this code m getting this error :<br><br>CODE : <br>def ComputeClasses(data):<br> radius = .5 <br> points = []<br> for cy in xrange(0, data.height):<br> for cx in xrange(0, data.width):<br> if data[cy,cx] != (0.0,0.0,0.0):<br>
centre = data[cy, cx]<br> points.append(centre) <br> <br><br> change = True<br><br> while change:<br> <br> for ring_number in xrange(1, 1000):<br>
change = False<br> new_indices = GenerateRing(cx, cy, ring_number)<br> <br><br> for idx in new_indices:<br> point = data[idx[0], idx[1]]<br>
<br> if point == (0.0, 0.0, 0.0 ):<br> continue<br> else:<br> dist = distance(centre, point)<br> if dist < radius :<br>
print point <br> points.append(point)<br> change = True<br> print change<br> <br>
<br> break <br><br><br>ERROR : <br>Traceback (most recent call last):<br> File "Z:\modules\classification2.py", line 74, in <module><br> ComputeClasses(data)<br> File "Z:\modules\classification2.py", line 56, in ComputeClasses<br>
dist = distance(centre, point)<br>UnboundLocalError: local variable 'centre' referenced before assignment<br><br>And i am unable to understand .. WHY ?<br><br><br>