Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Create multiscale_sharpen#17274

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Closed
jsxyhelu wants to merge6 commits intoopencv:3.4fromjsxyhelu:add_multiScaleSharpen
Closed

Create multiscale_sharpen#17274

jsxyhelu wants to merge6 commits intoopencv:3.4fromjsxyhelu:add_multiScaleSharpen

Conversation

@jsxyhelu
Copy link
Contributor

@jsxyhelujsxyhelu commentedMay 12, 2020
edited
Loading

This pullrequest changes 0516

This enhanced algorithm comes from paper
Dark image enhancement based on binocular target contrast and multi-scale detail enhancement
https://ieeexplore.ieee.org/abstract/document/7351031/
Section 2.3,there is Screenshot
e57b8fb4-c4a8-45a1-bcce-a2d973b644ba

The core idea of ​​the paper is similar to Retinex, which uses Gaussian blur at three scales, and then subtracts from the original image to obtain different levels of detail information, and then merges these details into the original image through a certain combination, which is strengthened The ability of original image information.
It is worth mentioning that the coefficients of D1 have been specially processed. The algorithm has simple coding and obvious effects.

Core function:

Mat multiScaleSharpen(Mat Src, int Radius){    int rows = Src.rows;    int cols = Src.cols;    int channels = Src.channels();    Mat B1, B2, B3;    GaussianBlur(Src, B1, Size(Radius, Radius), 1.0, 1.0);    GaussianBlur(Src, B2, Size(Radius * 2 - 1, Radius * 2 - 1), 2.0, 2.0);    GaussianBlur(Src, B3, Size(Radius * 4 - 1, Radius * 4 - 1), 4.0, 4.0);    double w1 = 0.5;    double w2 = 0.5;    double w3 = 0.25;    cv::Mat dest = cv::Mat::zeros(Src.size(), Src.type());    for (size_t i = 0; i < rows; i++)    {        uchar* src_ptr = Src.ptr<uchar>(i);        uchar* dest_ptr = dest.ptr<uchar>(i);        uchar* B1_ptr = B1.ptr<uchar>(i);        uchar* B2_ptr = B2.ptr<uchar>(i);        uchar* B3_ptr = B3.ptr<uchar>(i);        for (size_t j = 0; j < cols; j++)        {            for (size_t c = 0; c < channels; c++)            {                int  D1 = src_ptr[3 * j + c] - B1_ptr[3 * j + c];                int  D2 = B1_ptr[3 * j + c] - B2_ptr[3 * j + c];                int  D3 = B2_ptr[3 * j + c] - B3_ptr[3 * j + c];                int  sign = (D1 > 0) ? 1 : -1;                dest_ptr[3 * j + c] = saturate_cast<uchar>((1 - w1 * sign)*D1 - w2 * D2 + w3 * D3 + src_ptr[3 * j + c]);            }        }    }    return dest;}

Results show:
无标题

CPP Shampe was PR to illustrate the algorithm。

Pull Request Readiness Checklist

See details athttps://github.com/opencv/opencv/wiki/How_to_contribute#making-a-good-pull-request

  • I agree to contribute to the project under OpenCV (BSD) License.
  • To the best of my knowledge, the proposed patch is not based on a code under GPL or other license that is incompatible with OpenCV
  • The PR is proposed to proper branch
  • There is reference to original bug report and related work
  • There is accuracy test, performance test and test data in opencv_extra repository, if applicable
    Patch to opencv_extra has the same branch name.
  • The feature is well documented and sample code can be built with the project CMake

Copy link
Contributor

@asmorkalovasmorkalov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

@jsxyhelu Thanks for the sample. Please format the code with OpenCV coding style:https://github.com/opencv/opencv/wiki/Coding_Style_Guide

@@ -0,0 +1,82 @@
#include "opencv2/core/utility.hpp"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Please add license header at the beginning of the file:https://github.com/opencv/opencv/wiki/Coding_Style_Guide#file-structure

Copy link
ContributorAuthor

@jsxyhelujsxyheluMay 13, 2020
edited
Loading

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

@asmorkalov Thank you , This pullrequest has benn changed.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

actually we don't using license headers in sample files.

Copy link
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

my mistake, this pullrequest has benn changed.

Adjust code format to conform to Coding_Style_Guide,also add license header ,and modifying unintuitive variable naming。
@alalek
Copy link
Member

multiscale_sharpen

File must have .cpp extension.

@asmorkalov
Copy link
Contributor

@jsxyhelu Please take a look on CI bot status. It reports build warnings on most of platforms:https://pullrequest.opencv.org/buildbot/builders/precommit_linux64/builds/26054/steps/compile%20release/logs/warnings%20%284%29

@jsxyhelu
Copy link
ContributorAuthor

jsxyhelu commentedMay 15, 2020
edited
Loading

@jsxyhelu Please take a look on CI bot status. It reports build warnings on most of platforms:https://pullrequest.opencv.org/buildbot/builders/precommit_linux64/builds/26054/steps/compile%20release/logs/warnings%20%284%29

Thank you! Have Modified the code ,It is "ALL GREEN" now ^v^

Copy link
Contributor

@asmorkalovasmorkalov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

The code looks good enough for me in general, but I have not found any image insamples/data suitable for the example. It does not bring visible improvement for images, including Lena.

@jsxyhelu
Copy link
ContributorAuthor

The code looks good enough for me in general, but I have not found any image insamples/data suitable for the example. It does not bring visible improvement for images, including Lena.

lena
grass

Here I provide "multiScaleSharpen " image processing effects on "lena.jpg" and "building.jpg". As "building.jpg" is bigger, I chose radius 17 and 33 respectively. Overall, the algorithm can play a role in processing landscape pictures. However, I am not sure whether this algorithm is duplicated with the existing algorithm. If it is indeed the case, please help to point out, thank you very much!

@jsxyhelujsxyhelu requested a review fromasmorkalovMay 20, 2020 15:07
@sturkmen72
Copy link
Contributor

@jsxyhelu
Copy link
ContributorAuthor

there ishttps://github.com/opencv/opencv/blob/master/samples/cpp/tutorial_code/core/mat_mask_operations/mat_mask_operations.cpp in the samples. is this code really better?

function "Sharpen" is great!
And I believe the above code is going to explain "how to filter images with mask". If the algorithm I provide is placed in a similar place, it may not be too suitable.

// Create a window
namedWindow(window_name1, 1);
// create a toolbar
createTrackbar("Canny threshold default", window_name1, &sharpenRadius, 7, onTrackbar);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Canny threshold default ??

Copy link
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

My mistake.Legacy problems caused by reference code.Have fixed it.Thank you.

}
static void help(const char** argv)
{
printf("\nThis sample demonstrates multiScaleSharpen detection\n"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

detection ??

Copy link
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

yes,"image processing" is better.

@jsxyhelu
Copy link
ContributorAuthor

it may not be suiltable to pr here.

@jsxyhelujsxyhelu deleted the add_multiScaleSharpen branchJune 5, 2020 23:23
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@alalekalalekAwaiting requested review from alalek

@asmorkalovasmorkalovAwaiting requested review from asmorkalov

1 more reviewer

@sturkmen72sturkmen72sturkmen72 left review comments

Reviewers whose approvals may not affect merge requirements

Assignees

No one assigned

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

4 participants

@jsxyhelu@alalek@asmorkalov@sturkmen72

[8]ページ先頭

©2009-2025 Movatter.jp