Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!goblin3!goblin2!goblin.stu.neva.ru!newsfeed.xs4all.nl!newsfeed1.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.005 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'subject:not': 0.03; 'else:': 0.03; 'advance': 0.07; 'blue': 0.09; 'pixel': 0.09; '65536': 0.16; 'co-ordinate': 0.16; 'csv': 0.16; 'traverse': 0.16; 'trying': 0.19; 'everyone,': 0.19; '8bit%:5': 0.22; 'to:name :python-list@python.org': 0.22; 'print': 0.22; 'message- id:@mail.gmail.com': 0.30; 'code': 0.31; 'file': 0.32; 'running': 0.33; 'checking': 0.33; 'but': 0.35; 'received:google.com': 0.35; 'thanks': 0.36; '8bit%:4': 0.38; 'to:addr:python-list': 0.38; 'to:addr:python.org': 0.39; '8bit%:6': 0.40; 'first': 0.61; 'subject:For': 0.78; '14:': 0.84 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:x-received:date:message-id:subject:from:to :content-type; bh=cOJWALCV+tGs8dNN6G+JCSF/NwJEYJBuDRJ1ksx+IFI=; b=fvyraBdyLRtvQgUCa1RQWmeQWBd+3Oyd6cX5Ev+BcFRSsr476EkxN5iltYYBLLrkM8 NGSTTHOWPmhrSUfoVWBZvllbND5s68QR6fN+wSwa8g/14jU1yO3q5t8vQUIEMj+E2v37 ptFHDmQjdth4Kybz8s86a6XY9GUmzALbIv6r9NooHmznRqF4eUG0J4hTjxJrsuRmKfwV h6iHNah4zWqXQF+UKtLtJ1RALpo+XhdtPIUlx0BP8EdRTj+qtpx4cBHzLfdSdoyG/gZB aT/aq/OjZhjN/wzNIT+k/p9MSi1vXTiIMiPqH6m8C0fzUW5RT0BNrZ9tpVlu2hfz8y4N 0AKw== MIME-Version: 1.0 X-Received: by 10.50.118.33 with SMTP id kj1mr1172761igb.72.1366966111284; Fri, 26 Apr 2013 01:48:31 -0700 (PDT) Date: Fri, 26 Apr 2013 14:18:31 +0530 Subject: Nested For loop not running full From: inshu chauhan To: "python-list@python.org" Content-Type: multipart/alternative; boundary=089e012947527bb4b204db3f995c X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 79 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1366966121 news.xs4all.nl 15980 [2001:888:2000:d::a6]:57218 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:44397 --089e012947527bb4b204db3f995c Content-Type: text/plain; charset=ISO-8859-1 Hello everyone, I have this part of my code where I am trying to traverse over an image by running a for loop for both x and y co-ordinate axis. But the loop is terminating by just reading first pixel. Can think of a reason why this is happening ? The code is: for sy in xrange(0, segimage.height): for sx in xrange(0, segimage.width): if segimage[sy,sx] == (0.0, 0.0, 0.0): continue else: seg_color = segimage[sy,sx] blue = int(seg_color[0]) green = int(seg_color[1]) red = int(seg_color[2]) reg_num = blue + 256 * green + 65536 * red for l in f: sp = l.split(",") if len(sp) == 14: print sy, sx # for checking which pixel its reading currently print reg_num, sp[0] # for checking whats happening if reg_num == int(sp[0].strip()): print reg_num, sp[0].strip() # for checking whats happening classification = int(sp[13].strip()) The inside "for loop" is for reading a csv format file from which I am extracting some information. Thanks in Advance for your suggestions --089e012947527bb4b204db3f995c Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable
Hello everyone,=A0

I have this pa= rt of my code where I am trying to traverse over an image by running a for = loop for both x and y co-ordinate axis. But the loop is terminating by just= reading first pixel. Can think of a reason why this is happening ?

The code is:=A0
for sy= in xrange(0, segimage.height):
=A0 =A0 for sx in xrange(0, segim= age.width):
=A0 =A0 =A0 =A0 =A0 =A0 if segimage[sy,sx] =3D=3D (0.= 0, 0.0, 0.0):
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 continue
=A0 =A0 =A0 =A0 =A0= =A0 else:
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 seg_color =3D segimage= [sy,sx]
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 blue =3D int(seg_color[0]= )
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 green =3D int(seg_color[1])
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 red =3D int(seg_color[2])
=A0 =A0= =A0 =A0 =A0 =A0 =A0 =A0 reg_num =3D blue + 256 * green + 65536 * red
=
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 for l in f:
=A0 =A0 =A0 =A0 = =A0 =A0 =A0 =A0 =A0 =A0 sp =3D l.split(",")
=A0 =A0 =A0= =A0 =A0 =A0 =A0 =A0 =A0 =A0 if len(sp) =3D=3D 14:
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 print sy, sx =A0# for = checking which pixel its reading currently
=A0 =A0 =A0 =A0 =A0 = =A0 =A0 =A0 =A0 =A0 =A0 =A0 print reg_num, sp[0] =A0# for checking whats ha= ppening =A0
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 if re= g_num =3D=3D int(sp[0].strip()):
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 print reg_num,= sp[0].strip() # for checking whats happening
=A0 =A0 =A0 =A0 =A0= =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 classification =3D int(sp[13].strip())=
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0=A0
=

The inside "for loop" is for reading a csv forma= t file from which I am extracting some information.=A0

=
Thanks in Advance for your suggestions
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0
--089e012947527bb4b204db3f995c--