- Notifications
You must be signed in to change notification settings - Fork5.9k
Add Radon transform function to ximgproc#3090
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Conversation
| * with type CV_32SC1 by default. | ||
| * | ||
| */ | ||
| CV_EXPORTS_W void HoughSpaceTransform(InputArray src, |
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.
What is wrong withHoughLines?
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.
HoughLines only returns lines detected in images. Hough Space can be used in other ways like comparing similarity between images, and it has some advantages over comparing histograms or pixels directly.
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.
After a search I found Hough Detection is using Radon Transform to detect shape in image. (Described herehttps://www.osti.gov/doepatents/biblio/4746348 ). What I implemented is more like Radon Transform (https://en.wikipedia.org/wiki/Radon_transform)
Should I change my function name and commit to the same pull request?
AleksandrPanov commentedNov 1, 2021 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
I compared the current version of Radon Transform with thescikit-image radon version based onscikit-image example.
|
kuloPo commentedNov 7, 2021 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
Updates:
The small difference may caused by:
I wrote two more cases to test data in corners |
AleksandrPanov commentedNov 8, 2021 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
AleksandrPanov commentedNov 8, 2021
LGTM + minor comments:
Note: no need to re-open PR, apply changes "inplace". |
fix always cropping corner when rotatetranspose the output - now each column is integraladd support for float numberadd comment
2a7f0ba to36275caComparekuloPo commentedNov 8, 2021
The branch is rebased to 4.x |
alalek left a comment
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.
@kuloPo Thank you for updates!
Please take a look on the comments below.
| namespace opencv_test { | ||
| namespace { | ||
| typedef tuple<Size, MatType> RadonTransformPerfTestParam; |
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.
Please avoid indentation in namespaces
| int main() { | ||
| cv::Mat src = cv::imread("peilin_plane.png", cv::IMREAD_GRAYSCALE); | ||
| cv::Mat radon; |
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.
Please use 4 spaces for indentation (no tabs)
| #include <opencv2/ximgproc/radon_transform.hpp> | ||
| int main() { | ||
| cv::Mat src = cv::imread("peilin_plane.png", cv::IMREAD_GRAYSCALE); |
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.
cv::
In OpenCV samples we addusing namespace cv; after includes and removing allcv:: prefixes.
| Mat radon; | ||
| cv::ximgproc::RadonTransform(src, radon); | ||
| ASSERT_EQ(radon.rows, 363); |
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.
_EQ
uses different order of parameters:(expected, actual).
Signature for_EQ isASSERT_EQ(expected_reference, actual_result);.
Correct order of parameters are required to emit valid error messages.
Reference:https://github.com/opencv/opencv/blob/4.0.0/modules/ts/include/opencv2/ts/ts_gtest.h#L8196-L8200
GTEST_API_ AssertionResult EqFailure(const char* expected_expression, const char* actual_expression, const std::string& expected_value, const std::string& actual_value, bool ignoring_case);| declare.in(src, WARMUP_RNG); | ||
| TEST_CYCLE_N(3) |
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.
TEST_CYCLE_N
is misused here. No need to specify amount of inner samples here.
Please use:
TEST_CYCLE()- or
PERF_SAMPLE_BEGIN()+PERF_SAMPLE_END()
| Mat radon; | ||
| cv::ximgproc::RadonTransform(src, radon); | ||
| ASSERT_EQ(radon.at<int>(0, 0), 0); |
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.
Before using.at<int> it makes sense to validate type.
ASSERT_EQ(CV_32SC1, radon.type());EXPECT_EQ(0, radon.at<int>(0, 0));(prefer to useEXPECT_ for non-critical failures - e.g. code below would not crash)
kuloPo commentedNov 9, 2021
All the issues are fixed. |
AleksandrPanov left a comment
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.
👍


Uh oh!
There was an error while loading.Please reload this page.
This function calculates the Hough Space of a given image in any range.
Hough Transform is a discrete implementation of Radon Transform.
Pull Request Readiness Checklist
See details athttps://github.com/opencv/opencv/wiki/How_to_contribute#making-a-good-pull-request
Patch to opencv_extra has the same branch name.