导航:首页 > 编程语言 > pythonloadimage

pythonloadimage

发布时间:2022-05-11 02:38:54

‘壹’ Opencv用python实现灰度图

请题主把两张图上传上来。具体方法:是上传到网络网盘然后链接贴过来

‘贰’ 如何从python中opencv的阵列读取原始PNG

PNG图像从我的iPhone到我的MacBook通过TCP。 MacBook的代码是从怎样的形象与OpenCV的转换? PNG格式被选中它们是有效的,但其他格式可以 我写了一个测试程序,从文件中读取的rawImage,但不知道如何将它转化成:# Read rawImage from a file, but in reality will have it from TCPServer
f = open('frame.png', "rb")
rawImage = f.read()
f.close()

# Not sure how to convert rawImage
npImage = np.array(rawImage)
matImage = cv2.imdecode(rawImage, 1)

#show it
cv.NamedWindow('display')
cv.MoveWindow('display', 10, 10)
cv.ShowImage('display', matImage)
cv. WaitKey(0)

1. 另一种方式, 也是在阅读一个实际的文件的情况下,这将适用于一个unicode路径(在Windows上进行测试)with open(image_full_path, 'rb') as img_stream:
file_bytes = numpy.asarray(bytearray(img_stream.read()), dtype=numpy.uint8)
img_data_ndarray = cv2.imdecode(file_bytes, cv2.CV_LOAD_IMAGE_UNCHANGED)
img_data_cvmat = cv.fromarray(img_data_ndarray) # convert to old cvmat if needed

2. (你的问题似乎被标记的Objective-C,但你问的Python,所以是你的榜样,所以我'的。) 我的第一篇文章对堆栈溢出! 简历。似乎是你在找什么。 的LoadImage(iscolor=CV_LOAD_IMAGE_COLOR)→无Loads an image from a file as an IplImage.
Parameters:

filename (str) – Name of file to be loaded.
iscolor (int) –

Specific color type of the loaded image:
CV_LOAD_IMAGE_COLOR the loaded image is forced to be a 3-channel color image
CV_LOAD_IMAGE_GRAYSCALE the loaded image is forced to be grayscale
CV_LOAD_IMAGE_UNCHANGED the loaded image will be loaded as is.

该函数cvLoadImage加载图像从指定的文件和 返回的指针加载的图像。目前,下列文件 格式支持:Windows bitmaps - BMP, DIB
JPEG files - JPEG, JPG, JPE
Portable Network Graphics - PNG
Portable image format - PBM, PGM, PPM
Sun rasters - SR, RAS
TIFF files - TIFF, TIF

注意,在当前的alpha通道,如果有的话,是 从输出图像除去,例如4通道的RGBA图像会 加载为RGB。

3. 我想通了:# Read rawImage from a file, but in reality will have it from TCPServer
f = open('frame.png', "rb")
rawImage = f.read()
f.close()

# Convert rawImage to Mat
pilImage = Image.open(StringIO(rawImage));
npImage = np.array(pilImage)
matImage = cv.fromarray(npImage)

#show it
cv.NamedWindow('display')
cv.MoveWindow('display', 10, 10)
cv.ShowImage('display', matImage)
cv. WaitKey(0)

‘叁’ ubuntu 下安装了opencv 和 python,可是运行程序时,总出现下面的问题

看了你的错误,很明显你连linux下运行python脚本都不熟悉,首先你的python test.py这个命令不能在python环境下执行。。要执行的话也可以,直接import test就可以,要确定test文件路径

‘肆’ 运行Python出现错误: AttributeError: 'mole' object has no attribute 'LoadImage' 请各位大神支招!

典型AttributeError异常,找不到LoadImage属性,请检查你是否导入了此模块或者模块使用是否正确

‘伍’ python大神求助,关于图片合成问题

这需要opencv图形的库才会比较容易吧。
import cv2.cv as cv

if __name__=='__main__':
img1=cv.LoadImage('foreground.jpg')
img2=cv.LoadImage('background.jpg')
img3=cv.CreateImage((img1.width, img1.height), 8, 3)

for i in range(img1.height):
for j in range(img1.width):
if (img1[i,j][0]==0 and img1[i,j][1]>255 and img1[i,j][2]==0): #判断像素点为绿色,即背景色,可根据实际做相应的变化
img3[i,j][0]=img2[i,j][0]
img3[i,j][1]=img2[i,j][1]
img3[i,j][2]=img2[i,j][2]
else:

img3[i,j][0]=img1[i,j][0]
img3[i,j][1]=img1[i,j][1]
img3[i,j][2]=img1[i,j][2]

cv.SaveImage("result.jpg",img3)

‘陆’ 如何从python中opencv的数组读取原始PNG

1. 另一种方式,
也是在阅读一个实际的文件的情况下,这将适用于一个unicode路径(在Windows上进行测试)

with open(image_full_path, 'rb') as img_stream:
file_bytes = numpy.asarray(bytearray(img_stream.read()), dtype=numpy.uint8)
img_data_ndarray = cv2.imdecode(file_bytes, cv2.CV_LOAD_IMAGE_UNCHANGED)
img_data_cvmat = cv.fromarray(img_data_ndarray) # convert to old cvmat if needed

2.
(你的问题似乎被标记的Objective-C,但你问的Python,所以是你的榜样,所以我'的。)
我的优先篇文章对堆栈溢出!
简历。似乎是你在找什么。
的LoadImage(iscolor=CV_LOAD_IMAGE_COLOR)→无
Loads an image from a file as an IplImage.
Parameters:
filename (str) – Name of file to be loaded.
iscolor (int) –
Specific color type of the loaded image:
CV_LOAD_IMAGE_COLOR the loaded image is forced to be a 3-channel color image
CV_LOAD_IMAGE_GRAYSCALE the loaded image is forced to be grayscale
CV_LOAD_IMAGE_UNCHANGED the loaded image will be loaded as is.

该函数cvLoadImage加载图像从指定的文件和
返回的指针加载的图像。目前,下列文件
格式支持:
Windows bitmaps - BMP, DIB
JPEG files - JPEG, JPG, JPE
Portable Network Graphics - PNG
Portable image format - PBM, PGM, PPM
Sun rasters - SR, RAS
TIFF files - TIFF, TIF

注意 CodeGo.net,在当前的alpha通道,如果有的话,是
从输出图像除去,例如4通道的RGBA图像会
加载为RGB。
3.
我想通了:
# Read rawImage from a file, but in reality will have it from TCPServer
f = open('frame.png', "rb")
rawImage = f.read()
f.close()
# Convert rawImage to Mat
pilImage = Image.open(StringIO(rawImage));
npImage = np.array(pilImage)
matImage = cv.fromarray(npImage)
#show it
cv.NamedWindow('display')
cv.MoveWindow('display', 10, 10)
cv.ShowImage('display', matImage)
cv. WaitKey(0)

‘柒’ python如何把检测出来的边缘画成矩形

__author__='Administrator'importcv

defSharp(image,flag1=0,flag2=0):
w=image.width
h=image.heightsize=(w,h)
iSharp=cv.CreateImage(size,8,1)foriinrange(h-1):forjinrange(w-1):ifflag2==0:
x=abs(image[i,j+1]-image[i,j])
y=abs(image[i+1,j]-image[i,j])else:
x=abs(image[i+1,j+1]-image[i,j])
y=abs(image[i+1,j]-image[i,j+1])ifflag1==0:
iSharp[i,j]=max(x,y)else:
iSharp[i,j]=x+yreturniSharpimage=cv.LoadImage('18.jpg',0)
iMaxSharp=Sharp(image)
iAddSharp=Sharp(image,1)
iRMaxSharp=Sharp(image,0,1)
iRAddSharp=Sharp(image,1,1)
cv.ShowImage('iMaxSharp',iMaxSharp)
cv.ShowImage('image',image)
cv.ShowImage('iAddSharp',iAddSharp)
cv.ShowImage('iRAddSharp',iRAddSharp)
cv.ShowImage('iRMaxSharp',iRMaxSharp)
cv.WaitKey(0)

‘捌’ python图像处理opencv cv.createimage怎么用

在处理图片的时候,经常会需要把一些信息直接以文字的形式输出在图片上,下面的代码将实现这个效果:
import cv2.cv as cv
image=cv.LoadImage('img/lena.jpg', cv.CV_LOAD_IMAGE_COLOR) #Load the image
font = cv.InitFont(cv.CV_FONT_HERSHEY_SIMPLEX, 1, 1, 0, 3, 8) #Creates a font

‘玖’ 如何用python进行文本预处理

#!/usr/bin/python
#print"HelloWorld"
str_seperator="=================================================================================="
timePointName=["enterOpenNextImageat",#0
"enterOpenImageat",#1
"InOpenImagesendOn_ImageRefreshat",#2
"leaveOpenImageat",#3
"leaveOpenNextImageat",#4
"enterLoadImageat",#5
"decodebeganat",#6
"enterDrawClientat",#7
"leaveDrawClientat",#8
"decodeendat",#9
"inLoadImagesendOn_ImageRefreshat",#10
"leaveloadImageat",#11
"secondenterDrawClientat",#12
"secondleaveDrawClientat"#13
]

itemNumber=0;
avgTotal=0;#13-0
avgFirstDraw=0;#8-2
avgLoadImage=0;#11-5
avgSecondDraw=0;#13-10

fobj=open("F:log.txt","r")
imageTimeSta={}
dic={}
path=""
idx=0
forlineinfobj:
idx=idx+1
ifidx==1:
line=line[3:]
else:
pass

line=line.strip()
line=line.decode("utf-8").encode("gbk")
ifline==str_seperator:
ifpath=="":
pass
else:
imageTimeSta[path]=dic
dic={}
path=""
continue

tabIndex=line.find(' ')
iftabIndex==-1:
path=line
printpath
continue

tabLastIndex=line.rfind(' ')
name=line[0:tabIndex]
time=int(line[tabLastIndex+1:])
ifnameindic:
dic["second"+name]=time
else:
dic[name]=time

fobj.close()
itemNumber=len(imageTimeSta)
keys=imageTimeSta.keys();
for(k,dic)inimageTimeSta.iteritems():
avgTotal+=dic[timePointName[13]]-dic[timePointName[0]];
avgFirstDraw+=dic[timePointName[8]]-dic[timePointName[2]];
avgLoadImage+=dic[timePointName[11]]-dic[timePointName[5]];
avgSecondDraw+=dic[timePointName[13]]-dic[timePointName[10]];

print'avgTotal',avgTotal/float(itemNumber)
print'avgFirstDraw',avgFirstDraw/float(itemNumber)
print'avgLoadImage',avgLoadImage/float(itemNumber)
print'avgSecondDraw',avgSecondDraw/float(itemNumber)

#printimageTimeSta

‘拾’ python如何将PIL.Image对象写入到windows剪贴板中

from ctypes import *
import os
import win32con,win32clipboard

aString=windll.user32.LoadImageW(0,"new.bmp",win32con.IMAGE_BITMAP,0,0,win32con.LR_LOADFROMFILE)
print(aString)
if aString !=0: ## 由于图片编码问题 图片载入失败的话 aString 就等于0
win32clipboard.OpenClipboard()
win32clipboard.EmptyClipboard()
win32clipboard.SetClipboardData(win32con.CF_BITMAP, aString)
win32clipboard.CloseClipboard()
————————————————

阅读全文

与pythonloadimage相关的资料

热点内容
如何判断服务器有没有带宽 浏览:41
天正建筑批量删除命令 浏览:94
cad最下面的一排命令都什么意思 浏览:456
pythonimportcpp 浏览:850
W10的系统怎么给U盘加密 浏览:370
华为手机代码编程教学入门 浏览:762
和彩云没会员怎样解压 浏览:634
androidimageview保存 浏览:387
新买店铺什么服务器 浏览:883
文件夹能直接刻录吗 浏览:493
androidxmpp删除好友 浏览:969
javac哪个前景好 浏览:428
中华英才网app为什么不能搜索了 浏览:660
服务器域名是什么意思 浏览:52
Linux导出mysql命令 浏览:159
无诈建邺是什么app 浏览:228
python中的双色球 浏览:167
python解释器里如何换行 浏览:412
python编写格式 浏览:576
用python做出来的软件 浏览:470