The Wayback Machine - https://web.archive.org/web/20201019101030/https://github.com/TheAlgorithms/Python/pull/2946
Skip to content
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

Hacktoberfest 2020: Added computer vision algorithm #2946

Merged
merged 5 commits into from Oct 16, 2020

Conversation

@TanayKarve
Copy link
Contributor

@TanayKarve TanayKarve commented Oct 6, 2020

Describe your change:

  • Add an algorithm?
  • Fix a bug or typo in an existing algorithm?
  • Documentation change?

Checklist:

  • I have read CONTRIBUTING.md.
  • This pull request is all my own work -- I have not plagiarized.
  • I know that pull requests will not be merged if they fail the automated tests.
  • This PR only changes one algorithm file. To ease review, please open separate PRs for separate algorithms.
  • All new Python files are placed inside an existing directory.
  • All filenames are in all lowercase characters with no spaces or dashes.
  • All functions and variable names follow Python naming conventions.
  • All function parameters and return values are annotated with Python type hints.
  • All functions have doctests that pass the automated testing.
  • All new algorithms have a URL in its comments that points to Wikipedia or other similar explanation.
  • If this pull request resolves one or more open issues then the commit message contains Fixes: #{$ISSUE_NO}.
TanayKarve added 3 commits Oct 6, 2020
@sharpblade4
Copy link
Contributor

@sharpblade4 sharpblade4 commented Oct 7, 2020

@TanayKarve you can optimize it in magnitudes by using numpy vectorian oprerations instead of python for loops

@TanayKarve
Copy link
Contributor Author

@TanayKarve TanayKarve commented Oct 7, 2020

@sharpblade4 yes i was planning to do it, however wanted to write this code in pure python, thus avoiding any dependencies. what do you think?

Copy link
Contributor Author

@TanayKarve TanayKarve left a comment

avoiding numpy to make this implement in pure python.

@TanayKarve TanayKarve changed the title Added computer vision algorithm Hacktoberfest 2020: Added computer vision algorithm Oct 9, 2020
@TanayKarve
Copy link
Contributor Author

@TanayKarve TanayKarve commented Oct 14, 2020

@sharpblade4 sorry to disturb you, but its been a week, can you please accept this PR?

@sharpblade4
Copy link
Contributor

@sharpblade4 sharpblade4 commented Oct 16, 2020

@TanayKarve sorry for confusing you, I'm just another contributer - not an member of TheAlgorithms/Python.

mean = 0
pixels = image.load()
for i in range(width):
for j in range(height):
pixel = pixels[j, i]
mean += pixel
mean //= width * height
Comment on lines +14 to +20

This comment has been minimized.

@cclauss

cclauss Oct 16, 2020
Member

Suggested change
mean = 0
pixels = image.load()
for i in range(width):
for j in range(height):
pixel = pixels[j, i]
mean += pixel
mean //= width * height
total = sum(sum(pixel for pixel in row) for row in image.load())
mean = total // (width * height)

This comment has been minimized.

@TanayKarve

TanayKarve Oct 16, 2020
Author Contributor

Yes I tried using list builder comprehension initially. However image.load() returns a PixelAccess object which according to the documentation is not Iterable. Thus when running this code the following exception is thrown:
TypeError: 'PixelAccess' object is not iterable

computer_vision/meanthreshold.py Outdated Show resolved Hide resolved
computer_vision/meanthreshold.py Outdated Show resolved Hide resolved
TanayKarve and others added 2 commits Oct 16, 2020
Verified this part works, thanks.

Co-authored-by: Christian Clauss <[email protected]>
Co-authored-by: Christian Clauss <[email protected]>
Copy link
Member

@cclauss cclauss left a comment

Well done! Thanks.

@cclauss cclauss merged commit fc98961 into TheAlgorithms:master Oct 16, 2020
3 checks passed
3 checks passed
codespell
Details
pre-commit
Details
Travis CI - Pull Request Build Passed
Details
@TanayKarve TanayKarve deleted the TanayKarve:patch-1 branch Oct 16, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
3 participants
You can’t perform that action at this time.