-
-
Notifications
You must be signed in to change notification settings - Fork 46.4k
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
Conversation
@TanayKarve you can optimize it in magnitudes by using numpy vectorian oprerations instead of python for loops |
@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? |
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.
avoiding numpy to make this implement in pure python.
@sharpblade4 sorry to disturb you, but its been a week, can you please accept this PR? |
@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 |
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.
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) |
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.
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
Verified this part works, thanks. Co-authored-by: Christian Clauss <cclauss@me.com>
Co-authored-by: Christian Clauss <cclauss@me.com>
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.
Well done! Thanks.
* 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>
* 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>
* 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>
Describe your change:
Checklist:
Fixes: #{$ISSUE_NO}
.