Skip to content

Hacktoberfest 2020: Added computer vision algorithm#2946

Merged
cclauss merged 5 commits intoTheAlgorithms:masterfrom
TanayKarve:patch-1
Oct 16, 2020
Merged

Hacktoberfest 2020: Added computer vision algorithm#2946
cclauss merged 5 commits intoTheAlgorithms:masterfrom
TanayKarve:patch-1

Conversation

@TanayKarve
Copy link
Copy Markdown
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}.

@sharpblade4
Copy link
Copy Markdown
Contributor

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

@TanayKarve
Copy link
Copy Markdown
Contributor Author

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
Copy Markdown
Contributor Author

@TanayKarve TanayKarve left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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
Copy Markdown
Contributor Author

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

@sharpblade4
Copy link
Copy Markdown
Contributor

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

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

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

TanayKarve and others added 2 commits October 16, 2020 18:34
Verified this part works, thanks.

Co-authored-by: Christian Clauss <cclauss@me.com>
Co-authored-by: Christian Clauss <cclauss@me.com>
Copy link
Copy Markdown
Member

@cclauss cclauss left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well done! Thanks.

@cclauss cclauss added the hacktoberfest-accepted Accepted to be counted towards Hacktoberfest label Oct 16, 2020
@cclauss cclauss merged commit fc98961 into TheAlgorithms:master Oct 16, 2020
@TanayKarve TanayKarve deleted the patch-1 branch October 16, 2020 13:18
stokhos pushed a commit to stokhos/Python that referenced this pull request Jan 3, 2021
* Create meanthresholding.py

* Rename meanthresholding.py to meanthreshold.py

* Update meanthreshold.py

* Update computer_vision/meanthreshold.py

Verified this part works, thanks.

Co-authored-by: Christian Clauss <cclauss@me.com>

* Update computer_vision/meanthreshold.py

Co-authored-by: Christian Clauss <cclauss@me.com>

Co-authored-by: Christian Clauss <cclauss@me.com>
peRFectBeliever pushed a commit to peRFectBeliever/Python that referenced this pull request Apr 1, 2021
* Create meanthresholding.py

* Rename meanthresholding.py to meanthreshold.py

* Update meanthreshold.py

* Update computer_vision/meanthreshold.py

Verified this part works, thanks.

Co-authored-by: Christian Clauss <cclauss@me.com>

* Update computer_vision/meanthreshold.py

Co-authored-by: Christian Clauss <cclauss@me.com>

Co-authored-by: Christian Clauss <cclauss@me.com>
Panquesito7 pushed a commit to Panquesito7/Python that referenced this pull request May 13, 2021
* Create meanthresholding.py

* Rename meanthresholding.py to meanthreshold.py

* Update meanthreshold.py

* Update computer_vision/meanthreshold.py

Verified this part works, thanks.

Co-authored-by: Christian Clauss <cclauss@me.com>

* Update computer_vision/meanthreshold.py

Co-authored-by: Christian Clauss <cclauss@me.com>

Co-authored-by: Christian Clauss <cclauss@me.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

hacktoberfest-accepted Accepted to be counted towards Hacktoberfest

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants