当前位置: 首页 > news >正文

Python和OpenCV图像分块之图像边长缩小比率是2

import cv2
import numpy as npimg = cv2.imread("F:\\mytupian\\xihuduanqiao.jpg")  # 低反光
cv2.imshow('image', img)
# =============================================================================
# 图像分块
# =============================================================================
dst = np.zeros(img.shape, img.dtype)
ratio = 2    #图像边长缩小比率是2,也就是一张图片被分割成四份
height, width = img.shape[:2]pheight = int(height / ratio)
pwidth = int(width / ratio)pHeightInterval = int(pheight)
pWidthInterval = int(pwidth)cnt = 1for i in range(ratio):for j in range(ratio):y = int(pHeightInterval * i)x = int(pWidthInterval * j)patch = img[y:y + pheight, x:x + pwidth]cv2.imshow('%d' % cnt + '.jpg', patch)cnt = cnt + 1#        patch=cv2.equalizeHist(patch) #直方图均衡#        ret,patch=cv2.threshold(patch,0,255,cv2.THRESH_BINARY+cv2.THRESH_OTSU)dst[y:y + pheight, x:x + pwidth] = patch
cv2.imshow('final image', dst)cv2.waitKey(0)
cv2.destroyAllWindows()

http://www.lryc.cn/news/377770.html

相关文章:

  • C语言中的位域(bit-field)是什么,以及它的用途和优缺点
  • 从面试角度了解前端基础知识体系
  • 【DKN: Deep Knowledge-Aware Network for News Recommendation】
  • Linux管道与重定向
  • kotlin数组
  • SpringSecurity实战入门——认证
  • 23种设计模式之桥接模式
  • vuejs3+elementPlus后台管理系统,左侧菜单栏制作、跳转、默认激活菜单
  • 代码随想录算法训练营第四十四天|LeetCode198 打家劫舍、LeetCode213 打家劫舍Ⅱ
  • Git进阶使用(图文详解)
  • Effective C++ 改善程序与设计的55个具体做法笔记与心得 4
  • WordPress管理员后台登录地址修改教程,WordPress admin登录地址文件修改方法
  • Python基础教程(二十四):日期和时间
  • java面向对象(上)
  • 揭示SOCKS5代理服务器列表的重要性
  • 机器学习python实践——关于ward聚类分层算法的一些个人心得
  • 从零制作一个docker的镜像
  • eclipse 老的s2sh(Struts2+Spring+Hibernate) 项目 用import导入直接导致死机(CPU100%)的解决
  • 《米小圈动画汉字》汉字教育动画化:传统与创新的完美融合!
  • 【LeetCode最详尽解答】11-盛最多水的容器 Container-With-Most-Water
  • redis 缓存jwt令牌设置更新时间 BUG修复
  • nginx精准禁止特定国家或者地区IP访问
  • 单片机课设-基于单片机的电子时钟设计(仿真+代码+报告)
  • .net 6 api 修改URL为小写
  • Windows电脑部署Jellyfin服务端并进行远程访问配置详细教程
  • rsync同步目录脚本
  • LeetCode 6. Z 字形变换
  • RTC实时时钟
  • WHAT - React 学习系列(一)
  • 代理模式(静态代理/动态代理)