Skip to content
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

I wondered if there is a bug in the cpp version #1

Open
xin-xiner opened this issue Feb 1, 2017 · 1 comment
Open

I wondered if there is a bug in the cpp version #1

xin-xiner opened this issue Feb 1, 2017 · 1 comment

Comments

@xin-xiner
Copy link

xin-xiner commented Feb 1, 2017

I very appreciate the help of your research for me. But when I read your cpp version code, I found some weird things.

In the sed.cpp file and the line 201, you defined a Mat clim. Then you use filter2D and resize it. But when you compute the responses of different orientations, you still use the Mat cim. That means the result of different scale clim never be used and the far surround in your cpp may be ignored.

I edit the line 215 to 224 as:

          for ( int t = 0; t < nangles; t++ )
          {
              cv::Mat cltim;
              cv::filter2D(clim, cltim, clim.depth(), d1gs[t]);
              cltim = cv::abs ( cltim );
              angles[t] = cltim;
          }
SurroundModulation(clim, angles, d1gs[0].rows, v1sigma);

Then the result of the cpp version has some weird differences compare to matlab version.
The left image is the result of matlab version and right is the result of cpp version.

image

Another problem is in the line 75, the definition of the function SurroundModulation:
As far as I am concerned, you want to update the rfrespons in the function's parameter.
I think there may need a & in the definition of the function like:
void SurroundModulation (const cv::Mat InputImage, std::vector<cv::Mat>& rfresponse, const double GaussianSize,const double sigma )

Thank you very much for this excellent work.

Update:
But maybe this is because of the parallel of OpenMP. When I close OpenMP the result looks nearly the same as matlab now. But the lines in the matlab's result looks more straight.
image

@xin-xiner xin-xiner changed the title I wondered if there a bug in the cpp version I wondered if there is a bug in the cpp version Feb 1, 2017
ArashAkbarinia added a commit that referenced this issue Feb 2, 2017
@ArashAkbarinia
Copy link
Owner

Thanks a lot for your interest in my work.

In the sed.cpp file and the line 201, you defined a Mat clim. Then you use filter2D and resize it. But when you compute the responses of different orientations, you still use the Mat cim. That means the result of different scale clim never be used and the far surround in your cpp may be ignored.

You're completely right, thanks a lot for noticing it and reporting it to me. I've fixed it and committed it to the GitHub.

Another problem is in the line 75, the definition of the function SurroundModulation:
As far as I am concerned, you want to update the rfrespons in the function's parameter.

It's not necessary to pass a vector as a reference. Changes on a vector are reflected regardless. You can try this by printing values of rfresponse before and after calling SurroundModulation function.

But maybe this is because of the parallel of OpenMP. When I close OpenMP the result looks nearly the same as matlab now. But the lines in the matlab's result looks more straight.

I'll look into more details of this, in theory the OpenMP shouldn't corrupt the results because parallel processing is completely on independent variables. I think there must be some bug somewhere that I've missed. I'll try to figure it out.

I just wanted also to mention to you that results in Matlab has non maximum suppression and c++ I haven't implemented it. But I guess you're already aware of that based on the pictures you've posted.

Thanks a lot again, I highly appreciated your comments. And if you found any other problems please let me know.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants