-
-
Notifications
You must be signed in to change notification settings - Fork 14
Revert "Kehao ch10problems(2 of them)" #42
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,31 +1,27 @@ | ||
| """ | ||
| Image Average | ||
| Here is the challenge problem for 2D loops: | ||
| Images are often represented as 3D arrays, | ||
| """ 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 RGB (red, green, blue) value | ||
| which determines the color of the pixel. | ||
| and each pixel has an r, g, and b value. | ||
| 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 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 neighbors of an image are all the pixels that surroun it, | ||
| 1 on each side, and 4 on the diagonals, for 8 in total. | ||
|
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. W291: trailing whitespace |
||
| 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 | ||
|
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. E501: line too long (91 > 79 characters) |
||
| [15,75,35] | ||
| """ | ||
|
|
||
| from PIL import Image | ||
|
|
||
This file was deleted.
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,31 +1,27 @@ | ||
| """ | ||
| Image Average | ||
| Here is the challenge problem for 2D loops: | ||
| Images are often represented as 3D arrays, | ||
| """ 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 RGB (red, green, blue) value | ||
| which determines the color of the pixel. | ||
| and each pixel has an r, g, and b value. | ||
| 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 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 neighbors of an image are all the pixels that surroun it, | ||
| 1 on each side, and 4 on the diagonals, for 8 in total. | ||
|
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. W291: trailing whitespace |
||
| 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 | ||
|
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. E501: line too long (91 > 79 characters) |
||
| [15,75,35] | ||
| """ | ||
|
|
||
| from PIL import Image | ||
|
|
@@ -41,12 +37,9 @@ | |
|
|
||
| # write code to create newimg here | ||
| def solution1(): | ||
| """ | ||
| 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. | ||
|
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. E501: line too long (83 > 79 characters) |
||
| j is a variable that ranges from 0 to the height of the image. i is associated with | ||
|
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. W191: indentation contains tabs 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. E101: indentation contains mixed spaces and tabs 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. E501: line too long (84 > 79 characters) |
||
| values""" | ||
|
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. W191: indentation contains tabs 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. E101: indentation contains mixed spaces and tabs |
||
| for i in range(len(img)): | ||
| for j in range(len(img[0])): | ||
| x_n = [0] | ||
|
|
||
This file was deleted.
This file was deleted.
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.
W291: trailing whitespace