You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The ... part is supposed to be executed for each pair of coordinates x and y. Those are initialized with 0 in line 1 and 2, which is correct. But let's see, what happens after finishing the first row of pixels? In that case, when the ... part is executed, x is the last column and y is 0. Then, x is incremented by 1, and the inner loop terminates, because x < img.shape[1] is no longer true. Then, y is incremented by 1, so the processing of the second row of pixels begins. However, we still have x referring to the last column plus 1! So in the next iteration of the outer loop, the condition x < img.shape[1] of the inner loop is still false, so the second row is never actually processed, and neither is the third, or any other row of pixels after the first.
The mistake that we have made is that we haven't reset x to 0 after finishing the first row! Lets fix that:
This code should work (I have only added the instruction x = 0 at the bottom, you can also find the fully fixed version of your code here). Please report back whether the issue is fixed now. @lottagambert
Dear Mr Kostrykin,
thank you for your quick response and help. Unfortunately I wasn't able to fix the problem with your explanation.
It would be very nice if we could speak about it again in the next lesson.
Have a nice weekend.
Best regards
Lotta Gambert
Repository
https://github.com/lottagambert/mobi-fs3-python
Access rights
Git commit and push
Task
Task 2.3.2
Describe the problem (if possible)
Image is not clipped although code runs without errors
The text was updated successfully, but these errors were encountered: