<br><div class="gmail_extra"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="im">
><br>
> def GenerateRing(x,y, N): Generates square rings around a point in data which has 300 columns(x) and 3000<br>
> rows(y)<br>
>     indices = []<br>
>     for i in xrange(-N, N):<br>
>         indices.append((x+i, y-N))<br>
>         indices.append((x+N, y+i))<br>
>         indices.append((x-i, y+N))<br>
>         indices.append((x-N, y-i))<br>
>     return indices<br>
<br>
</div>No, this creates a one dimensional list with 2N elements of where each element is a two item tuple.<br>
<div class="im"><br></div></blockquote><div>Yes, in programme it returns a list of tuples but pysically it is creating a ring . <br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div class="im">
<br>
             I need help in this part as I am<br>
> unable to device a method in which if the points are out of index,it should stop and<br>
>                         if idx[0] >= 300 and idx[1] >= 3000:           go to next centre and start generating<br>
> rings from there.. and again if the index is out of range .. this should repeat<br>
>                             continue<br>
>                         else :<br>
>                             point = data[idx[0], idx[1]]<br>
<br>
</div>You can use a few different methods. This is just one example.<br>
<br>
for idx, temp_point in enumerate(new_indices):<br>
    try:<br>
        temp_point[0]<br>
        temp_point[1]<br>
    except Exception: #Should be IndexError I think.<br>
        print 'idx: {0}\ntemp_point:{1}'.format(idx, temp_point)<br>
        # Possibly add a break or exit so you do not have to<br>
        # keep going once you hit a failure.<br>
    point = data[temp_point[0], temp_point[1]]<br>
<br>
<br></blockquote><div><br>Thank you for the suggestion. <br> <br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
What is `data`? I have not seen any built-in structure that takes<br>
a tuple in this manner...unless it is a dictionary. Or from numpy.<br>
Given my lack of knowledge of what `data`, it could be the<br>
problem is there. That is one reason I accessed `temp_point[0]` and<br>
`temp_point[1]` separately.<br></blockquote><div> </div><div>Data is an image. <br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div class="im"><br>
<br>
><br>
> Traceback (most recent call last):<br>
>   File "Z:/modules/Classify.py", line 73, in <module><br>
>     ComputeClasses(data)<br>
>   File "Z:/modules/Classify.py", line 49, in ComputeClasses<br>
>     point = data[idx[0], idx[1]]<br>
> error: index is out of range<br>
><br>
<br>
</div>Is that the actual error? If so, then the problem is not `idx` or<br>
`temp_point` but instead `data`. If it is not the exact error, please<br>
copy and paste the error message *exactly* as given.<br></blockquote><div><br><br>Sorry but this is the actual error .<br></div></div><br></div>