是否可以通过使用opencv在同一窗口有黑白和彩色图像? [英] Is it possible to have black and white and color image on same window by using opencv?

查看:569
本文介绍了是否可以通过使用opencv在同一窗口有黑白和彩色图像?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以通过使用opencv libraray在同一窗口上具有黑白和彩色图像?

Is it possible to have black-and-white and color image on same window by using opencv libraray? How can I have both of these images on same window?

推荐答案

是的,这里是一个例子,在评论中的expaination :

Yes it is, here is an example, expaination in the comments:

>

import cv
#open color and b/w images
im = cv.LoadImageM('1_tree_small.jpg')
im2 = cv.LoadImageM('1_tree_small.jpg',cv.CV_LOAD_IMAGE_GRAYSCALE)
#set up our output and b/w in rgb space arrays:
bw = cv.CreateImage((im.width,im.height), cv.IPL_DEPTH_8U, 3)
new = cv.CreateImage((im.width*2,im.height), cv.IPL_DEPTH_8U, 3)
#create a b/w image in rgb space
cv.Merge(im2, im2, im2, None, bw)
#set up and add the color image to the left half of our output image
cv.SetImageROI(new, (0,0,im.width,im.height))
cv.Add(new, im, new)
#set up and add the b/w image to the right half of output image
cv.SetImageROI(new, (im.width,0,im.width,im.height))
cv.Add(new, bw, new)
cv.ResetImageROI(new)
cv.ShowImage('double', new)
cv.SaveImage('double.jpg', new)
cv.WaitKey(0)

它在python,但很容易转换为任何..

Its in python, but easy to convert to whatever..

这篇关于是否可以通过使用opencv在同一窗口有黑白和彩色图像?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆