-
-
Notifications
You must be signed in to change notification settings - Fork 14
Update img_avg.py/ There were typos #41
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,27 +1,31 @@ | ||
| """ Here is the challenge problem for 2d loops> | ||
| Images are often represented as 3d arrays, | ||
| """ | ||
| Image Average | ||
|
|
||
| Here is the challenge problem for 2D loops: | ||
| Images are often represented as 3D arrays, | ||
| where the rows and columns are the pixels in the image, | ||
| and each pixel has an r, g, and b value. | ||
| and each pixel has an RGB (red, green, blue) value | ||
| which determines the color of the pixel. | ||
|
|
||
| The interesting thing is that we can iterate over images. | ||
| The challenge is, given an image, create a program that | ||
| will return a different image where each pixel is the average | ||
| of the pixels surrounding it in the original image. | ||
|
|
||
| The neighbors of an image are all the pixels that surroun it, | ||
| 1 on each side, and 4 on the diagonals, for 8 in total. | ||
| Each pixel doesn't necessarily have 8 neighbors, though (think about why) | ||
| The neighbors of an image are all the pixels that surround it, | ||
| 1 on each side, and 4 on the diagonals, for 8 in total. Each | ||
| pixel doesn't necessarily have 8 neighbors, though (think about why). | ||
|
|
||
| The code to grab an image from the internet and make it | ||
| into an array is given to you. The code also displays the new image | ||
| you create in the end. | ||
|
|
||
| NOTE: The image is 3 dimensional because each pixel has rgb values. | ||
| NOTE: The image is 3 dimensional because each pixel has RGB values. | ||
| To find the average value of all of a pixels neighbors, you must | ||
| change the average of the red value to the red value, blue to blue, etc. | ||
| For example, if the neighbors of a pixel with value [1,2,3] | ||
| were [20,30,40] and [10,120,30], the new pixel that would replace the original one would be | ||
| [15,75,35] | ||
| For example, if the neighbors of a pixel with value [1, 2, 3] | ||
| were [20, 30, 40] and [10, 120, 30], the new pixel that would replace the | ||
| original one would be [15, 75, 35] | ||
| """ | ||
|
|
||
| from PIL import Image | ||
|
|
@@ -37,9 +41,12 @@ | |
|
|
||
| # write code to create newimg here | ||
| def solution1(): | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @Citrus716 could you change this to not be a function since the students haven't learned them yet? |
||
| """Iterating over the image here. i is a variable from 0 to the width of the image. | ||
| j is a variable that ranges from 0 to the height of the image. i is associated with | ||
| values""" | ||
| """ | ||
| Iterating over the image here. i is a variable from | ||
| 0 to the width of the image. | ||
| j is a variable that ranges from 0 to the height of the image. | ||
| i is associated with values | ||
| """ | ||
| for i in range(len(img)): | ||
| for j in range(len(img[0])): | ||
| x_n = [0] | ||
|
|
||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@code-for-tomorrow/python who submitted this practice problem? I'm wondering because I noticed there's no solution for it...