zoukankan      html  css  js  c++  java
  • (19)边界变幻

    说实话,我真不知道,这个有啥用,先记着吧,以后可能慢慢理解

    详细可以看这个代码:https://blog.csdn.net/qq_39396954/article/details/80522426

    =======================================

     1 #include <opencv2corecore.hpp>  
     2 #include <opencv2highguihighgui.hpp>  
     3 #include <opencv2imgprocimgproc.hpp>  
     4 #include <opencv2objdetectobjdetect.hpp>  
     5 #include <opencv2imgproc	ypes_c.h>  
     6 #include <opencv2objdetectobjdetect_c.h>
     7 #include<opencv2/opencv.hpp>
     8 #include<iostream>
     9 #include<cmath>
    10 #include<cstdio>
    11 
    12 using namespace std;
    13 using namespace cv;
    14 
    15 int main()
    16 {
    17     Mat src, dst;
    18     src = imread("C:\Users\32829\Desktop\aa.jpg");
    19     if (src.empty())
    20     {
    21         cout << "!!???" << endl;
    22         return -1;
    23     }
    24     namedWindow("cat!", 1);
    25     imshow("cat!", src);
    26     namedWindow("out", 1);
    27 
    28     int top = (int)(0.05*src.rows);
    29     int bottom = (int)(0.05*src.rows);
    30     int left = (int)(0.05*src.cols);
    31     int right = (int)(0.05*src.cols);
    32     RNG rng(12345);
    33     int bordertype = BORDER_DEFAULT;
    34 
    35     int c = 0;
    36     while (true)
    37     {
    38         c = waitKey(500);
    39         if ((char)c == 27)
    40             break;
    41         if ((char)c == 'r')
    42         {
    43             bordertype = BORDER_REPLICATE;
    44         }
    45         else if ((char)c == 'w')
    46         {
    47             bordertype = BORDER_WRAP;
    48         }
    49         else if ((char)c == 'c')
    50         {
    51             bordertype = BORDER_CONSTANT;
    52         }
    53         57         Scalar color = Scalar(rng.uniform(0, 255), rng.uniform(0, 255), rng.uniform(0, 255));
    58         copyMakeBorder(src, dst, top, bottom, left, right, bordertype, color);
    59         imshow("out", dst);
    60     }
    61 
    62 
    63     waitKey(0);
    64     return 0;
    65 }

     开始运行,是用和原图没啥差别,然后按下===>r  ,就代表用周围的像素来代替边界的像素,最后的结果是这样

    ============================

    ====================================

    这是按下-->w键,,,是换行,就是用下代表上,用左代表右,用右代表左,就是上下和左右颠倒

    ======================================

    ================================

    按下c,是代表constant的,他的边框是一直变化的。

    ===================================

  • 相关阅读:
    Scons 三
    Scons 二
    vs code插件
    Scons一
    实例演示 C# 中 Dictionary<Key, Value> 的检索速度远远大于 hobbyList.Where(c => c.UserId == user.Id)
    ASP.NET Core 如何用 Cookie 来做身份验证
    如何设计出和 ASP.NET Core 中 Middleware 一样的 API 方法?
    小记编程语言的设计
    解决 VS2019 打开 edmx 文件时没有 Diagram 视图的 Bug
    一款回到顶部的 jQuery 插件,支持 Div 中的滚动条回到顶部
  • 原文地址:https://www.cnblogs.com/xiaoyoucai/p/10195312.html
Copyright © 2011-2022 走看看