实验5.1

Posted war1111

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了实验5.1相关的知识,希望对你有一定的参考价值。

#include <bits/stdc++.h>
#include "opencv2/core.hpp"
#include "opencv2/imgproc.hpp"
#include "opencv2/video.hpp"
#include "opencv2/objdetect.hpp"
#include "opencv2/imgcodecs.hpp"
#include "opencv2/highgui.hpp"
#include "opencv2/ml.hpp"
#define inf 2333333333333333
#define N 2010
#define p(a) putchar(a)
#define For(i,a,b) for(int i=a;i<=b;++i)
typedef unsigned char uchar;
//by war
//2020.10.8
using namespace std;
using namespace cv;
int alpha_slider_r=1,alpha_slider_d=1,m,cnt;
char TrackbarNamed[50],TrackbarNamer[50];
Mat image,image0,image1,new_image,boxFilterDst;
double Sum,sigma_d,sigma_r,alpha_d,alpha_r,alpha_slider_max=100,eps=1e-7;
double kel[N][N];
void in(int &x){
    int y=1;char c=getchar();x=0;
    while(c<0||c>9){if(c==-)y=-1;c=getchar();}
    while(c<=9&&c>=0){ x=(x<<1)+(x<<3)+c-0;c=getchar();}
    x*=y;
}
void o(int x){
    if(x<0){p(-);x=-x;}
    if(x>9)o(x/10);
    p(x%10+0);
}

void on_trackbar(int, void*){
    alpha_d = (double) alpha_slider_d/(double) 10.0;
    if(1.0/6.0 - alpha_d>eps) alpha_d=1.0/6.0;
    sigma_d=alpha_d;

    alpha_r = (double) alpha_slider_r/(double) 10.0;
    if(1.0/6.0 - alpha_r>eps) alpha_r=1.0/6.0;
    sigma_r=alpha_r;

    m=6.0*sigma_d-1;
    m+=(m%2==0);
//     copyMakeBorder(image, image0, m/2, m/2, m/2, m/2, BORDER_REFLECT);
//     new_image = Mat::zeros(image.size(), image.type());
//     For(i,0,image.rows-1)
//         For(j,0,image.cols-1)
//             For(k,0,2){
//                 cnt=0;Sum=0;
//                 For(h,i,i+m-1)
//                     For(w,j,j+m-1){
//                         kel[h][w]=exp((-1.0)/(2.0*sigma_d*sigma_d)*((h-(i+m/2))*(h-(i+m/2))+(w-(j+m/2))*(w-(j+m/2))));
//                         kel[h][w]*=exp((-1.0)/(2.0*sigma_r*sigma_r)*(image.at<Vec3b>(h,w)[k]-image.at<Vec3b>(i+m/2,j+m/2)[k])*(image.at<Vec3b>(h,w)[k]-image.at<Vec3b>(i+m/2,j+m/2)[k]));
//                         Sum+=kel[h][w];
//                     }
//                 For(h,i,i+m-1)
//                     For(w,j,j+m-1){
//                         kel[h][w]/=Sum;
//                     }
//                 Sum=0;
//                 For(h,i,i+m-1)
//                     For(w,j,j+m-1){
//                         Sum+=image0.at<Vec3b>(h,w)[k]*kel[h][w];
//                     }
//                 new_image.at<Vec3b>(i,j)[k]=Sum;
//             }
//     imshow("Contrast", new_image);
    //cout<<sigma_d<<" "<<sigma_r<<endl;
    //bilateralFilter(image, image1, m, sigma_d*10, sigma_r*10);
    //imshow("Contrast", image1);
    
    boxFilter(image, boxFilterDst, -1, cv::Size(m, m));
    imshow("Contrast", boxFilterDst);
}

signed main(){
    image = imread("/Users/war/Downloads/08.jpg");
    namedWindow("Contrast", 1);
    sprintf(TrackbarNamed, "d -> %lf", alpha_slider_max);
    sprintf(TrackbarNamer, "r -> %lf", alpha_slider_max);
    createTrackbar(TrackbarNamed, "Contrast", &alpha_slider_d, alpha_slider_max, on_trackbar);
    on_trackbar( alpha_slider_d, 0 );
    createTrackbar(TrackbarNamer, "Contrast", &alpha_slider_r, alpha_slider_max, on_trackbar);
    on_trackbar( alpha_slider_r, 0 );
    waitKey(0);
    return 0;
}

 

以上是关于实验5.1的主要内容,如果未能解决你的问题,请参考以下文章

20155201 李卓雯 《网络对抗技术》实验一 逆向及Bof基础

后端基础php框架laravel 5.1环境构建(CentOS 6.5)之FastCGI

使用 React 实验性中继片段:缺少属性 '"$fragmentRefs"'

Java初识方法

[NTUSTISC pwn LAB 7]Return to libc实验(puts泄露libc中gadget片段定位)

angularJS使用ocLazyLoad实现js延迟加载