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

imgWatershedCustomMarkers #2423

Closed
wants to merge 7 commits into from
Closed

Conversation

@santoshrajkumar
Copy link
Contributor

santoshrajkumar commented Sep 13, 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}.
@TravisBuddy
Copy link

TravisBuddy commented Sep 13, 2020

Hey @santoshrajkumar,
Something went wrong with the build.

TravisCI finished with status errored, which means the build failed because of something unrelated to the tests, such as a problem with a dependency or the build process itself.

View build log

TravisBuddy Request Identifier: 66852cc0-f603-11ea-b8b5-77c9400cce29
@TravisBuddy
Copy link

TravisBuddy commented Sep 13, 2020

Hey @santoshrajkumar,
Something went wrong with the build.

TravisCI finished with status errored, which means the build failed because of something unrelated to the tests, such as a problem with a dependency or the build process itself.

View build log

TravisBuddy Request Identifier: 55a0ffc0-f607-11ea-b8b5-77c9400cce29
@TravisBuddy
Copy link

TravisBuddy commented Sep 13, 2020

Hey @santoshrajkumar,
Something went wrong with the build.

TravisCI finished with status errored, which means the build failed because of something unrelated to the tests, such as a problem with a dependency or the build process itself.

View build log

TravisBuddy Request Identifier: d7365e90-f607-11ea-b8b5-77c9400cce29
@TravisBuddy
Copy link

TravisBuddy commented Sep 13, 2020

Travis tests have failed

Hey @santoshrajkumar,
Please read the following log in order to understand the failure reason.
It'll be awesome if you fix what's wrong and commit the changes.

TravisBuddy Request Identifier: 2a899660-f609-11ea-b8b5-77c9400cce29
@TravisBuddy
Copy link

TravisBuddy commented Sep 13, 2020

Travis tests have failed

Hey @santoshrajkumar,
Please read the following log in order to understand the failure reason.
It'll be awesome if you fix what's wrong and commit the changes.

TravisBuddy Request Identifier: a9b022a0-f60a-11ea-b8b5-77c9400cce29
"""


def create_rgb(i):

This comment has been minimized.

@cclauss

cclauss Sep 14, 2020

Member

Please avoid single-letter variable names especially for function parameters. They make your code look old fashioned. Please use a self-documenting name and add Python type hints for function parameters and return types.

colors = []
for i in range(10):
colors.append(create_rgb(i))
Comment on lines +23 to +25

This comment has been minimized.

@cclauss

cclauss Sep 14, 2020

Member
Suggested change
colors = []
for i in range(10):
colors.append(create_rgb(i))
colors = [create_rgb(i) for i in range(10)]

A list comprehension.

# callback function


Comment on lines +34 to +36

This comment has been minimized.

@cclauss

cclauss Sep 14, 2020

Member
Suggested change
# callback function

The function name already tells us that this is a callback function so it only slows down the reader to have a comment that says the same thing.

cv2.setMouseCallback("Image", mouse_callback)


while True:

This comment has been minimized.

@cclauss

cclauss Sep 14, 2020

Member

Please indent all code at global scope (i.e. not already in a function) under if __name__ == "__main__": so that Travis CI and pytest does not run it each time we test our code.

segments = np.zeros(img.shape, dtype=np.uint8)

for color_ind in range(n_markers):
segments[marker_image_copy == (color_ind)] = colors[color_ind]

This comment has been minimized.

@cclauss

cclauss Sep 14, 2020

Member

This line confuses me. Perhaps a comment about what is going on.

Please run this code thru psf/black as discussed in CONTRIBUTING.md.

@@ -0,0 +1,89 @@
import cv2

This comment has been minimized.

@cclauss

cclauss Sep 14, 2020

Member

Please add a URL to a site that discusses what watersheding and custom markers are and where/when/why we would want to use this algrithm.

This comment has been minimized.

@spamegg1
Copy link
Contributor

spamegg1 commented Sep 14, 2020

Build log says:

digital_image_processing/image_watersheding_custom_markers.py:7: in
img_copy = img.copy()
E AttributeError: 'NoneType' object has no attribute 'copy'

This means that on line 6

img = cv2.imread('/image_data/scenery.jpg')

it is unable to read the file, so img ends up being None.
I'm not sure how to fix this, but somehow the path to the file needs to be added so Travis can see it.
One idea is to look at other algorithms that read from a file. See how they handled it.
Here is one example: they use the os module (look at the bottom):
https://github.com/TheAlgorithms/Python/blob/master/digital_image_processing/histogram_equalization/histogram_stretch.py
You can imitate what they are doing there.
Hope this helps. Good luck!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

4 participants
You can’t perform that action at this time.