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)   #经过像素操作的
相关推荐
nbsaas-boot1 小时前
Java 正则表达式白皮书:语法详解、工程实践与常用表达式库
开发语言·python·mysql
仗剑_走天涯1 小时前
基于pytorch.nn模块实现线性模型
人工智能·pytorch·python·深度学习
chao_7891 小时前
二分查找篇——搜索旋转排序数组【LeetCode】两次二分查找
开发语言·数据结构·python·算法·leetcode
chao_7896 小时前
二分查找篇——搜索旋转排序数组【LeetCode】一次二分查找
数据结构·python·算法·leetcode·二分查找
烛阴6 小时前
Python装饰器解除:如何让被装饰的函数重获自由?
前端·python
noravinsc6 小时前
django 一个表中包括id和parentid,如何通过parentid找到全部父爷id
python·django·sqlite
ajassi20006 小时前
开源 python 应用 开发(三)python语法介绍
linux·python·开源·自动化
沉默媛7 小时前
如何安装python以及jupyter notebook
开发语言·python·jupyter
Deng9452013148 小时前
基于Python的旅游数据可视化应用
python·numpy·pandas·旅游·数据可视化技术
2401_878624798 小时前
pytorch 自动微分
人工智能·pytorch·python·机器学习