当前位置: 首页>>代码示例>>Python>>正文


Python Image.applyLayers方法代码示例

本文整理汇总了Python中SimpleCV.Image.applyLayers方法的典型用法代码示例。如果您正苦于以下问题:Python Image.applyLayers方法的具体用法?Python Image.applyLayers怎么用?Python Image.applyLayers使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在SimpleCV.Image的用法示例。


在下文中一共展示了Image.applyLayers方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: face_recognize

# 需要导入模块: from SimpleCV import Image [as 别名]
# 或者: from SimpleCV.Image import applyLayers [as 别名]
def face_recognize(filename):
    from SimpleCV import Image, Display, DrawingLayer
    
    image = Image(filename)
    faces = image.findHaarFeatures('face.xml')
    if faces:
        for face in faces:
            face_layer = DrawingLayer((image.width, image.height))
            face_box = face_layer.centeredRectangle(face.coordinates(), (face.width(), face.height()))
            image.addDrawingLayer(face_layer)
            image.applyLayers()
        image.save(filename)
        print('偵測到 {} 張人臉'.format(len(faces)))
    else:
        print('沒有偵測到人臉')
开发者ID:AlexW867,项目名称:rpi2-sample-codes,代码行数:17,代码来源:face_recognize.py

示例2: drawImage

# 需要导入模块: from SimpleCV import Image [as 别名]
# 或者: from SimpleCV.Image import applyLayers [as 别名]
def drawImage():
    #Load Map
    d = Display((1240, 820), title="London Map - Scotland Yard")
    lMap = Image("maps/map.jpg")

    #Check Position from players

    #See corresponding pixel in list

    #Draw Circle from players
    circlesLayer = DrawingLayer((lMap.width, lMap.height))
    circlesLayer.circle ((191,44), 20,color=Color.BLACK, filled=True, alpha = 255)
    lMap.addDrawingLayer(circlesLayer)

    #Display
    lMap.applyLayers()
    lMap.save(d)

    '''Later create a "draw possibilites" areas in map for thief '''
开发者ID:Flavsditz,项目名称:projects,代码行数:21,代码来源:track_v0_3.py

示例3: _removeAllButCentralGalaxyCluster

# 需要导入模块: from SimpleCV import Image [as 别名]
# 或者: from SimpleCV.Image import applyLayers [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)
开发者ID:rmclaren,项目名称:Kaggle-GalaxyZoo,代码行数:18,代码来源:Galaxy.py

示例4: Display

# 需要导入模块: from SimpleCV import Image [as 别名]
# 或者: from SimpleCV.Image import applyLayers [as 别名]
from SimpleCV import Image,Display,DrawingLayer,Color
from time import sleep

myDisplay = Display()

raspberryImage = Image("test.jpg")

myDrawingLayer = DrawingLayer((raspberryImage.width, raspberryImage.height))
myDrawingLayer.rectangle((50,20),(250,60),filled=True)
myDrawingLayer.setFontSize(45)
myDrawingLayer.text("Raspberries!",(50,20),color=Color.WHITE)
raspberryImage.addDrawingLayer(myDrawingLayer)
raspberryImage.applyLayers()
raspberryImage.save(myDisplay)
while not myDisplay.isDone():
  sleep(0.1)
开发者ID:Naohiro2g,项目名称:raspberry-pi-python-sample,代码行数:18,代码来源:superimpose.py

示例5: detectChargingStation

# 需要导入模块: from SimpleCV import Image [as 别名]
# 或者: from SimpleCV.Image import applyLayers [as 别名]
def detectChargingStation(image_file):
	debug = False

	myColor1 = (8,33,64)
	myColor2 = (70,80,100)

	original = Image(image_file)

	only_station = onlyBlueColor(original, myColor1)

	#Different findBlobs
	maskMean = original.hueDistance(color=(200,160,150))
	mask = only_station.hueDistance(color=myColor1).binarize()
	meanColor = (round(((maskMean.meanColor()[0]+maskMean.meanColor()[1]+maskMean.meanColor()[2])/3) * 10000)/10000)
	blobs = original.findBlobsFromMask(mask, minsize=400)

	if(meanColor > 190):
		return 6

	#print "Number of blobs found" , len(blobs)
	try: 
		blobs.image = original
	except Exception:
		only_station = onlyBlueColor(original, myColor2)
		mask = only_station.hueDistance(color=myColor2).binarize()
		blobs = original.findBlobsFromMask(mask, minsize=400)
		blobs.image = original

	station_blob = chooseBestBlobCosine(blobs)
	station_blob.drawMinRect(color=Color.RED)

	centroidX = station_blob.minRectX()
	centroidY = station_blob.minRectY()

	#Have to find out which part of the screen centroid is in
	maxX = original.getNumpy().shape[0]
	maxY = original.getNumpy().shape[1]+100

	if(debug):
		centroidLayer = DrawingLayer((maxX,maxY))

		centroidLayer.line((0,(1/3.0)*maxY),(maxX, (1/3.0)*maxY), color=Color.GREEN, width=2)
		centroidLayer.line((0,(2/3.0)*maxY),(maxX, (2/3.0)*maxY), color=Color.GREEN, width=2)
		centroidLayer.circle((int(centroidX), int(centroidY)), color=Color.GREEN, radius=5, filled=True)

		original.addDrawingLayer(centroidLayer)
		original.applyLayers()

		mask.save("binarizeMask.png")
		original.save("blobs.png")
		only_station.save("blueFilter.png")

	#print "Coordinates of centroid are "+str(centroidX)+", "+str(centroidY)
	#print "Coordinates of max are "+str(maxX)+", "+str(maxY)

	#if(station_blob.width() * station_blob.height() < 4000):
	#	return 2

	blobArea = station_blob.width() * station_blob.height()

	if(blobArea < 10000):
		return 2

	return chargingStationLocation_New(maxX,maxY,centroidX,centroidY,200, station_blob.width() / float(station_blob.height()), blobArea)
开发者ID:sachinsiby,项目名称:SPARQ,代码行数:66,代码来源:utils.py

示例6: __call__

# 需要导入模块: from SimpleCV import Image [as 别名]
# 或者: from SimpleCV.Image import applyLayers [as 别名]
    def __call__(self, image):
        params = util.utf8convert(self.inspection.parameters)
        retVal = []
        mask = Image((image.width,image.height))
        if( params.has_key('w') and  params.has_key('h') and params.has_key('x') and params.has_key('y') ): #rectangle
            if( params['x'] + params['w'] < image.width and
                params['y'] + params['h'] < image.height and
                params['y'] >= 0 and 
                params['x'] >= 0 ):
                mask.drawRectangle(params['x'],params['y'],params['w'],params['h'],width=-1,color=Color.WHITE)
                mask = mask.applyLayers()
                fs = image.findBlobsFromMask(mask)
                ff = M.FrameFeature()
                if( fs is not None and len(fs) > 0 ):                    
                    #fs[-1].draw()
                    b = fs[-1]
                    b.__class__ = BlobRegion                   
                    c = b.meanColor()
                    b.mColor = (int(c[0]),int(c[1]),int(c[2]))
                    ff.setFeature(b) # a little hacky but I am sure that it works
                    retVal = [ff]
  
        elif( params.has_key('x') and  params.has_key('y') and params.has_key('r') ): # circle
            if( params['x'] + params['r'] < image.width and
                params['y'] + params['r'] < image.height and 
                params['x'] - params['r'] >= 0 and 
                params['y'] - params['r'] >= 0 ):

                r = params['r']
                x = params['x']
                y = params['y']

                mask.drawCircle((x,y),r,thickness=-1,color=Color.WHITE)
                mask = mask.applyLayers()
                fs = image.findBlobsFromMask(mask)
                ff = M.FrameFeature()
                if( fs is not None and len(fs) > 0 ):                    
                    #fs[-1].draw()
                    b = fs[-1]
                    b.__class__ = BlobRegion                  
                    c = b.meanColor()
                    b.mColor = (int(c[0]),int(c[1]),int(c[2]))
                    ff.setFeature(b)
                    retVal = [ff]

        elif( params.has_key('contour') ):
            contour = params['contour'] # this may bail out
            if( len(contour) >=  3 ):
                mask.dl().polygon(contour,filled=True,color=Color.WHITE)
                mask = mask.applyLayers()
                fs = image.findBlobsFromMask(mask)
                ff = M.FrameFeature()
                if( fs is not None and len(fs) > 0 ):                    
                    #fs[-1].draw()
                    b = fs[-1]
                    b.__class__ = BlobRegion                   
                    c = b.meanColor()
                    b.mColor = (int(c[0]),int(c[1]),int(c[2])) 
                    ff.setFeature(b)
                    retVal = [ff]
            
        if( params.has_key("saveFile") ):
            image.save(params["saveFile"])

        return retVal
开发者ID:kscottz,项目名称:SimpleSeer,代码行数:67,代码来源:region.py

示例7: Display

# 需要导入模块: from SimpleCV import Image [as 别名]
# 或者: from SimpleCV.Image import applyLayers [as 别名]
from SimpleCV import Image, DrawingLayer, Color, Display


d = Display((1240, 820), title="London Map - Scotland Yard")
lMap = Image("C:\\Users\\flavio\\Documents\\Python\\Scotland Yard\\maps\\map.jpg")
circlesLayer = DrawingLayer((lMap.width, lMap.height))

circlesLayer.circle ((191,44), 20,color=Color.ORANGE, filled=True, alpha = 255)
lMap.addDrawingLayer(circlesLayer)
lMap.applyLayers()

lMap.save(d)
开发者ID:Flavsditz,项目名称:projects,代码行数:14,代码来源:drawMapTest.py

示例8: Camera

# 需要导入模块: from SimpleCV import Image [as 别名]
# 或者: from SimpleCV.Image import applyLayers [as 别名]

if __name__ == '__main__':
    cam = Camera(0)
    img = Image()

    samples = 0
    coordinates = redCoords = (0,0)
    text = " "

    while True:
        img = cam.getImage()
        # Make image black and white
        tmp = findRedDot(img)
        if (tmp != None):
            coordinates= (coordinates[0]+tmp[0][0], coordinates[1]+tmp[0][1])
            samples+=1

        if samples == 10:
            samples = 0
            coordinates = (coordinates[0]/10, coordinates[1]/10)
            text = str(coordinates)
            redCoords = coordinates
            coordinates = (0,0)

        redcircle = DrawingLayer((img.width, img.height))
        redcircle.circle(redCoords, 5, filled=True, color=(0,255,0)) #add circle point 10,10, radius 10.
        img.addDrawingLayer(redcircle)
        img.applyLayers()
        img.drawText(text)
        img.show()
开发者ID:Flavsditz,项目名称:projects,代码行数:32,代码来源:findRedDot.py

示例9: fancify

# 需要导入模块: from SimpleCV import Image [as 别名]
# 或者: from SimpleCV.Image import applyLayers [as 别名]

#.........这里部分代码省略.........
                    bottom_of_nose = y_nose + (nose.height() * 4 / 5)
                    top_of_mouth = y_mouth
                    # if top_of_mouth > bottom_of_nose:
                    #    top_of_mouth = bottom_of_nose
                    y_must = y_face + ((bottom_of_nose + top_of_mouth) / 2) - (cur_stache.height / 2)

                    middle_of_nose = nose.x
                    middle_of_mouth = mouth.x
                    x_must = x_face + ((middle_of_nose + middle_of_mouth) / 2) - (cur_stache.width / 2)

                if right_eye:
                    x_right_eye = right_eye.x - (right_eye.width() / 2)
                    y_right_eye = right_eye.y - (right_eye.height() / 2)

                    # Setup Monocle Image
                    cur_mono = monocle.copy()
                    scale_factor = ((right_eye.width() / 65.0) + (face.width() / 200.0)) / 2.0
                    cur_mono = cur_mono.scale(scale_factor)
                    mono_mask = cur_mono.createAlphaMask(hue_lb=0, hue_ub=100).invert()

                    # Calculate Monocle Position
                    x_mono = x_face + x_right_eye
                    y_mono = y_face + y_right_eye
                    img = img.blit(cur_mono, pos=(x_mono, y_mono), alphaMask=mono_mask)

                img = img.blit(cur_stache, pos=(x_must, y_must), alphaMask=stache_mask)

                if debug:
                    noselayer = DrawingLayer((img.width, img.height))
                    nosebox_dimensions = (nose.width(), nose.height())
                    center_point = (face.x - (face.width() / 2) + nose.x,
                                    face.y - (face.height() / 2) + nose.y)
                    nosebox = noselayer.centeredRectangle(center_point, nosebox_dimensions, width=3)
                    img.addDrawingLayer(noselayer)
                    img = img.applyLayers()

            else:
                print "Face culled:"
                if not nose:
                    print "  No Nose"
                if not mouth:
                    print "  No mouth"
                if not right_eye:
                    print "  No right eye"
                    print

            if debug:
                face_left_edge = face.x - (face.width() / 2)
                face_top_edge = face.y - (face.height() / 2)

                facelayer = DrawingLayer((img.width, img.height))
                facebox_dimensions = (face.width(), face.height())
                center_point = (face.x, face.y)
                facebox = facelayer.centeredRectangle(center_point, facebox_dimensions, Color.BLUE)
                img.addDrawingLayer(facelayer)

                if noses:
                    for nose in noses:
                        noselayer = DrawingLayer((img.width, img.height))
                        nosebox_dimensions = (nose.width(), nose.height())
                        center_point = (face.x - (face.width() / 2) + nose.x,
                                    face.y - (face.height() / 2) + nose.y)
                        nosebox = noselayer.centeredRectangle(center_point, nosebox_dimensions)
                        img.addDrawingLayer(noselayer)

                if mouths:
                    for mouth in mouths:
                        mouthlayer = DrawingLayer((img.width, img.height))
                        mouthbox_dimensions = (mouth.width(), mouth.height())
                        center_point = (face.x - (face.width() / 2) + mouth.x,
                                face.y - (face.height() / 2) + mouth.y)
                        mouthbox = mouthlayer.centeredRectangle(center_point, mouthbox_dimensions, Color.GREEN)
                        img.addDrawingLayer(mouthlayer)

                if eyes:
                    for right_eye in eyes:
                        right_eyelayer = DrawingLayer((img.width, img.height))
                        right_eyebox_dimensions = (right_eye.width(), right_eye.height())
                        right_eye_center_point = (face_left_edge + right_eye.x, face_top_edge + right_eye.y)
                        right_eyebox = right_eyelayer.centeredRectangle(right_eye_center_point, right_eyebox_dimensions)
                        img.addDrawingLayer(right_eyelayer)

                img = img.applyLayers()

    img = img.scale(0.5)
    w_ratio = img.width / 800.0
    h_ratio = img.height / 600.0

    if h_ratio > 1.0 or w_ratio > 1.0:
        if h_ratio > w_ratio:
            img = img.resize(h=600)
        else:
            img = img.resize(w=800)

    output = StringIO.StringIO()
    img.getPIL().save(output, format="JPEG") #, quality=85, optimize=True)
    img_contents = output.getvalue()

    mimetype = "image/jpeg"
    return app.response_class(img_contents, mimetype=mimetype, direct_passthrough=False)
开发者ID:chadnickbok,项目名称:fancify,代码行数:104,代码来源:fancify.py

示例10: Image

# 需要导入模块: from SimpleCV import Image [as 别名]
# 或者: from SimpleCV.Image import applyLayers [as 别名]
big_blobs = eye_final.findBlobs(minsize=500)

 #create a blank image to mask
masked_image = Image(eye.size())

for b in big_blobs:

     #set mask
   b.image = masked_image

     #draw the blob on your mask
   b.draw(color = Color.WHITE)



eye_final = eye_final - masked_image.applyLayers()
eye_final = eye_final.erode()

#eye_final.save("testthis.png")


if eye_final.findBlobs(maxsize=10):

    small_blobs = eye_final.findBlobs(maxsize=10)

    #create a blank image to mask
    masked_small_image = Image(eye.size())
    for b in small_blobs:

        #set mask
       b.image = masked_small_image
开发者ID:SamViesselman,项目名称:SeniorDesignComputerVision,代码行数:33,代码来源:Image+Processing.py

示例11:

# 需要导入模块: from SimpleCV import Image [as 别名]
# 或者: from SimpleCV.Image import applyLayers [as 别名]

invertidos=green.invert()#se invierte la imagen para obtener manchas negras en la foto
blob=invertidos.findBlobs()#se ve si se encuentrasn las mannchas en la foto invertida
blob.show(width=2)
pruebalunar.addDrawingLayer(invertidos.dl())
pruebalunar.show()
pruebalunar.save("porfavorguardate2.png") #guardamos la imagen 


#enncontrar manchas por color especifico para el cual tenemos:
brown_distance=green.colorDistance(Color.BLACK).invert()##cmo buscamos de color negro , le pknemos black 
blobs2_=brown_distance.findBlobs()
blobs2_.draw(color=Color.PUCE ,width=3)#se va  hacer el mismo ejemplo de la guia
brown_distance.show()
green.addDrawingLayer(brown_distance.dl())
green.show()
green.save("Porfavorguaradte5.png")

#lineas=pruebalunar.findLines()
#lineas.draw(width=3)
#pruebalunar.show()
circles=pruebalunar.findCircle(canny=100,thresh=350,distance=15)
circles=circles.sortArea()
circles.draw(width=4)
img_with_circles= pruebalunar.applyLayers()
edges_in_image= pruebalunar.edges(t2=200)
final=pruebalunar.sideBySide(edges_in_image.sideBySide(img_with_circles)).scale(0.5)
final.show()
final.save("porfavorguardate.png") 
开发者ID:yavier123,项目名称:lab3pdi2016,代码行数:31,代码来源:fotoslunar.py

示例12: Image

# 需要导入模块: from SimpleCV import Image [as 别名]
# 或者: from SimpleCV.Image import applyLayers [as 别名]
from SimpleCV import Image, Color, Display
# load an image from imgur
img = Image('http://i.imgur.com/lfAeZ4n.png')
# use a keypoint detector to find areas of interest
feats = img.findKeypoints()
# draw the list of keypoints
feats.draw(color=Color.RED)
# show the  resulting image. 
img.show()
# apply the stuff we found to the image.
output = img.applyLayers()
# save the results.
output.save('juniperfeats.png')
开发者ID:RoboticaBrasil,项目名称:-ComputerVision,代码行数:15,代码来源:keypoints.py


注:本文中的SimpleCV.Image.applyLayers方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。