CARVIEW |
Navigation Menu
-
Notifications
You must be signed in to change notification settings - Fork 5.8k
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
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 with HoughLines?
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 here https://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?
I compared the current version of Radon Transform with the scikit-image radon version based on scikit-image example.
|
Updates:
The small difference may caused by:
I wrote two more cases to test data in corners |
LGTM + minor comments:
Note: no need to re-open PR, apply changes "inplace". |
fix always cropping corner when rotate transpose the output - now each column is integral add support for float number add comment
2a7f0ba
to
36275ca
Compare
The branch is rebased to 4.x |
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 add using namespace cv;
after includes and removing all cv::
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
is ASSERT_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 use EXPECT_
for non-critical failures - e.g. code below would not crash)
All the issues are fixed. |
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.
👍
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 at https://github.com/opencv/opencv/wiki/How_to_contribute#making-a-good-pull-request
Patch to opencv_extra has the same branch name.