首页 > 其他分享 >4、openCV 图像像素

4、openCV 图像像素

时间:2022-09-28 11:03:58浏览次数:50  
标签:color image cv2 像素 openCV amount 图像 np height


# -*- coding: utf-8 -*-
import cv2, matplotlib
import numpy as np
import matplotlib.pyplot as plt
cols = 640
rows = 480
image = cv2.imread('2.jpg')
print image.shape
width = image.shape[0]
height = image.shape[1]
print width
print height
amount = 2.0
print 'orginal_image=',image
print 'image[0,1]=',image[0,1]
#表示图片像素image[起始位置,步长]
for x in range(0,width):
for y in range(0,height):
pixel = image[x,y]
b = pixel[0]
g = pixel[1]
r = pixel[2]
if x < width/2 and y < height/2:
color = np.array([b,g,r*amount],np.uint8)
elif x > width/2 and y < height/2:
color = np.array([b,g*amount,r],np.uint8)
elif x < width/2 and y > height/2:
color = np.array([b*amount,g,r],np.uint8)
else:
color = np.array([b*amount,g*amount,r*amount],np.uint8)

image[x,y] = color
print 'new_image=',image
# image[x,y] = color
# image[0:150,0:110] = [0, 255, 128]
cv2.imshow('image',image)
cv2.imwrite('access_pixel.png',image)
cv2.waitKey(0)

4、openCV 图像像素_编程

标签:color,image,cv2,像素,openCV,amount,图像,np,height
From: https://blog.51cto.com/u_12504263/5718745

相关文章

  • 3、openCV 平均图像的颜色
    #-*-coding:utf-8-*-importcv2,matplotlibimportnumpyasnpimportmatplotlib.pyplotaspltpixel=cv2.imread('2.jpg')print'pixel=',pixelaverage_img=np.aver......
  • 13、OpenCV4.4 仿射变换
    Parameters:src–Coordinatesoftriangleverticesinthesourceimage.dst–Coordinatesofthecorrespondingtriangleverticesinthedestinationimage.Thefunc......
  • 9、OpenCV4.4 色彩抽出
    色彩的空间变换#-*-coding:utf-8-*-importcv2importnumpyasnporiginal=cv2.imread('1.jpg',1)img=original.copy()#副本dst=np.zeros(img.shape,np.uint8)#......
  • [cmake wrong]wsl opencv
    [root@DESKTOP-31LJ6LM~/g101/h1/build]$cmake..--OpenCVARCH:--OpenCVRUNTIME:--OpenCVSTATIC:OFFCMakeWarningat/mnt/e/DevelopeTools/opencv/opencv/......
  • imageIO图像流 验证码效果案例
    packagecn.images;importjavax.imageio.ImageIO;importjava.awt.*;importjava.awt.image.BufferedImage;importjava.io.File;importjava.util.Random;publicclassCa......
  • Python cv2(Opencv) Canny边缘检测 和 傅里叶变换
    OpenCV是一个基于Apache2.0许可(开源)发行的跨平台计算机视觉和机器学习软件库,可以运行在Linux、Windows、Android和MacOS操作系统上。它轻量级而且高效,由一系列C函数和少......
  • 图像轮廓的检测
    importcv2importmatplotlib.pyplotaspltimage=cv2.imread("qqhuman.jpeg")image_BGR=image.copy()#将图像转换成灰度图像,并执行图像高斯模糊,以及转化成二值图像......
  • 关于python的opencv库的学习笔记,腐蚀与膨胀
    importcv2importnumpyasnp##img=cv2.imread('cat.jpeg')##cv2.imshow('cat',img)##cv2.waitKey()##cv2.destroyAllWindows()##对图像进行腐蚀操作#ken=np.ones......
  • opencv学习笔记,关于图片的平滑处理
    在opencv的图像平滑处理,有高斯滤波,中值滤波,均值滤波的处理方法importcv2importnumpyasapimportmatplotlib.pyplotaspltimg=cv2.imread('cat.jpeg')cv2.imshow('cat......
  • Brush Bundle一键创建精美图像PS笔刷包
    BrushBundle是一款可以在几秒钟内创建灯笼、萤火虫、剪影、瀑布、银河、头发、草、毛皮、北极光、雾、云等等的笔刷,使用简单方便。BrushBundle是中文笔刷。独特、有趣......