03_OpenCV像素操作

复制代码
import cv2

img = cv2.imread('libaray.JPG',1)
(b,g,r) = img[100,100]
print(b,g,r)# bgr
#10 100 --- 110 100
i=j=0
for j in range(1,500):
    img[i,j] = (255,255,255)
    for i in range(1,500):
        img[i,j] = (255,255,255)

# cv2.imshow('image',img)
# cv2.waitKey(0) #1000 ms
复制代码
#bgr8转jpeg格式
import enum
import cv2

def bgr8_to_jpeg(value, quality=75):
    return bytes(cv2.imencode('.jpg', value)[1])
复制代码
import ipywidgets.widgets as widgets

image_widget1 = widgets.Image(format='jpg', )
image_widget2 = widgets.Image(format='jpg', )
# create a horizontal box container to place the image widget next to eachother
image_container = widgets.HBox([image_widget1, image_widget2])

# display the container in this cell's output
display(image_container)

img1 = cv2.imread('libaray.JPG',1)

image_widget1.value = bgr8_to_jpeg(img1)  #原始的
image_widget2.value = bgr8_to_jpeg(img)   #经过像素操作的
相关推荐
Merrill_hh24 分钟前
Python环境搭建
python
用户0190275816130 分钟前
如何用 Python 回测布林带突破策略?
python
4SAPI39 分钟前
企业Agent落地选型:大模型API接入方案迁移实践与稳定性评估
人工智能·python·php
用户019027581611 小时前
如何用 Python 计算 CR 能量指标(中间意愿指标)?
python
曲径海盗1 小时前
【Python 学习第 34 天】条件判断 if/else
python·学习笔记·编程入门
用户6602676118791 小时前
重试不重复下单还不够:同一幂等键换了参数,应该返回什么?
python
五网1 小时前
用Python搭建创业项目财务测算模型:CAC、LTV、盈亏平衡点一键算出(附完整代码)
python
用户6602676118791 小时前
登录成功就能读取任意任务 ID 吗?给 SaaS 读写加上租户范围
python
用户7624117567051 小时前
第十五章 数据分析
python·数据分析
2601_961963382 小时前
电子合同检索与全文搜索怎么测、怎么选:六个指标 + 五家平台对比 + 八个自测问题
数据库·后端·python·django·智能合约