iLMS知識社群(Sites)師生部落格(Blogs)朝陽首頁(Homepage)TronClass教學平台Login
Position: 鄭文昌 > 程式設計
如何才能將兩張影像合併在一張影像顯示?
by 鄭文昌 2017-11-17 14:40:21, Reply(7), Views(3456)
今天專題生問我,如何才能將兩張影像分別放置左右合併在一張影像顯示?這可以利用ROI設定方式來完成。
Step 1 : 讀入Lena影像。
Step 2 : 建構一張與Lena相同列數但有兩倍行數的空白影像。
Step 3 : 設定一張暫時影像,並讓暫時影像利用ROI設定指向合併影像邊ROI,複製lena到暫時影像。
Step 4 : 接著設定暫時影像指向合併影像的邊ROI,複製lena到暫時影像。
Step 5 : 顯示結果。

C++程式如下:
//----------------------------------------------------
#include <opencv2\opencv.hpp>

using namespace cv;

void main()
{
Mat img = imread("C:\\opencv\\sources\\samples\\cpp\\lena.jpg");
Mat newimg = Mat(img.rows, img.cols*2, CV_8UC3);

Mat tmpimg;
tmpimg = newimg(Rect(0, 0, img.rows, img.cols));
img.copyTo(tmpimg);

tmpimg = newimg(Rect(img.cols, 0, img.rows, img.cols));
img.copyTo(tmpimg);

imshow("image", img);
imshow("new_image", newimg);

waitKey();
}


Attachments:
1. result.jpg (312 KB)
Tag: opencv2
Reply(7)
感謝,非常實用的教學
Many people don't know how to change wifi password, although it's very easy, just looking at tutorials on 192.168.l.l and you can change in one minute.
Thank you so much for this excellent Post and all the best for your future. I hope you and we will be sharing more thoughts and keep writing more like this one. 


or software which requires you t office 365 product key pay a certain amount, you are provided with its product key. The product key of any software ensures that you have bought it from the licensed means and you have not forged it.
Norton.com/setup – To prevent ransomware from attacking your system, look into security software like Norton Security. With Norton’s Ransomware Shield, you can ward off almost every online threat. The antivirus can be installed on all of your devices. 
https://conorton-norton.com
Microsoft has been actively present in providing us with all the needed tools, applications and platforms for us to read, edit, compose and manage all our vital office documents at www.office.com/setup, office.com/setup
We live in the technological world all digital modes have become the most convenient ways to communicate. At present, around the world, people are heavily dependent on the internet. An Norton.com/setup antivirus program is designed in order to protect your device from corrupt software programs
Reply