-
Notifications
You must be signed in to change notification settings - Fork 5.9k
Radon transform #549
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
Radon transform #549
Conversation
| 19. **opencv_xfeatures2d**: Extra 2D Features Framework containing experimental and non-free 2D feature algorithms. | ||
|
|
||
| 20. **opencv_ximgproc**: Extended Image Processing: Structured Forests / Domain Transform Filter / Guided Filter / Adaptive Manifold Filter / Joint Bilateral Filter / Superpixels. | ||
| 20. **opencv_ximgproc**: Extended Image Processing: Structured Forests / Domain Transform Filter / Guided Filter / Adaptive Manifold Filter / Joint Bilateral Filter / Superpixels / Radon transform. |
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.
- Radon transform is within "Domain Transform" category, not sure it must be mentioned as separate.
- There is also the Hough Transform present here in ximgproc (Hough is spacial case of 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.
What should I do then? The outputs of hough and radon are similar. But the way they are implemented is different. Should I remove "Radon transform" from README.md ?
|
Some improvements suggestions:
|
Indeed, to be polite I let this PR to flow and perhaps enhance it another time. Consider my opinion only as advice level, no need to follow them at all. |
|
Okay. I will have a look into the links suggested. What should I do now? A fast radon implementation or the existing one should be slightly modified? |
I believe would be great to try implement the exposed matlab piece or from other trusted and well documented sources you like more. |
|
For reference:
My ultimate goal (personal) would be to see hough aside with radon and inverse radon using parallelism and also a GPU versions too, but my time is limited. |
|
I implemented it after looking into the links. Can you tell me what other changes need to be made? |
|
Few ideas starting with the exposed API of fast Hough: https://github.com/Itseez/opencv_contrib/blob/master/modules/ximgproc/include/opencv2/ximgproc/fast_hough_transform.hpp Would be nice to align radon to that to make a nice tandem in OpenCV . See their ideas, I believe are well reasoned and well done:
Add some example to proof it works. E.g. take two very noisy lines compute and display the sinogram , find biggest two points in sinogram, compute and draw back the lines over the original noisy image. E.g.: http://cogsys.imm.dtu.dk/staff/ptoft/Radon/Radon.html . If you could example this side by side with actual Hough transform proving that radon sinogram is much more sharper in noisy conditions that example would be cherry of the cherries ! When done, assure builbots are in green state and squash all commits into one (ask here if you have troubles, someone will help). Please consider these as simple advices. Last word will be of the reviewers/maintainers. I am simple contributor here with some care about quality. It happen to be very interested in this radon transform so i tried to advice you in my best ways. My respect goes to You so I let you choose your final ways. |
|
Haha, thanks a lot. Will try to implement the best I can. |
People spend lot of time documenting & bugfixing, much more spent time then just adding new features. Looking forward for the best of Radon [1] one, looking forward for best it can be done. |
|
Okay. I will add new features ( angle range option and operations ) and documentation soon. |
|
How should I add support for any type of input? I am thinking of normalizing the input to [0, 1] with CV_32F or CV_64F and go ahead. Is that right? Or is any better alternative available? |
|
|
Okay. Thanks. I will try to do modify the code so as to process any type of input, keeping output depth fixed. |
|
Is the code fine? If it is, I will complete documentation and example code, and make a final commit. Thanks. |
Few minor comments, little inconsistency:
After you finish and all is green merge all individual commits into single one for the reviewers (by git rebase). Also notice that review can take up to several month depending on relase cycle/upstream time schedule so be patient. |
|
I wanted to put 63 for AngleRange as it would include all the angle between 1 and 180 degrees. Will do the same. Also, for the operation should I give a default value, as people may not need to perform an operation. They can just get the Radon transform and analyse it. Or should I create an enum value RT_NONE which I will put as default ? |
|
|
Okay. I will add RT_SUM as the default value. |
49a1bc3 to
b675dc4
Compare
|
I am getting a merge conflict error with the buildbot. Can somebody help me fix it? |
|
Make sure you have a 3-way visual merge tool installed and configured in your Git config.
|
b675dc4 to
e94c66a
Compare
|
Ohh okay. Thanks. Merged and pushed. |
|
I completed the implementation and it has passed the required builds. Please review it and merge it. Suggestions are welcome :) . |
918e06d to
b501a2a
Compare
|
I subtracted the min angle values from the theta values as a workaround and now it works properly. Thanks! |
b501a2a to
9ca4edb
Compare
|
@dogramacigokhan I made the change which you pointed out. Thanks :) |
0135dc4 to
ef2f720
Compare
|
I am getting an error like this: Can anyone tell me how to fix it? |
|
look if there is another git process accessing the repo. |
91b5545 to
5f63895
Compare
5f63895 to
456e6fa
Compare
|
Is it necessary to squash commits into one if someone else pushes commits to the current pull request, too? I'm planning to make some major changes on code. Should I wait for this pull request to be merged or should I create pull request to current one? |
GitHub forbids this by default. Anyway you can start experiments in new own PR based on commit from this patch (2+ commits in total). |
|
|
@Aravind-Suresh , @dogramacigokhan I think it is possible to have multiple 'commiters' on same forked branch thus changing.controlling the same PR (in this case @Aravind-Suresh 's branch called radon-transform). All you need is to obtain 'colaborator' status from @Aravind-Suresh (see github profile settings for that fork, or global settings, just google for that). But, even in such scenario whith single/multiple commiters someone (one of you two who have access to forked branch) need to squash all the commits, thus by squashing i think only @Aravind-Suresh 's name will be displayed as author). |
|
Okay. @dogramacigokhan I have added you as a collaborator. Start working on radon transform and commit your works. As @cbalint13 said, we will squash them later. |
|
Hi, was this request finally merged? |
|
Hi @tomasfernandezm, No. It hasn't been merged yet. |
terfendail
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.
Could you please also rebase your changes to latest master to handle merge conflicts
| #include <opencv2/imgproc.hpp> | ||
| #include "opencv2/ximgproc.hpp" | ||
|
|
||
| #ifdef __cplusplus |
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.
It isn't necessary to check for c++ availability here. Since inclusion of imgproc.hpp will anyway produce compilation error if compiler isn't c++ capable. Moreover in this case radon_transform.hpp will be almost empty and RadonOp enum referred later became undefined.
| rT(srcMat, dstMat, minAngle, maxAngle); | ||
|
|
||
| // Operating the Radon transform | ||
| if( opDst.needed() ) { |
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.
It looks like the second part of the function isn't closely related to Radon transform itself. IMHO it would be better to remove it to simplify and clarify the function interface. If the user require Radon transform reduction it's always possible to add reduce(dst, opDst, 0, REDUCE_OP); to the application code
| * @param maxAngle [maxAngle, referenced] | ||
| */ | ||
|
|
||
| static inline void getAngleRange( int angleRange, |
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.
IMHO it would be better to replace int angleRange with int angleMax, int angleMin in radonTransform(...) interface to extend the set of use cases function could be used in. The implementation anyway prepare result degree by degree and therefore doesn't depend on particular angle range as input. Moreover it doesn't provide the result as a set so for angleRange == AR_1_45 + AR_180 the result is same as for angleRange == 63 which is confusing
| CV_Assert(src.size().width > 0 && src.size().height > 0); | ||
| CV_Assert(src.channels() == 1); | ||
|
|
||
| Mat srcMat = src.getMat().clone(); |
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.
trans(..) function doesn't modify source matrix so it isn't necessary to clone src here. However since trans(..) could be called and therefore iterate over the same points several times for different angles probably it make sense to convert src to CV_32FC1 here instead of casting its content to float inside the trans(..)
| x = static_cast<float>(std::max((int)(x), -m)); | ||
| x = static_cast<float>(std::min((int)(x), m-2)); | ||
|
|
||
| dst.at<float>(rhoMax - r, theta-minAngle) += (float)(xLow)*static_cast<float>(src.at<T>(y + n, (int)(x) + m)) |
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.
Since dst is used as accumulator here it would be better to fill it with 0 prior to evaluation
| float sinTh = static_cast<float>(std::sin(theta*CV_PI/180.0)); | ||
|
|
||
| // Slope of the line = tan(90 - theta) | ||
| float a = -cosTh/sinTh; |
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.
sinTh could be 0 here if theta == 180
|
Superseded by #3090 |
Basic version of radon transform implemented.