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


Python Image.size方法代码示例

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


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

示例1: test

# 需要导入模块: from SimpleCV import Image [as 别名]
# 或者: from SimpleCV.Image import size [as 别名]
def test():
    with timer('image'):
        img = Image('train/372.png')

    print "image size (%d, %d)" % img.size()

    with timer('parse'):
        p = parse_frame(img)
        print '--------------'

    return p
开发者ID:david-crespo,项目名称:py-super-hexagon,代码行数:13,代码来源:parse.py

示例2: capture_camera_image

# 需要导入模块: from SimpleCV import Image [as 别名]
# 或者: from SimpleCV.Image import size [as 别名]
def capture_camera_image():
    log("capture_camera_image()")
    image = None
    if USE_MOTION_CAMERA:
        image = Image(MOTION_CAMERA_SNAPSHOT)
    else:  # default to USE_WEB_CAMERA
        if cam is None:
            image = Camera().getImage()
        else:
            image = cam.getImage()

    size = image.size()

    # dynamic background mean color calculation
    if (BACKGROUND_AUTO_CALIBRATE):
        x = CROP_IMAGE_BORDERS[0]
        y = CROP_IMAGE_BORDERS[1]
        if (x > 0 and y > 0):
            background = image.crop(0, 0, x, y)
            mean_color = background.meanColor()
            log("background as (%d, %d, %d)" % (mean_color[0], mean_color[1], mean_color[2]))
            # save it
            db = db_open()
            db_backgrounds_write(db, db_background(date_created=datetime.now(), mean_color=mean_color))
            db_close(db)

    # if image border needs to be cropped
    x = CROP_IMAGE_BORDERS[0]
    y = CROP_IMAGE_BORDERS[1]
    if (x > 0 and y > 0):
        width = size[0] - 2 * x
        height = size[1] - 2 * y
        cropped = image.crop(x, y, width, height)
    else:
        cropped = image
    return cropped
开发者ID:jonahgroup,项目名称:SnackWatcher,代码行数:38,代码来源:utils.py

示例3: deMello

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


## Load an image from a filepath
## (Hong, deMello (2010): http://iopscience.iop.org/1748-605X/5/2/021001/fulltext/)
droplets = Image('data_s7.jpg')

## Once you have an image you can do a ton of stuff!
## URL (official documentation) about available methods: 
## http://simplecv.org/docs/SimpleCV.html#i/SimpleCV.ImageClass.Image


## Display the image & the image size
# droplets.show()
# time.sleep(5)
img_size = droplets.size()
# print 'Image size:', img_size


## Convert to black and white (applying a simple threshold value)
droplets = droplets.threshold(75)
# droplets.show()
# time.sleep(5)


## Cropping the image into the four pieces
## The x coords are always the whole size
x = 55
segment_height = img_size[1]/4
y_coords = [i * segment_height for i in range(4)]
# print segment_height, y_coords
开发者ID:oOo0oOo,项目名称:Pytut,代码行数:33,代码来源:session7.py

示例4: get_bounding_box

# 需要导入模块: from SimpleCV import Image [as 别名]
# 或者: from SimpleCV.Image import size [as 别名]
def get_bounding_box(keyword, url, filename):
    # get the image
    img = Image(url)

    # resize the image so things aren't so slow, if necessary
    w, h = img.size()
    if w > 1200 or h > 1200:
        maxdim = max(w, h)
        ratio = math.ceil(maxdim/800.0)
        print "   resizing..."
        img = img.resize(w=int(w/ratio), h=int(h/ratio))
    else:
        ratio = 1

    # get the canvas
    disp = Display((800, 800))
    # text overlay
    textlayer = DrawingLayer(img.size())
    textlayer.setFontSize(30)
    cx, cy = 10, 10
    for xoff in range(-2, 3):
        for yoff in range(-2, 3):
            textlayer.text(keyword, (cx + xoff, cy + yoff), color=Color.BLACK)
    textlayer.text(keyword, (cx, cy), color=Color.WHITE)

    # two points to declare a bounding box
    point1 = None
    point2 = None
    while disp.isNotDone():
        cursor = (disp.mouseX, disp.mouseY)
        if disp.leftButtonUp:
            if point1 and point2:
                point1 = None
                point2 = None
            if point1:
                point2 = disp.leftButtonUpPosition()
            else:
                point1 = disp.leftButtonUpPosition()
        bb = None
        if point1 and point2:
            bb = disp.pointsToBoundingBox(point1, point2)
        elif point1 and not point2:
            bb = disp.pointsToBoundingBox(point1, cursor)

        img.clearLayers()
        drawlayer = DrawingLayer(img.size())
        if bb:
            drawlayer.rectangle((bb[0], bb[1]), (bb[2], bb[3]), color=Color.RED)

        # keyboard commands
        if pygame.key.get_pressed()[pygame.K_s]:
            # skip for now
            raise Skip()
        elif pygame.key.get_pressed()[pygame.K_b]:
            # mark it as an invalid picture
            raise BadImage()
        elif pygame.key.get_pressed()[pygame.K_RETURN]:
            if point1 and point2:
                bb = disp.pointsToBoundingBox(scale(ratio, point1), scale(ratio, point2))
                return bb
            elif not point1 and not point2:
                bb = disp.pointsToBoundingBox((0, 0), (w, h))
                return bb


        drawlayer.line((cursor[0], 0), (cursor[0], img.height), color=Color.BLUE)
        drawlayer.line((0, cursor[1]), (img.width, cursor[1]), color=Color.BLUE)
        #drawlayer.circle(cursor, 2, color=Color.BLUE, filled=True)
        img.addDrawingLayer(textlayer)
        img.addDrawingLayer(drawlayer)
        img.save(disp)
开发者ID:stephenroller,项目名称:imsgrounded,代码行数:73,代码来源:annotation.py

示例5: Image

# 需要导入模块: from SimpleCV import Image [as 别名]
# 或者: from SimpleCV.Image import size [as 别名]
# from SimpleCV import *
from SimpleCV import Image, ColorCurve
from etc import settings
import os, random, sys

fn = sys.argv[1]
shortname = sys.argv[2]
bg_fn = random.choice(os.listdir("/opt/photopops/assets/backgrounds"))

gs = Image("/opt/photopops/events/%s/orig/%s" % (shortname, fn))
gs_x, gs_y = gs.size()
# background = Image("/opt/photopops/assets/backgrounds/%s" % bg_fn)
background = Image("%s/%s" % (settings.BG_FOLDER, bg_fn))
background = background.scale(gs_x, gs_y)

matte = gs.toHLS()
cc = ColorCurve([[0, 50], [40, 40], [90, 110], [255, 150]])
cc2 = ColorCurve([[0, 0], [80, 40], [170, 90], [255, 240]])
matte = gs.toRGB()
matte = matte.hueDistance(color=[0, 200, 0], minvalue=20, minsaturation=90)
matte = matte.applyIntensityCurve(cc2).binarize(thresh=30).bilateralFilter().morphOpen().smooth(aperature=(5, 5))

result = (gs - matte) + (background - matte.invert())
result.save("/opt/photopops/events/%s/proc/%s" % (shortname, fn))
开发者ID:mattgorecki,项目名称:photopops-python,代码行数:26,代码来源:greenscreen.py

示例6: Image

# 需要导入模块: from SimpleCV import Image [as 别名]
# 或者: from SimpleCV.Image import size [as 别名]
'''
This program super imposes the camera onto the television in the picture
'''
print __doc__

from SimpleCV import Camera, Image, Display

tv_original = Image("family_watching_television_1958.jpg", sample=True)

tv_coordinates = [(353, 379), (433,380),(432, 448), (354,446)]
tv_mask = Image(tv_original.size()).invert().warp(tv_coordinates)
tv = tv_original - tv_mask

c = Camera()
d = Display(tv.size())

while d.isNotDone():
   bwimage = c.getImage().grayscale().resize(tv.width, tv.height)
   on_tv = tv + bwimage.warp(tv_coordinates)
   on_tv.save(d)
开发者ID:ALitTLeQ,项目名称:SimpleCV,代码行数:22,代码来源:tvexample.py

示例7: Image

# 需要导入模块: from SimpleCV import Image [as 别名]
# 或者: from SimpleCV.Image import size [as 别名]
edge_test = eye_gray + eye_edges


eye_final = eye_edges

#Perform closing to find individual objects
eye_final = eye_final.dilate(2)
eye_final = eye_final.erode()

eye_final = eye_final.dilate(4)
eye_final = eye_final.erode(3)

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")
开发者ID:SamViesselman,项目名称:SeniorDesignComputerVision,代码行数:33,代码来源:Image+Processing.py

示例8: int

# 需要导入模块: from SimpleCV import Image [as 别名]
# 或者: from SimpleCV.Image import size [as 别名]
            f['y'] = int((f['y'] + new['y']) / 2.0)
            f['width'] = max(f['width'], new['width'])
            f['height'] = max(f['height'], new['height'])
            break

    face_method.append(new)
    if add_new:
        faces.append(new)



ind = 0
for paint in db:
    print str(ind)
    i = ImageCV('./barroco/' + str(paint ['id']) + '.jpg')
    paint['resolution'] = {'width':i.size()[0], 'height':i.size()[1]}
    paint['faces'] = []
    paint['face_methods'] = {}

    for xml in xmls:
        faces = i.findHaarFeatures(
            '/usr/local/share/OpenCV/haarcascades/' + xml['file'])
        face_method = []
        paint['face_methods'][xml['code']]=face_method
        if faces:
            for f in faces:
                fuzzy_add({ 'x':f.coordinates()[0],
                            'y':f.coordinates()[1],
                            'width':f.width(),
                            'height':f.height() },
                            paint['faces'],
开发者ID:drtimcouper,项目名称:gamex,代码行数:33,代码来源:detect_faces.py


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