commit
d2548239bb
59 changed files with 946 additions and 102 deletions
@ -0,0 +1,30 @@ |
|||||||
|
<!-- |
||||||
|
If you have a question rather than reporting a bug please go to http://answers.opencv.org where you get much faster responses. |
||||||
|
If you need further assistance please read [How To Contribute](https://github.com/opencv/opencv/wiki/How_to_contribute). |
||||||
|
|
||||||
|
This is a template helping you to create an issue which can be processed as quickly as possible. This is the bug reporting section for the OpenCV library. |
||||||
|
--> |
||||||
|
|
||||||
|
##### System information (version) |
||||||
|
<!-- Example |
||||||
|
- OpenCV => 3.1 |
||||||
|
- Operating System / Platform => Windows 64 Bit |
||||||
|
- Compiler => Visual Studio 2015 |
||||||
|
--> |
||||||
|
|
||||||
|
- OpenCV => :grey_question: |
||||||
|
- Operating System / Platform => :grey_question: |
||||||
|
- Compiler => :grey_question: |
||||||
|
|
||||||
|
##### Detailed description |
||||||
|
|
||||||
|
<!-- your description --> |
||||||
|
|
||||||
|
##### Steps to reproduce |
||||||
|
|
||||||
|
<!-- to add code example fence it with triple backticks and optional file extension |
||||||
|
```.cpp |
||||||
|
// C++ code example |
||||||
|
``` |
||||||
|
or attach as .txt or .zip file |
||||||
|
--> |
@ -0,0 +1,9 @@ |
|||||||
|
<!-- Please use this line to close one or multiple issues when this pullrequest gets merged |
||||||
|
You can add another line right under the first one: |
||||||
|
resolves #1234 |
||||||
|
resolves #1235 |
||||||
|
--> |
||||||
|
|
||||||
|
### This pullrequest changes |
||||||
|
|
||||||
|
<!-- Please describe what your pullrequest is changing --> |
@ -1,3 +1,3 @@ |
|||||||
## Contributing guidelines |
## Contributing guidelines |
||||||
|
|
||||||
All guidelines for contributing to the OpenCV repository can be found at [`How to contribute guideline`](https://github.com/Itseez/opencv/wiki/How_to_contribute). |
All guidelines for contributing to the OpenCV repository can be found at [`How to contribute guideline`](https://github.com/opencv/opencv/wiki/How_to_contribute). |
||||||
|
@ -1,59 +1,71 @@ |
|||||||
An overview of the contrib modules and a small explanation |
An overview of the opencv_contrib modules |
||||||
---------------------------------------------------------- |
----------------------------------------- |
||||||
|
|
||||||
This list gives an overview of all modules available inside the contrib repository. |
This list gives an overview of all modules available inside the contrib repository. |
||||||
These are also the correct names for disabling the building of a specific module by adding |
To turn off building one of these module repositories, set the names in bold below to <reponame> |
||||||
|
|
||||||
``` |
``` |
||||||
$ cmake -D OPENCV_EXTRA_MODULES_PATH=<opencv_contrib>/modules -D BUILD_opencv_reponame=OFF <opencv_source_directory> |
$ cmake -D OPENCV_EXTRA_MODULES_PATH=<opencv_contrib>/modules -D BUILD_opencv_<reponame>=OFF <opencv_source_directory> |
||||||
``` |
``` |
||||||
|
|
||||||
1. **opencv_adas**: Advanced Driver Assistance Systems module with Forward Collision Warning. |
1. **aruco**: ArUco and ChArUco Markers -- Augmented reality ArUco marker and "ChARUco" markers where ArUco markers embedded inside the white areas of the checker board. |
||||||
|
|
||||||
2. **opencv_bgsegm**: Improved Adaptive Background Mixture Model for Real-time Tracking / Visual Tracking of Human Visitors under Variable-Lighting Conditions. |
2. **bgsegm**: Background Segmentation -- Improved Adaptive Background Mixture Model and use for real time human tracking under Variable-Lighting Conditions. |
||||||
|
|
||||||
3. **opencv_bioinspired**: Biologically inspired vision models and derivated tools. |
3. **bioinspired**: Biological Vision -- Biologically inspired vision model: minimize noise and luminance variance, transient event segmentation, high dynamic range tone mapping methods. |
||||||
|
|
||||||
4. **opencv_ ccalib**: Custom Calibration Pattern for 3D reconstruction. |
4. **ccalib**: Custom Calibration -- Patterns for 3D reconstruction, omnidirectional camera calibration, random pattern calibration and multi-camera calibration. |
||||||
|
|
||||||
5. **opencv_cvv**: GUI for Interactive Visual Debugging of Computer Vision Programs. |
5. **cnn_3dobj**: Deep Object Recognition and Pose -- Uses Caffe Deep Neural Net library to build, train and test a CNN model of visual object recognition and pose. |
||||||
|
|
||||||
6. **opencv_datasets**: Interface for interfacing with existing computer vision databases. |
6. **contrib_world**: opencv_contrib holder -- contrib_world is the module that when built, contains all other opencv_contrib modules. It may be used for the more convenient redistribution of opencv binaries. |
||||||
|
|
||||||
7. **opencv_datasettools**: Tools for working with different datasets. |
7. **cvv**: Computer Vision Debugger -- Simple code that you can add to your program that pops up a GUI allowing you to interactively and visually debug computer vision programs. |
||||||
|
|
||||||
8. **opencv_face**: Recently added face recognition software which is not yet stabilized. |
8. **datasets**: Datasets Reader -- Code for reading existing computer vision databases and samples of using the readers to train, test and run using that dataset's data. |
||||||
|
|
||||||
9. **opencv_latentsvm**: Implementation of the LatentSVM detector algorithm. |
9. **dnn**: Deep Neural Networks (DNNs) -- This module can read in image recogniton networks trained in the Caffe neural netowrk library and run them efficiently on CPU. |
||||||
|
|
||||||
10. **opencv_line_descriptor**: Binary descriptors for lines extracted from an image. |
10. **dnns_easily_fooled**: Subvert DNNs -- This code can use the activations in a network to fool the networks into recognizing something else. |
||||||
|
|
||||||
11. **opencv_matlab**: OpenCV Matlab Code Generator. |
11. **dpm**: Deformable Part Model -- Felzenszwalb's Cascade with deformable parts object recognition code. |
||||||
|
|
||||||
12. **opencv_optflow**: Optical Flow Algorithms for tracking points. |
12. **face**: Face Recognition -- Face recognition techniques: Eigen, Fisher and Local Binary Pattern Histograms LBPH methods. |
||||||
|
|
||||||
13. **opencv_reg**: Image Registration module. |
13. **fuzzy**: Fuzzy Logic in Vision -- Fuzzy logic image transform and inverse; Fuzzy image processing. |
||||||
|
|
||||||
14. **opencv_rgbd**: RGB-Depth Processing module. |
14. **hdf**: Hierarchical Data Storage -- This module contains I/O routines for Hierarchical Data Format: https://en.m.wikipedia.org/wiki/Hierarchical_Data_Format meant to store large amounts of data. |
||||||
|
|
||||||
15. **opencv_saliency**: Saliency API, understanding where humans focus given a scene. |
15. **line_descriptor**: Line Segment Extract and Match -- Methods of extracting, describing and latching line segments using binary descriptors. |
||||||
|
|
||||||
16. **opencv_surface_matching**: Surface Matching Algorithm Through 3D Features. |
16. **matlab**: Matlab Interface -- OpenCV Matlab Mex wrapper code generator for certain opencv core modules. |
||||||
|
|
||||||
17. **opencv_text**: Scene Text Detection and Recognition in Natural Scene Images. |
17. **optflow**: Optical Flow -- Algorithms for running and evaluating deepflow, simpleflow, sparsetodenseflow and motion templates (silhouette flow). |
||||||
|
|
||||||
18. **opencv_tracking**: Long-term optical tracking API. |
18. **plot**: Plotting -- The plot module allows you to easily plot data in 1D or 2D. |
||||||
|
|
||||||
19. **opencv_xfeatures2d**: Extra 2D Features Framework containing experimental and non-free 2D feature algorithms. |
19. **reg**: Image Registration -- Pixels based image registration for precise alignment. Follows the paper "Image Alignment and Stitching: A Tutorial", by Richard Szeliski. |
||||||
|
|
||||||
20. **opencv_ximgproc**: Extended Image Processing: Structured Forests / Domain Transform Filter / Guided Filter / Adaptive Manifold Filter / Joint Bilateral Filter / Superpixels. |
20. **rgbd**: RGB-Depth Processing module -- Linemod 3D object recognition; Fast surface normals and 3D plane finding. 3D visual odometry |
||||||
|
|
||||||
21. **opencv_xobjdetect**: Integral Channel Features Detector Framework. |
21. **saliency**: Saliency API -- Where humans would look in a scene. Has routines for static, motion and "objectness" saliency. |
||||||
|
|
||||||
22. **opencv_xphoto**: Additional photo processing algorithms: Color balance / Denoising / Inpainting. |
22. **sfm**: Structure from Motion -- This module contains algorithms to perform 3d reconstruction from 2d images. The core of the module is a light version of Libmv. |
||||||
|
|
||||||
23. **opencv_stereo**: Stereo Correspondence done with different descriptors: Census / CS-Census / MCT / BRIEF / MV. |
23. **stereo**: Stereo Correspondence -- Stereo matching done with different descriptors: Census / CS-Census / MCT / BRIEF / MV. |
||||||
|
|
||||||
24. **opencv_hdf**: Hierarchical Data Format I/O. |
24. **structured_light**: Structured Light Use -- How to generate and project gray code patterns and use them to find dense depth in a scene. |
||||||
|
|
||||||
25. **opencv_fuzzy**: New module focused on the fuzzy image processing. |
25. **surface_matching**: Point Pair Features -- Implements 3d object detection and localization using multimodal point pair features. |
||||||
|
|
||||||
|
26. **text**: Visual Text Matching -- In a visual scene, detect text, segment words and recognise the text. |
||||||
|
|
||||||
|
27. **tracking**: Vision Based Object Tracking -- Use and/or evaluate one of 5 different visual object tracking techniques. |
||||||
|
|
||||||
|
28. **xfeatures2d**: Features2D extra -- Extra 2D Features Framework containing experimental and non-free 2D feature detector/descriptor algorithms. SURF, SIFT, BRIEF, Censure, Freak, LUCID, Daisy, Self-similar. |
||||||
|
|
||||||
|
29. **ximgproc**: Extended Image Processing -- Structured Forests / Domain Transform Filter / Guided Filter / Adaptive Manifold Filter / Joint Bilateral Filter / Superpixels. |
||||||
|
|
||||||
|
30. **xobjdetect**: Boosted 2D Object Detection -- Uses a Waldboost cascade and local binary patterns computed as integral features for 2D object detection. |
||||||
|
|
||||||
|
31. **xphoto**: Extra Computational Photography -- Additional photo processing algorithms: Color balance / Denoising / Inpainting. |
||||||
|
Before Width: | Height: | Size: 79 KiB After Width: | Height: | Size: 11 KiB |
Before Width: | Height: | Size: 4.7 KiB After Width: | Height: | Size: 1.1 KiB |
After Width: | Height: | Size: 31 KiB |
Before Width: | Height: | Size: 28 KiB |
@ -1,2 +1,2 @@ |
|||||||
set(the_description "Structured Light API") |
set(the_description "Structured Light API") |
||||||
ocv_define_module(structured_light opencv_core opencv_calib3d opencv_imgproc opencv_highgui opencv_features2d opencv_rgbd OPTIONAL opencv_viz) |
ocv_define_module(structured_light opencv_core opencv_calib3d opencv_imgproc opencv_highgui opencv_features2d opencv_rgbd OPTIONAL opencv_viz WRAP python java) |
||||||
|
@ -0,0 +1,67 @@ |
|||||||
|
/*
|
||||||
|
* 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) |
||||||
|
* |
||||||
|
* 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. |
||||||
|
*/ |
||||||
|
|
||||||
|
#ifndef __OPENCV_PAILLOUFILTER_HPP__ |
||||||
|
#define __OPENCV_PAILLOUFILTER_HPP__ |
||||||
|
#ifdef __cplusplus |
||||||
|
|
||||||
|
#include <opencv2/core.hpp> |
||||||
|
|
||||||
|
namespace cv { |
||||||
|
namespace ximgproc { |
||||||
|
|
||||||
|
//! @addtogroup ximgproc_filters
|
||||||
|
//! @{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Applies Paillou filter to an image. |
||||||
|
* |
||||||
|
* For more details about this implementation, please see @cite paillou1997detecting |
||||||
|
* |
||||||
|
* @param op Source 8-bit or 16bit image, 1-channel or 3-channel image. |
||||||
|
* @param _dst result CV_32F image with same numeber of channel than op. |
||||||
|
* @param omega double see paper |
||||||
|
* @param alpha double see paper |
||||||
|
* |
||||||
|
* @sa GradientPaillouX, GradientPaillouY |
||||||
|
*/ |
||||||
|
CV_EXPORTS void GradientPaillouY(InputArray op, OutputArray _dst, double alpha, double omega); |
||||||
|
CV_EXPORTS void GradientPaillouX(InputArray op, OutputArray _dst, double alpha, double omega); |
||||||
|
|
||||||
|
} |
||||||
|
} |
||||||
|
#endif |
||||||
|
#endif |
@ -0,0 +1,107 @@ |
|||||||
|
/*
|
||||||
|
* 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) |
||||||
|
* |
||||||
|
* 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. |
||||||
|
*/ |
||||||
|
|
||||||
|
#include <opencv2/core.hpp> |
||||||
|
#include <opencv2/core/utility.hpp> |
||||||
|
#include <opencv2/highgui.hpp> |
||||||
|
#include <opencv2/ximgproc.hpp> |
||||||
|
#include "opencv2/ximgproc/paillou_filter.hpp" |
||||||
|
|
||||||
|
using namespace cv; |
||||||
|
using namespace cv::ximgproc; |
||||||
|
|
||||||
|
#include <iostream> |
||||||
|
using namespace std; |
||||||
|
|
||||||
|
int aa = 100, ww = 10; |
||||||
|
Mat dx, dy; |
||||||
|
UMat img; |
||||||
|
const char* window_name = "Gradient Modulus"; |
||||||
|
|
||||||
|
static void DisplayImage(Mat x,string s) |
||||||
|
{ |
||||||
|
vector<Mat> sx; |
||||||
|
split(x, sx); |
||||||
|
vector<double> minVal(3), maxVal(3); |
||||||
|
for (int i = 0; i < static_cast<int>(sx.size()); i++) |
||||||
|
{ |
||||||
|
minMaxLoc(sx[i], &minVal[i], &maxVal[i]); |
||||||
|
} |
||||||
|
maxVal[0] = *max_element(maxVal.begin(), maxVal.end()); |
||||||
|
minVal[0] = *min_element(minVal.begin(), minVal.end()); |
||||||
|
Mat uc; |
||||||
|
x.convertTo(uc, CV_8U,255/(maxVal[0]-minVal[0]),-255*minVal[0]/(maxVal[0]-minVal[0])); |
||||||
|
imshow(s, uc); |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @function paillouFilter |
||||||
|
* @brief Trackbar callback |
||||||
|
*/ |
||||||
|
static void PaillouFilter(int, void*) |
||||||
|
{ |
||||||
|
Mat dst; |
||||||
|
double a=aa/100.0,w=ww/100.0; |
||||||
|
Mat rx,ry; |
||||||
|
GradientPaillouX(img,rx,a,w); |
||||||
|
GradientPaillouY(img,ry,a,w); |
||||||
|
DisplayImage(rx, "Gx"); |
||||||
|
DisplayImage(ry, "Gy"); |
||||||
|
add(rx.mul(rx),ry.mul(ry),dst); |
||||||
|
sqrt(dst,dst); |
||||||
|
DisplayImage(dst, window_name ); |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
int main(int argc, char* argv[]) |
||||||
|
{ |
||||||
|
if (argc==2) |
||||||
|
imread(argv[1]).copyTo(img); |
||||||
|
if (img.empty()) |
||||||
|
{ |
||||||
|
cout << "File not found or empty image\n"; |
||||||
|
} |
||||||
|
imshow("Original",img); |
||||||
|
namedWindow( window_name, WINDOW_AUTOSIZE ); |
||||||
|
|
||||||
|
/// Create a Trackbar for user to enter threshold
|
||||||
|
createTrackbar( "a:",window_name, &aa, 400, PaillouFilter ); |
||||||
|
createTrackbar( "w:", window_name, &ww, 400, PaillouFilter ); |
||||||
|
PaillouFilter(0,NULL); |
||||||
|
waitKey(); |
||||||
|
return 0; |
||||||
|
} |
@ -0,0 +1,486 @@ |
|||||||
|
#include "precomp.hpp" |
||||||
|
#include "opencv2/highgui.hpp" |
||||||
|
#include <math.h> |
||||||
|
#include <vector> |
||||||
|
#include <iostream> |
||||||
|
|
||||||
|
namespace cv { |
||||||
|
namespace ximgproc { |
||||||
|
|
||||||
|
/*
|
||||||
|
If you use this code please cite this @cite paillou1997detecting |
||||||
|
Detecting step edges in noisy SAR images: a new linear operator IEEE Transactions on Geoscience and Remote Sensing (Volume:35 , Issue: 1 ) 1997 |
||||||
|
*/ |
||||||
|
|
||||||
|
|
||||||
|
class ParallelGradientPaillouYCols: public ParallelLoopBody |
||||||
|
{ |
||||||
|
private: |
||||||
|
Mat &img; |
||||||
|
Mat &dst; |
||||||
|
double a; |
||||||
|
double w; |
||||||
|
bool verbose; |
||||||
|
public: |
||||||
|
ParallelGradientPaillouYCols(Mat& imgSrc, Mat &d,double aa,double ww): |
||||||
|
img(imgSrc), |
||||||
|
dst(d), |
||||||
|
a(aa), |
||||||
|
w(ww), |
||||||
|
verbose(false) |
||||||
|
{} |
||||||
|
void Verbose(bool b){verbose=b;} |
||||||
|
virtual void operator()(const Range& range) const |
||||||
|
{ |
||||||
|
CV_Assert(img.depth()==CV_8UC1 || img.depth()==CV_16SC1 || img.depth()==CV_16UC1); |
||||||
|
CV_Assert(dst.depth()==CV_32FC1); |
||||||
|
if (verbose) |
||||||
|
std::cout << getThreadNum()<<"# :Start from row " << range.start << " to " << range.end-1<<" ("<<range.end-range.start<<" loops)" << std::endl; |
||||||
|
float *f2; |
||||||
|
int tailleSequence=(img.rows>img.cols)?img.rows:img.cols; |
||||||
|
Mat matYp(1,tailleSequence,CV_64FC1), matYm(1,tailleSequence,CV_64FC1); |
||||||
|
double *yp=matYp.ptr<double>(0), *ym=matYm.ptr<double>(0); |
||||||
|
int rows=img.rows,cols=img.cols; |
||||||
|
|
||||||
|
// Equation 12 p193
|
||||||
|
double b1=-2*exp(-a)*cosh(w); |
||||||
|
double a1=2*exp(-a)*cosh(w)-exp(-2*a)-1; |
||||||
|
double b2=exp(-2*a); |
||||||
|
|
||||||
|
switch(img.depth()){ |
||||||
|
case CV_8U : |
||||||
|
for (int j=range.start;j<range.end;j++) |
||||||
|
{ |
||||||
|
// Equation 26 p194
|
||||||
|
uchar *c1 = img.ptr(0)+j; |
||||||
|
f2 = dst.ptr<float>(0)+j; |
||||||
|
double border=*c1; |
||||||
|
yp[0] = *c1 ; |
||||||
|
c1+=cols; |
||||||
|
yp[1] = *c1 - b1*yp[0]-b2*border; |
||||||
|
c1+=cols; |
||||||
|
for (int i=2;i<rows;i++,c1+=cols) |
||||||
|
yp[i] = *c1-b1*yp[i-1]-b2*yp[i-2]; |
||||||
|
// Equation 27 p194
|
||||||
|
c1 = img.ptr(rows-1)+j; |
||||||
|
border=*c1; |
||||||
|
ym[rows - 1] = *c1; |
||||||
|
c1 -= cols; |
||||||
|
ym[rows-2] =*c1 - b1*ym[rows-1]; |
||||||
|
c1 -= cols; |
||||||
|
for (int i=rows-3;i>=0;i--,c1-=cols) |
||||||
|
ym[i]=*c1-b1*ym[i+1]-b2*ym[i+2]; |
||||||
|
// Equation 25 p193
|
||||||
|
for (int i=0;i<rows;i++,f2+=cols) |
||||||
|
*f2 = (float)(a1*(ym[i]-yp[i])); |
||||||
|
} |
||||||
|
break; |
||||||
|
case CV_16S : |
||||||
|
for (int j = range.start; j<range.end; j++) |
||||||
|
{ |
||||||
|
// Equation 26 p194
|
||||||
|
short *c1 = img.ptr<short>(0) + j; |
||||||
|
f2 = dst.ptr<float>(0) + j; |
||||||
|
double border = *c1; |
||||||
|
yp[0] = *c1; |
||||||
|
c1 += cols; |
||||||
|
yp[1] = *c1 - b1*yp[0] - b2*border; |
||||||
|
c1 += cols; |
||||||
|
for (int i = 2; i<rows; i++, c1 += cols) |
||||||
|
yp[i] = *c1 - b1*yp[i - 1] - b2*yp[i - 2]; |
||||||
|
// Equation 27 p194
|
||||||
|
c1 = img.ptr<short>(rows - 1) + j; |
||||||
|
border = *c1; |
||||||
|
ym[rows - 1] = *c1; |
||||||
|
c1 -= cols; |
||||||
|
ym[rows - 2] = *c1 - b1*ym[rows - 1]; |
||||||
|
c1 -= cols; |
||||||
|
for (int i = rows - 3; i >= 0; i--, c1 -= cols) |
||||||
|
ym[i] = *c1 - b1*ym[i + 1] - b2*ym[i + 2]; |
||||||
|
// Equation 25 p193
|
||||||
|
for (int i = 0; i<rows; i++, f2 += cols) |
||||||
|
*f2 = (float)(a1*(ym[i] - yp[i])); |
||||||
|
} |
||||||
|
break; |
||||||
|
case CV_16U : |
||||||
|
for (int j = range.start; j<range.end; j++) |
||||||
|
{ |
||||||
|
// Equation 26 p194
|
||||||
|
ushort *c1 = img.ptr<ushort>(0) + j; |
||||||
|
f2 = dst.ptr<float>(0) + j; |
||||||
|
double border = *c1; |
||||||
|
yp[0] = *c1; |
||||||
|
c1 += cols; |
||||||
|
yp[1] = *c1 - b1*yp[0] - b2*border; |
||||||
|
c1 += cols; |
||||||
|
for (int i = 2; i<rows; i++, c1 += cols) |
||||||
|
yp[i] = *c1 - b1*yp[i - 1] - b2*yp[i - 2]; |
||||||
|
// Equation 27 p194
|
||||||
|
c1 = img.ptr<ushort>(rows - 1) + j; |
||||||
|
border = *c1; |
||||||
|
ym[rows - 1] = *c1; |
||||||
|
c1 -= cols; |
||||||
|
ym[rows - 2] = *c1 - b1*ym[rows - 1]; |
||||||
|
c1 -= cols; |
||||||
|
for (int i = rows - 3; i >= 0; i--, c1 -= cols) |
||||||
|
ym[i] = *c1 - b1*ym[i + 1] - b2*ym[i + 2]; |
||||||
|
// Equation 25 p193
|
||||||
|
for (int i = 0; i<rows; i++, f2 += cols) |
||||||
|
*f2 = (float)(a1*(ym[i] - yp[i])); |
||||||
|
} |
||||||
|
break; |
||||||
|
default : |
||||||
|
return ; |
||||||
|
} |
||||||
|
}; |
||||||
|
ParallelGradientPaillouYCols& operator=(const ParallelGradientPaillouYCols &) { |
||||||
|
return *this; |
||||||
|
}; |
||||||
|
}; |
||||||
|
|
||||||
|
|
||||||
|
class ParallelGradientPaillouYRows: public ParallelLoopBody |
||||||
|
{ |
||||||
|
private: |
||||||
|
Mat &img; |
||||||
|
Mat &dst; |
||||||
|
double a; |
||||||
|
double w; |
||||||
|
bool verbose; |
||||||
|
|
||||||
|
public: |
||||||
|
ParallelGradientPaillouYRows(Mat& imgSrc, Mat &d,double aa,double ww): |
||||||
|
img(imgSrc), |
||||||
|
dst(d), |
||||||
|
a(aa), |
||||||
|
w(ww), |
||||||
|
verbose(false) |
||||||
|
{} |
||||||
|
void Verbose(bool b){verbose=b;} |
||||||
|
virtual void operator()(const Range& range) const |
||||||
|
{ |
||||||
|
CV_Assert(img.depth()==CV_32FC1); |
||||||
|
if (verbose) |
||||||
|
std::cout << getThreadNum()<<"# :Start from row " << range.start << " to " << range.end-1<<" ("<<range.end-range.start<<" loops)" << std::endl; |
||||||
|
float *iy,*iy0; |
||||||
|
int tailleSequence=(img.rows>img.cols)?img.rows:img.cols; |
||||||
|
Mat matIym(1,tailleSequence,CV_64FC1), matIyp(1,tailleSequence,CV_64FC1); |
||||||
|
double *iym=matIym.ptr<double>(0), *iyp=matIyp.ptr<double>(0); |
||||||
|
int cols=img.cols; |
||||||
|
|
||||||
|
// Equation 13 p193
|
||||||
|
double d=(1-2*exp(-a)*cosh(w)+exp(-2*a))/(2*a*exp(-a)*sinh(w)+w*(1-exp(-2*a))); |
||||||
|
double c1=a*d; |
||||||
|
double c2=w*d; |
||||||
|
// Equation 12 p193
|
||||||
|
double b1=-2*exp(-a)*cosh(w); |
||||||
|
double b2=exp(-2*a); |
||||||
|
// Equation 14 p193
|
||||||
|
double a0p=c2; |
||||||
|
double a1p=(c1*sinh(w)-c2*cosh(w))*exp(-a); |
||||||
|
double a1m=a1p-c2*b1; |
||||||
|
double a2m=-c2*b2; |
||||||
|
|
||||||
|
for (int i=range.start;i<range.end;i++) |
||||||
|
{ |
||||||
|
iy0 = img.ptr<float>(i); |
||||||
|
int j=0; |
||||||
|
iyp[0] = a0p*iy0[0] ; |
||||||
|
iyp[1] = a0p*iy0[1] + a1p*iy0[0] - b1*iyp[0]; |
||||||
|
iy0 += 2; |
||||||
|
for (j=2;j<cols;j++,iy0++) |
||||||
|
iyp[j] = a0p*iy0[0] + a1p*iy0[-1] - b1*iyp[j-1] - b2*iyp[j-2]; |
||||||
|
iy0 = img.ptr<float>(i)+cols-1; |
||||||
|
iym[cols-1] = 0; |
||||||
|
iy0--; |
||||||
|
iym[cols-2] = a1m*iy0[1] - b1*iym[cols-1]; |
||||||
|
iy0--; |
||||||
|
for (j=cols-3;j>=0;j--,iy0--) |
||||||
|
iym[j] = a1m*iy0[1] + a2m*iy0[2] - b1*iym[j+1] - b2*iym[j+2]; |
||||||
|
iy = dst.ptr<float>(i); |
||||||
|
for (j=0;j<cols;j++,iy++) |
||||||
|
*iy = (float)(iym[j]+iyp[j]); |
||||||
|
} |
||||||
|
|
||||||
|
}; |
||||||
|
ParallelGradientPaillouYRows& operator=(const ParallelGradientPaillouYRows &) { |
||||||
|
return *this; |
||||||
|
}; |
||||||
|
}; |
||||||
|
|
||||||
|
|
||||||
|
class ParallelGradientPaillouXCols: public ParallelLoopBody |
||||||
|
{ |
||||||
|
private: |
||||||
|
Mat &img; |
||||||
|
Mat &dst; |
||||||
|
double a; |
||||||
|
double w; |
||||||
|
bool verbose; |
||||||
|
|
||||||
|
public: |
||||||
|
ParallelGradientPaillouXCols(Mat& imgSrc, Mat &d,double aa,double ww): |
||||||
|
img(imgSrc), |
||||||
|
dst(d), |
||||||
|
a(aa), |
||||||
|
w(ww), |
||||||
|
verbose(false) |
||||||
|
{} |
||||||
|
void Verbose(bool b){verbose=b;} |
||||||
|
virtual void operator()(const Range& range) const |
||||||
|
{ |
||||||
|
CV_Assert(img.depth()==CV_32FC1); |
||||||
|
if (verbose) |
||||||
|
std::cout << getThreadNum() << "# :Start from row " << range.start << " to " << range.end - 1 << " (" << range.end - range.start << " loops)" << std::endl; |
||||||
|
float *iy, *iy0; |
||||||
|
int tailleSequence = (img.rows>img.cols) ? img.rows : img.cols; |
||||||
|
Mat matIym(1,tailleSequence,CV_64FC1), matIyp(1,tailleSequence,CV_64FC1); |
||||||
|
double *iym=matIym.ptr<double>(0), *iyp=matIyp.ptr<double>(0); |
||||||
|
int rows = img.rows,cols=img.cols; |
||||||
|
|
||||||
|
// Equation 13 p193
|
||||||
|
double d = (1 - 2 * exp(-a)*cosh(w) + exp(-2 * a)) / (2 * a*exp(-a)*sinh(w) + w*(1 - exp(-2 * a))); |
||||||
|
double c1 = a*d; |
||||||
|
double c2 = w*d; |
||||||
|
// Equation 12 p193
|
||||||
|
double b1 = -2 * exp(-a)*cosh(w); |
||||||
|
double b2 = exp(-2 * a); |
||||||
|
// Equation 14 p193
|
||||||
|
double a0p = c2; |
||||||
|
double a1p = (c1*sinh(w) - c2*cosh(w))*exp(-a); |
||||||
|
double a1m = a1p - c2*b1; |
||||||
|
double a2m = -c2*b2; |
||||||
|
|
||||||
|
for (int j = range.start; j<range.end; j++) |
||||||
|
{ |
||||||
|
iy0 = img.ptr<float>(0)+j; |
||||||
|
iyp[0] = a0p*iy0[0]; |
||||||
|
iy0 +=cols; |
||||||
|
iyp[1] = a0p*iy0[0] + a1p*iy0[-cols] - b1*iyp[0]; |
||||||
|
iy0 +=cols; |
||||||
|
for (int i = 2; i<rows; i++, iy0+=cols) |
||||||
|
iyp[i] = a0p*iy0[0] + a1p*iy0[-cols] - b1*iyp[i - 1] - b2*iyp[i - 2]; |
||||||
|
iy0 = img.ptr<float>(rows-1) + j; |
||||||
|
iym[rows - 1] = 0; |
||||||
|
iy0 -=cols; |
||||||
|
iym[rows - 2] = a1m*iy0[cols] - b1*iym[rows-1]; |
||||||
|
iy0-=cols; |
||||||
|
for (int i = rows - 3; i >= 0; i--, iy0-=cols) |
||||||
|
iym[i] = a1m*iy0[cols] + a2m*iy0[2*cols] - b1*iym[i + 1] - b2*iym[i + 2]; |
||||||
|
iy = dst.ptr<float>(0)+j; |
||||||
|
for (int i = 0; i<rows; i++, iy+=cols) |
||||||
|
*iy = (float)(iym[i] + iyp[i]); |
||||||
|
} |
||||||
|
|
||||||
|
}; |
||||||
|
ParallelGradientPaillouXCols& operator=(const ParallelGradientPaillouXCols &) { |
||||||
|
return *this; |
||||||
|
}; |
||||||
|
}; |
||||||
|
|
||||||
|
|
||||||
|
class ParallelGradientPaillouXRows: public ParallelLoopBody |
||||||
|
{ |
||||||
|
private: |
||||||
|
Mat &img; |
||||||
|
Mat &im1; |
||||||
|
double a; |
||||||
|
double w; |
||||||
|
bool verbose; |
||||||
|
|
||||||
|
public: |
||||||
|
ParallelGradientPaillouXRows(Mat& imgSrc, Mat &d,double aa,double ww): |
||||||
|
img(imgSrc), |
||||||
|
im1(d), |
||||||
|
a(aa), |
||||||
|
w(ww), |
||||||
|
verbose(false) |
||||||
|
{} |
||||||
|
void Verbose(bool b){verbose=b;} |
||||||
|
virtual void operator()(const Range& range) const |
||||||
|
{ |
||||||
|
if (verbose) |
||||||
|
std::cout << getThreadNum()<<"# :Start from row " << range.start << " to " << range.end-1<<" ("<<range.end-range.start<<" loops)" << std::endl; |
||||||
|
float *f2; |
||||||
|
int tailleSequence = (img.rows>img.cols) ? img.rows : img.cols; |
||||||
|
Mat matYp(1,tailleSequence,CV_64FC1), matYm(1,tailleSequence,CV_64FC1); |
||||||
|
double *yp=matYp.ptr<double>(0), *ym=matYm.ptr<double>(0); |
||||||
|
int cols = img.cols; |
||||||
|
|
||||||
|
// Equation 12 p193
|
||||||
|
double b1 = -2 * exp(-a)*cosh(w); |
||||||
|
double a1 = 2 * exp(-a)*cosh(w) - exp(-2 * a) - 1; |
||||||
|
double b2 = exp(-2 * a); |
||||||
|
|
||||||
|
switch(img.depth()){ |
||||||
|
case CV_8U : |
||||||
|
for (int i = range.start; i<range.end; i++) |
||||||
|
{ |
||||||
|
// Equation 26 p194
|
||||||
|
uchar *c1 = img.ptr(i); |
||||||
|
double border = *c1; |
||||||
|
yp[0] = *c1; |
||||||
|
c1++; |
||||||
|
yp[1] = *c1 - b1*yp[0] - b2*border; |
||||||
|
c1++; |
||||||
|
for (int j = 2; j<cols; j++, c1++) |
||||||
|
yp[j] = *c1 - b1*yp[j - 1] - b2*yp[j - 2]; |
||||||
|
// Equation 27 p194
|
||||||
|
c1 = img.ptr(i)+cols-1; |
||||||
|
border = *c1; |
||||||
|
ym[cols - 1] = *c1; |
||||||
|
c1--; |
||||||
|
ym[cols - 2] = *c1 - b1*ym[cols - 1]; |
||||||
|
c1--; |
||||||
|
for (int j = cols - 3; j >= 0; j--, c1--) |
||||||
|
ym[j] = *c1 - b1*ym[j + 1] - b2*ym[j + 2]; |
||||||
|
// Equation 25 p193
|
||||||
|
f2 = im1.ptr<float>(i); |
||||||
|
for (int j = 0; j<cols; j++, f2 ++) |
||||||
|
*f2 = (float)(a1*(ym[j] - yp[j])); |
||||||
|
} |
||||||
|
break; |
||||||
|
case CV_8S : |
||||||
|
for (int i = range.start; i<range.end; i++) |
||||||
|
{ |
||||||
|
// Equation 26 p194
|
||||||
|
char *c1 = img.ptr<char>(i); |
||||||
|
double border = *c1; |
||||||
|
yp[0] = *c1; |
||||||
|
c1++; |
||||||
|
yp[1] = *c1 - b1*yp[0] - b2*border; |
||||||
|
c1++; |
||||||
|
for (int j = 2; j<cols; j++, c1++) |
||||||
|
yp[j] = *c1 - b1*yp[j - 1] - b2*yp[j - 2]; |
||||||
|
// Equation 27 p194
|
||||||
|
c1 = img.ptr<char>(i)+cols-1; |
||||||
|
border = *c1; |
||||||
|
ym[cols - 1] = *c1; |
||||||
|
c1--; |
||||||
|
ym[cols - 2] = *c1 - b1*ym[cols - 1]; |
||||||
|
c1--; |
||||||
|
for (int j = cols - 3; j >= 0; j--, c1--) |
||||||
|
ym[j] = *c1 - b1*ym[j + 1] - b2*ym[j + 2]; |
||||||
|
// Equation 25 p193
|
||||||
|
f2 = im1.ptr<float>(i); |
||||||
|
for (int j = 0; j<cols; j++, f2 ++) |
||||||
|
*f2 = (float)(a1*(ym[j] - yp[j])); |
||||||
|
} |
||||||
|
break; |
||||||
|
case CV_16S : |
||||||
|
for (int i = range.start; i<range.end; i++) |
||||||
|
{ |
||||||
|
// Equation 26 p194
|
||||||
|
short *c1 = img.ptr<short>(i); |
||||||
|
f2 = im1.ptr<float>(i); |
||||||
|
double border = *c1; |
||||||
|
yp[0] = *c1; |
||||||
|
c1++; |
||||||
|
yp[1] = *c1 - b1*yp[0] - b2*border; |
||||||
|
c1++; |
||||||
|
for (int j = 2; j<cols; j++, c1++) |
||||||
|
yp[j] = *c1 - b1*yp[j - 1] - b2*yp[j - 2]; |
||||||
|
// Equation 27 p194
|
||||||
|
c1 = img.ptr<short>(i) + cols - 1; |
||||||
|
border = *c1; |
||||||
|
ym[cols - 1] = *c1; |
||||||
|
c1--; |
||||||
|
ym[cols - 2] = *c1 - b1*ym[cols - 1]; |
||||||
|
c1--; |
||||||
|
for (int j = cols - 3; j >= 0; j--, c1--) |
||||||
|
ym[j] = *c1 - b1*ym[j + 1] - b2*ym[j + 2]; |
||||||
|
// Equation 25 p193
|
||||||
|
for (int j = 0; j<cols; j++, f2++) |
||||||
|
*f2 = (float)(a1*(ym[i] - yp[i])); |
||||||
|
} |
||||||
|
break; |
||||||
|
case CV_16U : |
||||||
|
for (int i = range.start; i<range.end; i++) |
||||||
|
{ |
||||||
|
// Equation 26 p194
|
||||||
|
ushort *c1 = img.ptr<ushort>(i); |
||||||
|
f2 = im1.ptr<float>(i); |
||||||
|
double border = *c1; |
||||||
|
yp[0] = *c1; |
||||||
|
c1++; |
||||||
|
yp[1] = *c1 - b1*yp[0] - b2*border; |
||||||
|
c1++; |
||||||
|
for (int j = 2; j<cols; j++, c1++) |
||||||
|
yp[j] = *c1 - b1*yp[j - 1] - b2*yp[j - 2]; |
||||||
|
// Equation 27 p194
|
||||||
|
c1 = img.ptr<ushort>(i) + cols - 1; |
||||||
|
border = *c1; |
||||||
|
ym[cols - 1] = *c1; |
||||||
|
c1--; |
||||||
|
ym[cols - 2] = *c1 - b1*ym[cols - 1]; |
||||||
|
c1--; |
||||||
|
for (int j = cols - 3; j >= 0; j--, c1--) |
||||||
|
ym[j] = *c1 - b1*ym[j + 1] - b2*ym[j + 2]; |
||||||
|
// Equation 25 p193
|
||||||
|
for (int j = 0; j<cols; j++, f2++) |
||||||
|
*f2 = (float)(a1*(ym[i] - yp[i])); |
||||||
|
} |
||||||
|
break; |
||||||
|
default : |
||||||
|
return ; |
||||||
|
} |
||||||
|
}; |
||||||
|
ParallelGradientPaillouXRows& operator=(const ParallelGradientPaillouXRows &) { |
||||||
|
return *this; |
||||||
|
}; |
||||||
|
}; |
||||||
|
|
||||||
|
void GradientPaillouY(InputArray _op, OutputArray _dst, double alpha, double omega) |
||||||
|
{ |
||||||
|
Mat tmp(_op.size(),CV_32FC(_op.channels())); |
||||||
|
_dst.create( _op.size(),CV_32FC(tmp.channels()) ); |
||||||
|
cv::Mat opSrc = _op.getMat(); |
||||||
|
std::vector<Mat> planSrc; |
||||||
|
split(opSrc,planSrc); |
||||||
|
std::vector<Mat> planTmp; |
||||||
|
split(tmp,planTmp); |
||||||
|
std::vector<Mat> planDst; |
||||||
|
split(_dst,planDst); |
||||||
|
for (int i = 0; i < static_cast<int>(planSrc.size()); i++) |
||||||
|
{ |
||||||
|
if (planSrc[i].isContinuous() && planTmp[i].isContinuous() && planDst[i].isContinuous()) |
||||||
|
{ |
||||||
|
ParallelGradientPaillouYCols x(planSrc[i],planTmp[i],alpha,omega); |
||||||
|
parallel_for_(Range(0,opSrc.cols), x,getNumThreads()); |
||||||
|
ParallelGradientPaillouYRows xr(planTmp[i],planDst[i],alpha,omega); |
||||||
|
parallel_for_(Range(0,opSrc.rows), xr,getNumThreads()); |
||||||
|
|
||||||
|
} |
||||||
|
else |
||||||
|
std::cout << "PB"; |
||||||
|
} |
||||||
|
merge(planDst,_dst); |
||||||
|
} |
||||||
|
|
||||||
|
void GradientPaillouX(InputArray _op, OutputArray _dst, double alpha, double omega) |
||||||
|
{ |
||||||
|
Mat tmp(_op.size(),CV_32FC(_op.channels())); |
||||||
|
_dst.create( _op.size(),CV_32FC(tmp.channels()) ); |
||||||
|
Mat opSrc = _op.getMat(); |
||||||
|
std::vector<Mat> planSrc; |
||||||
|
split(opSrc,planSrc); |
||||||
|
std::vector<Mat> planTmp; |
||||||
|
split(tmp,planTmp); |
||||||
|
std::vector<Mat> planDst; |
||||||
|
split(_dst,planDst); |
||||||
|
for (int i = 0; i < static_cast<int>(planSrc.size()); i++) |
||||||
|
{ |
||||||
|
if (planSrc[i].isContinuous() && planTmp[i].isContinuous() && planDst[i].isContinuous()) |
||||||
|
{ |
||||||
|
ParallelGradientPaillouXRows x(planSrc[i],planTmp[i],alpha,omega); |
||||||
|
parallel_for_(Range(0,opSrc.rows), x,getNumThreads()); |
||||||
|
ParallelGradientPaillouXCols xr(planTmp[i],planDst[i],alpha,omega); |
||||||
|
parallel_for_(Range(0,opSrc.cols), xr,getNumThreads()); |
||||||
|
} |
||||||
|
else |
||||||
|
std::cout << "PB"; |
||||||
|
} |
||||||
|
merge(planDst,_dst); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
Loading…
Reference in new issue