-
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
Closed
Closed
Radon transform #549
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,11 +1,12 @@ | ||
| Extended Image Processing | ||
| ========================= | ||
|
|
||
| 1. Structured Forests | ||
| 1. Structured Forests | ||
| 2. Domain Transform Filter | ||
| 3. Guided Filter | ||
| 4. Adaptive Manifold Filter | ||
| 5. Joint Bilateral Filter | ||
| 6. Superpixels | ||
| 7. Graph segmentation | ||
| 8. Selective search from segmentation | ||
| 9. Radon Transform |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
111 changes: 111 additions & 0 deletions
111
modules/ximgproc/include/opencv2/ximgproc/radon_transform.hpp
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,111 @@ | ||
| /**************************************************************************************** | ||
| * By downloading, copying, installing or using the software you agree to this license. * | ||
| * If you do not agree to this license, do not download, install, * | ||
| * copy or use the software. * | ||
| * * | ||
| * * | ||
| * License Agreement * | ||
| * For Open Source Computer Vision Library * | ||
| * (3-clause BSD License) * | ||
| * * | ||
| * Copyright (C) 2000-2016, Intel Corporation, all rights reserved. * | ||
| * Copyright (C) 2009-2011, Willow Garage Inc., all rights reserved. * | ||
| * Copyright (C) 2009-2016, NVIDIA Corporation, all rights reserved. * | ||
| * Copyright (C) 2010-2013, Advanced Micro Devices, Inc., all rights reserved. * | ||
| * Copyright (C) 2015-2016, OpenCV Foundation, all rights reserved. * | ||
| * Copyright (C) 2015-2016, Itseez Inc., all rights reserved. * | ||
| * Third party copyrights are property of their respective owners. * | ||
| * * | ||
| * Redistribution and use in source and binary forms, with or without modification, * | ||
| * are permitted provided that the following conditions are met: * | ||
| * * | ||
| * Redistributions of source code must retain the above copyright notice, * | ||
| * this list of conditions and the following disclaimer. * | ||
| * * | ||
| * Redistributions in binary form must reproduce the above copyright notice, * | ||
| * this list of conditions and the following disclaimer in the documentation * | ||
| * and/or other materials provided with the distribution. * | ||
| * * | ||
| * Neither the names of the copyright holders nor the names of the contributors * | ||
| * may be used to endorse or promote products derived from this software * | ||
| * without specific prior written permission. * | ||
| * * | ||
| * This software is provided by the copyright holders and contributors "as is" and * | ||
| * any express or implied warranties, including, but not limited to, the implied * | ||
| * warranties of merchantability and fitness for a particular purpose are disclaimed. * | ||
| * In no event shall copyright holders or contributors be liable for any direct, * | ||
| * indirect, incidental, special, exemplary, or consequential damages * | ||
| * (including, but not limited to, procurement of substitute goods or services; * | ||
| * loss of use, data, or profits; or business interruption) however caused * | ||
| * and on any theory of liability, whether in contract, strict liability, * | ||
| * or tort (including negligence or otherwise) arising in any way out of * | ||
| * the use of this software, even if advised of the possibility of such damage. * | ||
| ****************************************************************************************/ | ||
|
|
||
| /** | ||
| * @author {aravind | [email protected]} | ||
| * Created on Sun, Feb 14 2016 | ||
| */ | ||
|
|
||
| /** | ||
| * Implementation of "The Radon Transform - Theory and Implementation" | ||
| * by "Toft, {Peter Aundal} and Sørensen, {John Aasted}" | ||
| * | ||
| * Online publication: http://petertoft.dk/PhD/ | ||
| * | ||
| */ | ||
|
|
||
| #ifndef __OPENCV_RADON_TRANSFORM_HPP__ | ||
| #define __OPENCV_RADON_TRANSFORM_HPP__ | ||
| #ifdef __cplusplus | ||
|
|
||
| #include "opencv2/core.hpp" | ||
|
|
||
| namespace cv { | ||
| namespace ximgproc { | ||
|
|
||
| /** | ||
| * Flags for range of angles | ||
| * AR_x_y : theta lies in [x, y] ( both x and y inclusive ) | ||
| */ | ||
|
|
||
| enum RadonAngleRange { AR_1_45 = 1, | ||
| AR_46_89 = 2, | ||
| AR_90 = 4, | ||
| AR_91_135 = 8, | ||
| AR_136_179 = 16, | ||
| AR_180 = 32 | ||
| }; | ||
|
|
||
| /** | ||
| * Specifies binary operations | ||
| * The enum specifies four binary operations, | ||
| * viz. Minimum, Maximum, Average and sum | ||
| * of the Radon transformed images. | ||
| */ | ||
|
|
||
| enum RadonOp { RT_MIN = 1, | ||
| RT_MAX = 2, | ||
| RT_AVE = 4, | ||
| RT_SUM = 8 | ||
| }; | ||
|
|
||
| /** | ||
| * [radonTransform Computes the Radon transform of the given image] | ||
| * @param src [Input source image] | ||
| * @param dst [Output image] | ||
| * @param angleRange [One of the enums, RadonAngleRange, defaults to 63 ( 1 to 180 degrees)] | ||
| * @param operation [One of the enums, RadonOp, defaults to RT_SUM ( SUM OPERATION )] | ||
| * @param opDst [Output image of the operation perfomed, defaults to noArray()] | ||
| */ | ||
| CV_EXPORTS void radonTransform( InputArray src, | ||
| OutputArray dst, | ||
| int angleRange = 63, | ||
| int operation = RT_SUM, | ||
| OutputArray opDst = noArray() | ||
| ); | ||
| } | ||
| } | ||
|
|
||
| #endif // __cplusplus | ||
| #endif // __OPENCV_RADON_TRANSFORM_HPP__ |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,152 @@ | ||
| /**************************************************************************************** | ||
| * By downloading, copying, installing or using the software you agree to this license. * | ||
| * If you do not agree to this license, do not download, install, * | ||
| * copy or use the software. * | ||
| * * | ||
| * * | ||
| * License Agreement * | ||
| * For Open Source Computer Vision Library * | ||
| * (3-clause BSD License) * | ||
| * * | ||
| * Copyright (C) 2000-2016, Intel Corporation, all rights reserved. * | ||
| * Copyright (C) 2009-2011, Willow Garage Inc., all rights reserved. * | ||
| * Copyright (C) 2009-2016, NVIDIA Corporation, all rights reserved. * | ||
| * Copyright (C) 2010-2013, Advanced Micro Devices, Inc., all rights reserved. * | ||
| * Copyright (C) 2015-2016, OpenCV Foundation, all rights reserved. * | ||
| * Copyright (C) 2015-2016, Itseez Inc., all rights reserved. * | ||
| * Third party copyrights are property of their respective owners. * | ||
| * * | ||
| * Redistribution and use in source and binary forms, with or without modification, * | ||
| * are permitted provided that the following conditions are met: * | ||
| * * | ||
| * Redistributions of source code must retain the above copyright notice, * | ||
| * this list of conditions and the following disclaimer. * | ||
| * * | ||
| * Redistributions in binary form must reproduce the above copyright notice, * | ||
| * this list of conditions and the following disclaimer in the documentation * | ||
| * and/or other materials provided with the distribution. * | ||
| * * | ||
| * Neither the names of the copyright holders nor the names of the contributors * | ||
| * may be used to endorse or promote products derived from this software * | ||
| * without specific prior written permission. * | ||
| * * | ||
| * This software is provided by the copyright holders and contributors "as is" and * | ||
| * any express or implied warranties, including, but not limited to, the implied * | ||
| * warranties of merchantability and fitness for a particular purpose are disclaimed. * | ||
| * In no event shall copyright holders or contributors be liable for any direct, * | ||
| * indirect, incidental, special, exemplary, or consequential damages * | ||
| * (including, but not limited to, procurement of substitute goods or services; * | ||
| * loss of use, data, or profits; or business interruption) however caused * | ||
| * and on any theory of liability, whether in contract, strict liability, * | ||
| * or tort (including negligence or otherwise) arising in any way out of * | ||
| * the use of this software, even if advised of the possibility of such damage. * | ||
| ****************************************************************************************/ | ||
|
|
||
| /** | ||
| * @author {aravind | [email protected]} | ||
| * Created on Mon, Feb 15 2016 | ||
| */ | ||
|
|
||
| /** | ||
| * | ||
| * C++ Sample program for Radon transform | ||
| * | ||
| */ | ||
|
|
||
| // Necessary headers | ||
| #include <math.h> | ||
| #include <stdlib.h> | ||
| #include <string> | ||
| #include <iostream> | ||
|
|
||
| #include <opencv2/imgproc.hpp> | ||
| #include <opencv2/highgui.hpp> | ||
| #include <opencv2/core/utility.hpp> | ||
|
|
||
| #include <opencv2/ximgproc.hpp> | ||
|
|
||
| using namespace cv::ximgproc; | ||
| using namespace cv; | ||
| using namespace std; | ||
|
|
||
| static void help ( const char **argv ) { | ||
| std::cout << std::endl \ | ||
| << "This program demonstrates the usage of Radon transform." \ | ||
| << std::endl << std::endl << "USAGE: " << std::endl \ | ||
| << argv[0] << " <filename> <angle-range-option> <operation>" \ | ||
| << std::endl << std::endl; | ||
|
|
||
| std::cout << "Default for <angle-range-option> computes for " \ | ||
| << "all angles between 1 and 180 degrees." \ | ||
| << " ( @see cv::ximgproc::RadonAngleRange )" << std::endl \ | ||
| << "Default for <operation> is RT_SUM." \ | ||
| << " ( @see cv::ximgproc::RadonOp )" << std::endl \ | ||
| << std::endl; \ | ||
|
|
||
| } | ||
|
|
||
| static bool argParser( int argc, const char **argv, | ||
| cv::Mat & img, | ||
| int & radonAngleRange, | ||
| int & radonOperation ) { | ||
| if (argc > 4) { | ||
| std::cout << "Incorrect arguments" << std::endl; | ||
| return false; | ||
| } | ||
|
|
||
| const char *filename = argc >= 2 ? argv[1] | ||
| : "./radon_input.jpg"; | ||
| img = imread(filename, 0); | ||
| if( img.empty() ) { | ||
| std::cout << "Unable to load image: " << filename << std::endl; | ||
| return false; | ||
| } | ||
|
|
||
| radonAngleRange = ( argc >= 3 ) ? atoi(argv[2]) : 63; // 1 to 180 degrees | ||
| radonOperation = ( argc >= 4 ) ? atoi(argv[3]) : RT_SUM; // Sum up elements | ||
|
|
||
| return true; | ||
| } | ||
|
|
||
| int main( int argc, const char ** argv ) { | ||
|
|
||
| cv::Mat img; | ||
| int radonAngleRange, radonOperation; | ||
|
|
||
| // Display help | ||
| help( argv ); | ||
|
|
||
| if( !argParser( argc, argv, img, radonAngleRange, radonOperation) ) { | ||
| return -1; | ||
| } | ||
|
|
||
| cv::Mat radonTr, operImg; | ||
|
|
||
| // Computing the Radon transform with appropriate params | ||
| radonTransform( img, radonTr, radonAngleRange, radonOperation, operImg ); | ||
|
|
||
| // Mat for displaying the Radon transform | ||
| cv::Mat radonTrDisp; | ||
|
|
||
| double minVal, maxVal; | ||
| minMaxLoc(radonTr, &minVal, &maxVal); | ||
|
|
||
| // Normalizing radonTr so as to display as a CV_8U image | ||
| radonTr -= minVal; | ||
| radonTr.convertTo( radonTrDisp, CV_8U, 255.0/(maxVal-minVal) ); | ||
|
|
||
| // Normalizing operImg so as to display as a CV_8U image | ||
| minMaxLoc(operImg, &minVal, &maxVal); | ||
| operImg -= minVal; | ||
| operImg.convertTo(operImg, CV_8U, 255.0/(maxVal-minVal)); | ||
|
|
||
| // Displaying the images | ||
| cv::imshow("Input", img); | ||
| cv::imshow("Radon transform", radonTrDisp); | ||
| cv::imshow("Operation(image)", operImg); | ||
|
|
||
| cv::waitKey(0); | ||
| cv::destroyAllWindows(); | ||
|
|
||
| return 0; | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
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 ?