图像分解python_将图像等分为两部分python open

您可以将图像的顶部和底部水平裁剪到中间。

打开图像。import cv2

import numpy as np

image = cv2.imread('images/blobs1.png')

cv2.imshow("Original Image", image)

cv2.waitKey(0)

使用image.shape让我们捕获高度和宽度变量。height, width = image.shape[:2]

print image.shape

现在我们可以开始修剪了。# Let's get the starting pixel coordiantes (top left of cropped top)

start_row, start_col = int(0), int(0)

# Let's get the ending pixel coordinates (bottom right of cropped top)

end_row, end_col = int(height * .5), int(width)

cropped_top = image[start_row:end_row , start_col:end_col]

print start_row, end_row

print start_col, end_col

cv2.imshow("Cropped Top", cropped_top)

cv2.waitKey(0)

cv2.destroyAllWindows()

# Let's get the starting pixel coordiantes (top left of cropped bottom)

start_row, start_c

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值