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

Add rasterizer support for ellipse #585

Merged
merged 34 commits into from
Mar 28, 2021
Merged

Conversation

meshtag
Copy link
Member

@meshtag meshtag commented Mar 23, 2021

Description

This pull request adds rasterization functionality for drawing ellipse using midpoint algorithm.

I would like to ponder upon following points once this basic functionality is approved(possibly merged) :

  • Add support for drawing a rotated ellipse
  • Vary thickness of curves drawn using rasterization
  • Draw arcs(circular or elliptical) instead of drawing complete curves

I would like this pull request to be considered as solution for my competency test.

References

Tasklist

  • Add test case(s)
  • Ensure all CI builds pass
  • Review and approve

Copy link
Member

@mloskot mloskot left a comment

Choose a reason for hiding this comment

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

Please, ensure this code does not introduce any new warnings

include/boost/gil/rasterization/ellipse.hpp Outdated Show resolved Hide resolved
include/boost/gil/rasterization/ellipse.hpp Outdated Show resolved Hide resolved
include/boost/gil/rasterization/ellipse.hpp Outdated Show resolved Hide resolved
include/boost/gil/rasterization/ellipse.hpp Outdated Show resolved Hide resolved
test/core/rasterization/ellipse.cpp Outdated Show resolved Hide resolved
test/core/rasterization/ellipse.cpp Outdated Show resolved Hide resolved
@mloskot mloskot added the cat/feature New feature or functionality label Mar 26, 2021
Copy link
Member

@mloskot mloskot left a comment

Choose a reason for hiding this comment

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

The feature is based on a known paper and is covered by a test.
So, without doing any verification of the algorithm implementation, I'm happy to accept it.

/cc @lpranam any objections?

Copy link
Member

@lpranam lpranam left a comment

Choose a reason for hiding this comment

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

you forgot to add example in CMakeLists.txt otherwise all good :D

@meshtag
Copy link
Member Author

meshtag commented Mar 28, 2021

As far as I understand, we don't need to add example files individually in example/CMakeLists.txt since it is using GLOB_RECURSE (unlike some other CMakeLists.txt files of the project).
Do you want me to change any other file? Please correct me if I am wrong.

@lpranam
Copy link
Member

lpranam commented Mar 28, 2021

oh yes, sorry my bad I forgot. we have a few different approach in cmake so this happens a lot with me...

@mloskot mloskot added the core boost/gil label Mar 28, 2021
@mloskot mloskot added this to the Boost 1.77+ milestone Mar 28, 2021
@mloskot mloskot merged commit bc3a6c0 into boostorg:develop Mar 28, 2021
meshtag added a commit to meshtag/gil that referenced this pull request Apr 21, 2021
* Added all standard morphological transformations
* Should handle grayscale dilation/erosion
* Added test cases and improved code structure
* Should handle multichannel images
meshtag added a commit to meshtag/gil that referenced this pull request Apr 21, 2021
* Added all standard morphological transformations
* Should handle grayscale dilation/erosion
* Added test cases and improved code structure
* Should handle multichannel images
meshtag added a commit to meshtag/gil that referenced this pull request Apr 22, 2021
* Added all standard morphological transformations
* Should handle grayscale dilation/erosion
* Added test cases and improved code structure
* Should handle multichannel images
@meshtag meshtag deleted the ellipse branch August 21, 2021 18:48
@mloskot mloskot mentioned this pull request May 12, 2022
6 tasks
@marco-langer
Copy link
Contributor

marco-langer commented Jun 2, 2022

This PR was staged for releasing with Boost 1.80, but I'd like to give another review on ellipse.hpp:

  • naming: why is it midpoint_circle_rasterizer, but midpoint_elliptical_rasterizer?
  • the circle rasterizers take the center and radius arguments as signed integers whereas the ellipse rasterizer uses unsigned integers for semi-axes and center
  • line and circle rasterizers implement the call operator to obtain the trajectory whereas the ellipse rasterizer implements the call operator for drawing the trajectory to an image
  • the call operator makes a deep copy of the trajectory, because draw_curve() takes the vector by value
  • why is the color implemented as a std::vector<unsigned int> and not as a pixel?
  • why is error handling printed to std::cout?

@meshtag
Copy link
Member Author

meshtag commented Jun 2, 2022

Thanks a lot for providing your review @marco-langer !

naming: why is it midpoint_circle_rasterizer, but midpoint_elliptical_rasterizer?

  • naming : I agree that we can follow a more consistent naming pattern (maybe midpoint_ellipse_rasterizer instead of midpoint_elliptical_rasterizer ?)

the circle rasterizers take the center and radius arguments as signed integers whereas the ellipse rasterizer uses unsigned integers for semi-axes and center

  • There is no significant point in taking semi-axes as signed integers. For center co-ordinates, I think we can chose to provide signed integer support here (though it might require significant changes in some other parts of the algorithm as well, for ex. checking of curve overflow in our frame). I can share more on this once I test/observe the usefulness of signed center co-ordinates in the case of midpoint_circle_rasterizer as well.

line and circle rasterizers implement the call operator to obtain the trajectory whereas the ellipse rasterizer implements the call operator for drawing the trajectory to an image

  • I think my intention here was to save the user from the hassle of drawing stuff (with overflow checking).

the call operator makes a deep copy of the trajectory, because draw_curve() takes the vector by value

  • Yes, I think we can probably try passing it by reference

why is the color implemented as a std::vector and not as a pixel?

  • I don't really remember the reason I used std::vector<unsigned int> for color

why is error handling printed to std::cout?

  • I don't remember the reason for using std::cout for indicating curve overflow, (perhaps I hesitated from using std::length_error because curve overflow is more like a warning/notification than an actual error). Please feel free to share your suggestions here as well.

@mloskot
Copy link
Member

mloskot commented Jun 2, 2022

@marco-langer Great comments. Since this has already been merged, I'd suggest to simply open an issue with reference to this PR.
Unless @meshtag wants to attack your suggestions sooner and submit PR :)

@mloskot
Copy link
Member

mloskot commented Jun 26, 2022

@meshtag FYI, we have merged PR #692 which addresses points raised by @marco-langer, so please have a look at those changes.

@meshtag
Copy link
Member Author

meshtag commented Jun 26, 2022

Reviewed the PR.
@mloskot , thanks a lot for informing!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cat/feature New feature or functionality core boost/gil
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants