当前位置:网站首页>Image effect display (top)
Image effect display (top)
2022-08-07 13:11:00 【deal with】
Foreword
Prepare to update a new series in November. I read Mr. Yang Shuying's "Digital Image Processing Visual Studio C++ Technology Implementation" before.The series transplants all routines to opencv-C++ implementation, that is, the algorithm logic is implemented in C++, and the image object uses the image class that comes with opencv.
This book has supporting tutorials at station B. It is an open class taught by Ms. Yang Shuying from Tianjin University of Technology. Just search it directly.
So this series does not explain the principle in detail, only the basic idea + code + operation effect, the detailed principle can be read in the book, I will not repeat the content of the book.
Image scanning display
Scan down is to block the image and display it in time.
The scanning effect can be achieved by continuously changing the displayed ROI area:
void scanning_down(){// read imageMat srcImage, dstImage;srcImage = imread("2.jpg");imshow("Original Image", srcImage);//define variableMat roiImage;int ImageHeigth = srcImage.rows;int ImageWidth = srcImage.cols;namedWindow("scan down");for (int i = 1; i < ImageHeigth; i++) {//step size is 1roiImage = srcImage(Rect(0, 0, ImageWidth, i));roiImage.copyTo(dstImage);imshow("Scan down", dstImage);waitKey(5);}waitKey(0);}Animation
Up, left, right scan display the same.
The image fades in
The idea of image fading is to first record the pixel value of each pixel of the image, turn the screen black first, and display the image n times in a loop, where n is 0, 1, 2, ..., 256.Each time the pixel value is displayed n/256 times, so as to achieve the effect of fading.
void fade_in()//fade in{// read imageMat srcImage, dstImage;srcImage = imread("2.jpg");dstImage = srcImage.clone();imshow("Original Image", srcImage);//define variableMat roiImage;int ImageHeigth = srcImage.rows;int ImageWidth = srcImage.cols * 3;namedWindow("image fade in");for (int n = 1; n < 256; n++) {for (int i = 0; i < ImageHeigth; i++) {uchar* data1 = srcImage.ptr(i);uchar* data2 = dstImage.ptr(i);for (int j = 0; j < ImageWidth; j++) {data2[j] = data1[j] * n / 256;}}imshow("image fade in", dstImage);waitKey(10);}} Animation
Mosaic display
Mosaic display is to divide the picture into small blocks of fixed size, and record the coordinates of the upper left corner of all small blocks, and then randomly display these small blocks, which is the mosaic effect.
//image mosaic displayvoid mosaic(){// read imageMat srcImage, dstImage;srcImage = imread("2.jpg");dstImage = Mat(srcImage.size(), CV_8UC3);imshow("Original Image", srcImage);//define variableMat roiImage;int ImageHeigth = srcImage.rows;int ImageWidth = srcImage.cols;namedWindow("image mosaic display");//Store the first address of each small block and shuffle it randomlyint step =24;//Define the side length of the mosaic (square)vector temp;unsigned int mi = 0;//for loop to store all node coordinatesfor (int x = 0; x < ImageWidth; x = x + step) {for (int y = 0; y < ImageHeigth; y = y + step) {if (x > ImageWidth - step) {x = ImageWidth - step;}if (y > ImageHeigth - step) {y = ImageHeigth - step;}temp.push_back(Point2d(x,y));mi++;}}random_shuffle(temp.begin(), temp.end());//Shuffle the elements in the container//for loop to display each random mosaicfor (int i = 0; i < mi; i++) {srcImage(Rect(temp[i].x, temp[i].y, step, step)).copyTo(dstImage(Rect(temp[i].x, temp[i].y, step, step)));imshow("Image mosaic display", dstImage);waitKey(1);}waitKey(0);} Animation
THE END
That's it for today.Tomorrow, I will update the image display effects of image panning, cross fly-in, middle expansion, grid effect, and blind effect.
边栏推荐
- 中国石油大学(北京)-《 完井工程》第三阶段在线作业
- MySQL报错原因:ERROR 1292 (22007): Incorrect date value: ‘1988‘ for column ‘birthday‘ at row 1
- Yolo v5 masks monitoring
- 爱可可AI前沿推介(8.7)
- 2022/8/5 拓扑排序+dp
- China University of Petroleum (Beijing) - Online work of the third stage of "Percolation Mechanics"
- 亿纬锂能首件搭载自主研发46系列大圆柱电池系统产品成功下线
- 中国石油大学(北京)-《 完井工程》第二阶段在线作业
- OneNote 教程,如何在 OneNote 中使用绘图和批注?
- FairMOT Online Tracking Framework and Code Learning Records
猜你喜欢

DiskGenius Installation Tutorial

rpc.rquotad: unable to register (RQUOTAPROG, RQUOTAVERS, udp)

中国石油大学(北京)-《 渗流力学》第一阶段在线作业

代码随想录笔记_动态规划_518零钱兑换II

Leetcode 47. 全排列 II

目标检测工具箱MMDetection安装及使用示例

AICOCO AI Frontier Promotion (8.7)

PDF转换工具安装教程

Meta提出OmniMAE,用统一架构预训练视频和文本,ImageNet上达86.5%,SSv2上达75.3%!...

1.0常见命令以及权限理解
随机推荐
中国石油大学(北京)-《钻井液工艺原理》第一阶段在线作业
Leetcode LCP 40. 心算挑战(可以,已解决)
vscode create shortcut key template
China University of Petroleum (Beijing) - "Drilling Fluid Technology Principle" Phase II Online Operation
Real-time communication by integrating websocket
[华为云在线课程][SQL语法分类][数据查询][学习笔记]
Meta proposes OmniMAE: Pre-training video and text with a unified architecture
微信小程序和微信H5有什么区别?
Machine Learning in Practice (1) - Overview
China University of Petroleum (Beijing) - Online Operation of "Reservoir Engineering" Phase III
使用OpenCV测量图像中物体的大小
ReentrantReadWriteLock读写锁
【Unity入门计划】GameObject类(1)-GetComponent方法
2022年T电梯修理复习题及在线模拟考试
China university of petroleum (Beijing) - "completion project" the second phase of online operations
关于#mysql#的问题:如图创建以上表格,报错代码如下SELECT * FROM studentwhere 姓名 LIKE可%
2022年流动式起重机司机试题模拟考试平台操作
实现Sprite的Circle Fill效果及打了图集出现的问题
China University of Petroleum (Beijing) - "Workover Engineering" Phase II Online Work
Navicat连接mysql一段时间未操作之后卡住几秒