Skip to content

Add example to detect edges - #259

Open
sid19991 wants to merge 1 commit into
boostorg:developfrom
sid19991:example/simple_filter
Open

Add example to detect edges#259
sid19991 wants to merge 1 commit into
boostorg:developfrom
sid19991:example/simple_filter

Conversation

@sid19991

@sid19991 sid19991 commented Mar 15, 2019

Copy link
Copy Markdown

This commit adds a cpp file to example folder. The example demonstrats the use of one
dimensional filter for detection of horizontal and vertical edges.

Tasklist

  • Review
  • Adjust for comments
  • All CI builds and checks have passed ATM, examples are not built by CI jobs

@mloskot
mloskot requested a review from a team March 15, 2019 17:24

@mloskot mloskot left a comment

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.

Could you add a comment briefly explaining the algorithm; steps of the procedure, in words?

Comment thread example/simple_filter.cpp Outdated
#include <boost/gil/extension/numeric/convolve.hpp>


int main() {

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.

Would it be possible to accept input image as command line argument?

@sid19991
sid19991 force-pushed the example/simple_filter branch from 5854314 to d798bf5 Compare March 17, 2019 05:26
Comment thread example/simple_filter.cpp
if(argc!=2){
printf("Usage: simple_filter <image_path>");
return 0;
}

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.

Please use 'std::cerr' rather than printf, and return -1 to indicate the usage error.

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.

I'd also allow to use the C standard macros https://en.cppreference.com/w/cpp/utility/program/EXIT_status

Comment thread example/simple_filter.cpp

// making resizable kernel object
kernel_1d<float> kernel2(sharpen_1,3,1);
//compute horizontal edges

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.

The comment seems to be repeating what the line of C++ code shows.
It rather should explain purpose of computing those edges.

Imagine I know very little about image processing and I read your code for the first time, do I have a chance to learn what algorithm your code implements?

To me, you should give a comment explaining the algorithm, what it does, what are the steps.

Comment thread example/simple_filter.cpp Outdated
convolve_rows<gray32f_pixel_t>(color_converted_view<gray8_pixel_t>(const_view(img)),kernel2,view(convolved));
//compute vertical edges
convolve_cols<gray32f_pixel_t>(color_converted_view<gray8_pixel_t>(const_view(img)),kernel2,view(convolved2));
//save horizontal edges

@mloskot mloskot Mar 18, 2019

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.

save... just repeats what the self-descriptive write_view indicates.
Such comments repeating the actual code are redundant.

@sid19991
sid19991 force-pushed the example/simple_filter branch 2 times, most recently from 9ae14df to 9b548d9 Compare March 18, 2019 13:22
This commit adds a cpp file to example folder. The example demonstrats the use of one
dimensional filter for detection of horizontal and vertical edges.The function
accepts image path as command line argument.
@sid19991
sid19991 force-pushed the example/simple_filter branch from 9b548d9 to 2ae6852 Compare March 22, 2019 10:48
@mloskot

mloskot commented Apr 28, 2019

Copy link
Copy Markdown
Member

@stefanseefeld Shall we add those as they are (optionally, with minor stylistic refactoring) to example/ folder? I think, it's never too many examples showing how to actually use GIL. What do you think?

@mloskot mloskot added status/need-help Issues where help and contributions are welcome status/work-in-progress Do NOT merge yet until this label has been removed! labels Sep 5, 2019
@mloskot mloskot added the cat/feature New feature or functionality label Jan 31, 2020
@mloskot mloskot added the google-summer-of-code All items related to GSoC activities label Mar 10, 2020
@mloskot mloskot added the example Examples of how to use GIL label Mar 25, 2020
@mloskot mloskot added status/need-feedback Asking for more details about the problem and removed status/need-help Issues where help and contributions are welcome labels Jun 3, 2022
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 example Examples of how to use GIL google-summer-of-code All items related to GSoC activities status/need-feedback Asking for more details about the problem status/work-in-progress Do NOT merge yet until this label has been removed!

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants