Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #44400 > unrolled thread
| Started by | Terry Jan Reedy <tjreedy@udel.edu> |
|---|---|
| First post | 2013-04-26 05:10 -0400 |
| Last post | 2013-04-26 05:10 -0400 |
| Articles | 1 — 1 participant |
Back to article view | Back to comp.lang.python
This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by
below is the oldest one visible, not the original post.
Re: Nested For loop not running full Terry Jan Reedy <tjreedy@udel.edu> - 2013-04-26 05:10 -0400
| From | Terry Jan Reedy <tjreedy@udel.edu> |
|---|---|
| Date | 2013-04-26 05:10 -0400 |
| Subject | Re: Nested For loop not running full |
| Message-ID | <mailman.1089.1366967405.3114.python-list@python.org> |
On 4/26/2013 4:48 AM, inshu chauhan wrote:
> 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 ?
*A* reason could be that segimage.height and .width are both 1. I would
print them out to see what they are.
>
> 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
>
>
>
>
Back to top | Article view | comp.lang.python
csiph-web