python将图像分割成两半
答案:2 悬赏:30 手机版
解决时间 2021-11-24 02:45
- 提问者网友:放下
- 2021-11-23 16:49
python将图像分割成两半
最佳答案
- 五星知识达人网友:你哪知我潦倒为你
- 2021-11-23 18:23
import os
import re
import sys
import time
import random
# add system headers here...
#导入cv模块
import cv2 as cv
#读取图像,支持 bmp、jpg、png、tiff 等常用格式
height = 0
length = 0
key = 0
picPath = "E:\python3.4.0-amd\project\imageProcess\tamamo.jpg"
if not os.path.exists(picPath):
print("picture not exists! exit!")
sys.exit()
srcImage = cv.imread(picPath)
if srcImage is None:
print("read picture failed! exit!")
sys.exit()
size = srcImage.shape
height = size[0]
length = size[1]
print("srcImage: height(%u) length(%u)"%(height,length))
#显示原图
#cv.imshow("srcImage",srcImage)
#创建窗口并显示图像
mid = int(length / 2)
leftImage = srcImage[0:height, 0:mid]
cv.namedWindow("leftImage",cv.WINDOW_NORMAL)
cv.resizeWindow("leftImage", mid, height)
cv.imshow("leftImage",leftImage)
rightIamge = srcImage[0:height, mid:length]
cv.namedWindow("rightIamge",cv.WINDOW_NORMAL)
cv.resizeWindow("rightIamge", mid, height)
cv.imshow("rightIamge",rightIamge)
cv.waitKey(0)
#释放窗口
cv.destroyAllWindows()
import re
import sys
import time
import random
# add system headers here...
#导入cv模块
import cv2 as cv
#读取图像,支持 bmp、jpg、png、tiff 等常用格式
height = 0
length = 0
key = 0
picPath = "E:\python3.4.0-amd\project\imageProcess\tamamo.jpg"
if not os.path.exists(picPath):
print("picture not exists! exit!")
sys.exit()
srcImage = cv.imread(picPath)
if srcImage is None:
print("read picture failed! exit!")
sys.exit()
size = srcImage.shape
height = size[0]
length = size[1]
print("srcImage: height(%u) length(%u)"%(height,length))
#显示原图
#cv.imshow("srcImage",srcImage)
#创建窗口并显示图像
mid = int(length / 2)
leftImage = srcImage[0:height, 0:mid]
cv.namedWindow("leftImage",cv.WINDOW_NORMAL)
cv.resizeWindow("leftImage", mid, height)
cv.imshow("leftImage",leftImage)
rightIamge = srcImage[0:height, mid:length]
cv.namedWindow("rightIamge",cv.WINDOW_NORMAL)
cv.resizeWindow("rightIamge", mid, height)
cv.imshow("rightIamge",rightIamge)
cv.waitKey(0)
#释放窗口
cv.destroyAllWindows()
全部回答
- 1楼网友:妄饮晩冬酒
- 2021-11-23 19:36
切好的图第一张第二张
我要举报
如以上回答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
点此我要举报以上问答信息
大家都在看
推荐资讯