本文整理汇总了Python中SimpleCV.Image.binarize方法的典型用法代码示例。如果您正苦于以下问题:Python Image.binarize方法的具体用法?Python Image.binarize怎么用?Python Image.binarize使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SimpleCV.Image
的用法示例。
在下文中一共展示了Image.binarize方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _removeAllButCentralGalaxyCluster
# 需要导入模块: from SimpleCV import Image [as 别名]
# 或者: from SimpleCV.Image import binarize [as 别名]
def _removeAllButCentralGalaxyCluster(self):
e = self.ellipse
img = self.image
emask = Image(np.zeros((img.width, img.height), dtype=np.uint8))
if e and e.a and e.b and e.a != np.nan and e.b != np.nan:
try:
e.drawOntoLayer(emask)
except:
print "Got exception while processing %s" % self.id
pass
emask = emask.applyLayers().floodFill((img.width/2, img.height/2), color=Color.BLUE)
mask = emask.binarize().invert()
return img.applyBinaryMask(mask)
示例2: processQuote
# 需要导入模块: from SimpleCV import Image [as 别名]
# 或者: from SimpleCV.Image import binarize [as 别名]
def processQuote(src):
try:
img = Image(src)
text = img.binarize().readText()
except Exception as e:
print e
print '###'
else:
cleantext = cleanText(text)
translated = trans.translate(cleantext, langpair)
if translated:
img.drawText(translated, 0, 0, color=Color.BLACK, fontsize=24)
print lan1 + ": " + cleantext
print lan2 + ": " + translated.encode('utf-8')
print '###'
img.show()
示例3: find_shapes
# 需要导入模块: from SimpleCV import Image [as 别名]
# 或者: from SimpleCV.Image import binarize [as 别名]
def find_shapes(img):
markupImage = Image(img)
bwImage = markupImage.binarize()
blobs = bwImage.findBlobs()
rectangles = []
for b in blobs:
info = b.boundingBox()
x = info[0]
y = info[1]
w = info[2]
h = info[3]
c = find_color(x, y, markupImage)
markupImage.drawRectangle(x, y, w, h)
rectangles.append(Rectangle(*((x, y, w, h) + c)))
max_rectangle = max(rectangles, key=lambda rect: rect.w * rect.h)
#markupImage.drawRectangle(max_rectangle.x, max_rectangle.y, max_rectangle.w, max_rectangle.h, Color.ORANGE)
return rectangles, markupImage
示例4: halfsies
# 需要导入模块: from SimpleCV import Image [as 别名]
# 或者: from SimpleCV.Image import binarize [as 别名]
from SimpleCV import Image, Color, Display
# Make a function that does a half and half image.
def halfsies(left,right):
result = left
# crop the right image to be just the right side.
crop = right.crop(right.width/2.0,0,right.width/2.0,right.height)
# now paste the crop on the left image.
result = result.blit(crop,(left.width/2,0))
# return the results.
return result
# Load an image from imgur.
img = Image('http://i.imgur.com/lfAeZ4n.png')
# binarize the image using a threshold of 90
# and invert the results.
output = img.binarize(90).invert()
# create the side by side image.
result = halfsies(img,output)
# show the resulting image.
result.show()
# save the results to a file.
result.save('juniperbinary.png')
示例5: Image
# 需要导入模块: from SimpleCV import Image [as 别名]
# 或者: from SimpleCV.Image import binarize [as 别名]
from SimpleCV import Image, Color
img = Image("puzzle.jpg")
blobs = img.binarize().findBlobs()
blobs.image = img
blobs[-1].drawHull(color=Color.RED)
img.show()
示例6: Image
# 需要导入模块: from SimpleCV import Image [as 别名]
# 或者: from SimpleCV.Image import binarize [as 别名]
from SimpleCV import Image
#Ee crea la instancia de la Imatge agafant la imatege
#la imatge
imatge = Image('/home/palmendr/Documentos/PerePersonal/ServidorCcalc/ServidorCcalc/CCalc/autotrace-0.31.1/render2.bmp')
#S'executa el binarize sense parametres(negre)'
imgBin = imatge.binarize()
#Se salva la imagen como resultado3.jpg
imgBin.save('/home/palmendr/Documentos/PerePersonal/CCalc/ServidorCcalc/ServidorCcalc/autotrace-0.31.1/renderfinal.bmp')
示例7: call
# 需要导入模块: from SimpleCV import Image [as 别名]
# 或者: from SimpleCV.Image import binarize [as 别名]
from SimpleCV import Image
import time
#using opencv captured image, but purpose is make by video
call(“raspistill -n -t 0 -w %s -h %s -o image.bmp” % 640 480, shell=True)
img = Image(“image.bmp”)
img.show()
time.sleep(5)
#--------
cam = Camera()
img = cam.getImage()
#-----
img = img.edges()
img.show()
time.sleep(5)
img = img.binarize()
img.show()
time.sleep(5)
img = img.findBlobs()
for blob in blobs:
blob.draw()
img.show()
time.sleep(5)
#연속적인 이미지 촬영으로 영상을 만들면 속도가 너무 느리다 한방으로 가자
示例8: Image
# 需要导入模块: from SimpleCV import Image [as 别名]
# 或者: from SimpleCV.Image import binarize [as 别名]
#!/usr/bin/env python encoding: latin1
import sys
from SimpleCV import Image
#Creo la imatge a partir del bmp
imatge = Image('/Ccalc/ServidorCcalc/ServidorCcalc/imatges/'+sys.argv[1])
#La binaritzo, li trec totes les sombres i la natejo
imgBin = imatge.binarize(-1,255,37,8)
#I la inverteixo, la paso de fons negre i lletres blanques a fons blanc a lletres negres
imgInver = imgBin.invert()
#la guardo
imgInver.save('/Ccalc/ServidorCcalc/ServidorCcalc/imatges/'+ sys.argv[1])
print 1; #Retorno aquest 1 a java perque sapiga que ha acabat
示例9: Image
# 需要导入模块: from SimpleCV import Image [as 别名]
# 或者: from SimpleCV.Image import binarize [as 别名]
img = cam.getImage().save("img.jpg")
img = Image("img.jpg")
img.show()
imgGray = img.grayscale().save("imgGray.jpg")
imgGray = Image("imgGray.jpg")
imgGray.show()
hist = imgGray.histogram(255)
(red, green, blue) = img.splitChannels(False)
red_histogram = red.histogram(255)
green_histogram = green.histogram(255)
blue_histogram = blue.histogram(255)
plt.figure(1)
plt.subplot(411)
plt.plot(hist)
plt.subplot(412)
plt.plot(red_histogram)
plt.subplot(413)
plt.plot(green_histogram)
plt.subplot(414)
plt.plot(blue_histogram)
plt.show()
print("Ingresar parametro para binarizar: ")
a = input()
imgBin = imgGray.binarize(a).save("imgBin.jpg")
imgBin = Image("imgBin.jpg")
imgBin.show()
time.sleep(10)
示例10: Image
# 需要导入模块: from SimpleCV import Image [as 别名]
# 或者: from SimpleCV.Image import binarize [as 别名]
from SimpleCV import Image
img = Image("ex18.jpg")
imgBin = img.binarize()
imgBin.show()
示例11: Image
# 需要导入模块: from SimpleCV import Image [as 别名]
# 或者: from SimpleCV.Image import binarize [as 别名]
from SimpleCV import Image
img = Image('hand_pic.JPG')
while True:
b = img.binarize().invert()
s = b.skeletonize()
r = b - s
r.show()
# Image.track(), mask, findAndRecognizeFaces
# findBlobsFromHueHistogram(self, model, threshold=1, smooth=True, minsize=10, maxsize=None)
示例12: run
# 需要导入模块: from SimpleCV import Image [as 别名]
# 或者: from SimpleCV.Image import binarize [as 别名]
def run(self):
# Capture first frame to get size
frame = cv.QueryFrame(self.capture)
frame_size = cv.GetSize(frame)
grey_image = cv.CreateImage(cv.GetSize(frame), cv.IPL_DEPTH_8U, 1)
moving_average = cv.CreateImage(cv.GetSize(frame), cv.IPL_DEPTH_32F, 3)
difference = None
while True:
# Capture frame from webcam
color_image = cv.QueryFrame(self.capture)
preImg = pretreatment.PreTreatment()
imagePath = preImg.getImage(color_image)
sobelImagePath = preImg.sobelImage(imagePath)
thresholdImagePath = preImg.thresholdImage(sobelImagePath)
print thresholdImagePath
imThreshold = cv.LoadImage(thresholdImagePath,0)
src = cv.LoadImage(thresholdImagePath, cv.CV_LOAD_IMAGE_COLOR)
image = cv.CloneImage(src)
dest = cv.CloneImage(src)
#cv.ShowImage("texture", src)
erDest = preImg.Erosion(src,6)
opDest = preImg.Opening(erDest,6)
erDest = preImg.Erosion(opDest,3)
#save image
cv.ShowImage("last result",erDest)
filePath = os.getcwd()+"/img/dest4.jpg"
cv.SaveImage(filePath,erDest)
#img = cv.Convert(erDest,)
img = Image("./img/dest4.jpg")
blobs = img.binarize().findBlobs()
pack_blobs = blobs.crop()
pack_blob_size = pack_blobs[-1].size()
blobs.image = img
print blobs.sortArea()[-1].area()
blobArea = blobs.sortArea()[-1].area()
nickels = blobs.filter((blobs.area() > blobArea-10) & (blobs.area() < blobArea+10))
pack_blob_zoom = (nickels.center()[0][0]/2,nickels.center()[0][1]/2)
debug = True
color = (0,0,255)
rect_start = (nickels.center()[0][0]-pack_blob_size[0]/2,nickels.center()[0][1]-pack_blob_size[1]/2)
rect_end = (nickels.center()[0][0]+pack_blob_size[0]/2,nickels.center()[0][1]+pack_blob_size[1]/2)
cv.Rectangle(color_image, rect_start, rect_end, color, 2, 0)
cutting.cuteImg(pack_blob_zoom,pack_blob_size)
# palte prccessing
plateSrcPath = "./img/dest5.jpg"
plateBinaryImg = plateProcess.binary(plateSrcPath)
plateBinary = cv.LoadImage("./img/plateBinary.jpg", cv.CV_LOAD_IMAGE_COLOR)
cv.ShowImage("Binary Plare",plateBinary)
#start_x, end_x, graph = cutting.getVerticalProjection("./img/plateBinary.jpg")
#chars = cutting.cut(start_x,end_x,plateBinary)
# Display frame to user
cv.ShowImage("Target", color_image)
# Listen for ESC or ENTER key
c = cv.WaitKey(7) % 0x100
if c == 27 or c == 10:
break
示例13: Image
# 需要导入模块: from SimpleCV import Image [as 别名]
# 或者: from SimpleCV.Image import binarize [as 别名]
from SimpleCV import Image
import numpy
img = Image("us-scaled.jpg")
out = img.binarize(30)
out.save('out.png')
img = Image("out.png")
# ones = img.getNumpy()[:,:,:] == (0, 0, 0)
ones = img.getNumpy()[:,:,0] == 0
trues=numpy.where(ones)
points = []
for p in zip(trues[0], trues[1]):
# points.append(p)
print(str(p[0]) + " " + str(p[1]))
for one in ones:
print(one)
示例14: Image
# 需要导入模块: from SimpleCV import Image [as 别名]
# 或者: from SimpleCV.Image import binarize [as 别名]
from SimpleCV import Image
import time
img = Image('ladies.jpg')
# Using Otsu's method
otsu = img.binarize()
# Specify a low value
low = img.binarize(75)
# Specify a high value
high = img.binarize(125)
img = img.resize(int(img.width*.5), int(img.height*.5))
otsu = otsu.resize(int(otsu.width*.5), int(otsu.height*.5))
low = low.resize(int(low.width*.5), int(low.height*.5))
high = high.resize(int(high.width*.5), int(high.height*.5))
top = img.sideBySide(otsu)
bottom = low.sideBySide(high)
combined = top.sideBySide(bottom, side="bottom")
combined.show()
time.sleep(20)
示例15: Image
# 需要导入模块: from SimpleCV import Image [as 别名]
# 或者: from SimpleCV.Image import binarize [as 别名]
from SimpleCV import Image
img = Image("ex18.jpg")
imgBin = img.binarize().invert()
imgBin.show()