本文整理汇总了Python中SimpleCV.Image.scale方法的典型用法代码示例。如果您正苦于以下问题:Python Image.scale方法的具体用法?Python Image.scale怎么用?Python Image.scale使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SimpleCV.Image
的用法示例。
在下文中一共展示了Image.scale方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: scale
# 需要导入模块: from SimpleCV import Image [as 别名]
# 或者: from SimpleCV.Image import scale [as 别名]
def scale(self, img_path, scale):
new_file_path = self.nfn('resized')
img = Image(img_path)
img = img.scale(scale)
img.save(new_file_path)
self.transformations.append(new_file_path)
return new_file_path
示例2: rotate_and_resize
# 需要导入模块: from SimpleCV import Image [as 别名]
# 或者: from SimpleCV.Image import scale [as 别名]
def rotate_and_resize(si, left_sm, right_sm):
new_file_path = step_file_path(si, 'rotate')
img = Image(si.step_outputs[-1:][0])
rot = right_sm.toe_heel_angle() + left_sm.toe_heel_angle()
img = img.rotate(rot, fixed=True)
si.step_outputs.append(new_file_path)
img.save(new_file_path)
scale = left_sm.shoe_length() / right_sm.shoe_length()
new_file_path = step_file_path(si, 'scale-length')
img = img.scale(scale)
si.step_outputs.append(new_file_path)
img.save(new_file_path)
# We also resize the original file
orig_img = Image(si.step_outputs[0])
orig_img = orig_img.rotate(rot, fixed=True)
orig_img = orig_img.scale(scale)
new_file_path = step_file_path(si, 'transformed-original')
si.step_outputs.append(new_file_path)
orig_img.save(new_file_path)
return new_file_path
示例3: Image
# 需要导入模块: from SimpleCV import Image [as 别名]
# 或者: from SimpleCV.Image import scale [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))
示例4: Image
# 需要导入模块: from SimpleCV import Image [as 别名]
# 或者: from SimpleCV.Image import scale [as 别名]
from SimpleCV import Image, Display, Color
import numpy as np
import cv2
img = Image('disp.jpg')
img = img.scale(1)
# roughly the number of tiles in an image
# caclulate the value of a row
# using the integral image
def idxToSum(x1,x2,y,integral):
# assume x2 > x1
p3 = integral[y+1,x2+1]
p2 = integral[y+1,x1-1]
p1 = integral[y,x2+1]
p0 = integral[y,x1-1]
val = p3-p2-p1+p0
return val
# roughly how far we scan horizontally
window = 2*80 #int(img.width/repeats)
repeats = np.floor(img.width/window)
print "window: {0}".format(window)
# how big of a signal we convolve
samplesz = window / 10
print "sample: {0}".format(samplesz)
dmap = np.zeros([img.width-window,img.height],dtype='int32')
integral = cv2.integral(img.getGrayNumpyCv2())
# we'll do this with iteration first to test
# proof of concept.
print (img.width,img.height)
# need to double check these bounds with the integral image
示例5: Camera
# 需要导入模块: from SimpleCV import Image [as 别名]
# 或者: from SimpleCV.Image import scale [as 别名]
from SimpleCV import Camera, Display, HaarCascade, Image
#initialize the camera
cam = Camera()
# Create the display to show the image
display = Display()
# Load the new face image
troll_face = Image('troll_face.png', sample=True)
# Haar Cascade face detection, only faces
haarcascade = HaarCascade("face")
# Loop forever
while display.isNotDone():
# Get image, flip it so it looks mirrored, scale to speed things up
img = cam.getImage().flipHorizontal().scale(0.5)
# load in trained face file
faces = img.findHaarFeatures(haarcascade)
# If there were faces found do something
if faces:
face = faces[-1]
# Load the image to super impose and scale it correctly
troll = troll_face.scale(face.height(), face.width())
mymask = troll.invert()
# Super impose the new face on the existing face
img = img.blit(troll, face.topLeftCorner(), alphaMask=mymask)
# Display the image
img.save(display)
示例6: fancify
# 需要导入模块: from SimpleCV import Image [as 别名]
# 或者: from SimpleCV.Image import scale [as 别名]
def fancify():
if request.method == 'POST':
print request.data
cur_request = json.loads(request.data)
else:
#cur_request = """{"url": "", "debug":true}"""
#cur_request = """{"url": "", "debug":true}"""
#cur_request = """{"url": "", "debug":true}"""
cur_request = """{"url": "http://localhost/images/scrubs.jpg", "debug":true}"""
#cur_request = """{"url": "http://www.newrichstrategies.com/wp-content/uploads/2012/03/How-to-Find-Good-People-in-Your-Life.jpg", "debug":false}"""
#cur_request = """{"url": "http://greenobles.com/data_images/frank-lampard/frank-lampard-02.jpg", "debug":true}"""
#cur_request = """{"url": "http://www.billslater.com/barack__obama.jpg"}"""
#cur_request = """{"url": "http://celebrityroast.com/wp-content/uploads/2011/01/arnold-schwarzenegger-body-building.jpg", "debug":false}"""
#cur_request = """{"url": "http://face2face.si.edu/.a/6a00e550199efb8833010536a5483e970c-800wi", "debug":true}"""
#cur_request = """{"url": "http://collider.com/uploads/imageGallery/Scrubs/scrubs_cast_image__medium_.jpg", "debug":false}"""
#cur_request = """{"url": "http://localhost/images/Kevin_Bacon_at_the_2010_SAG_Awards.jpg", "debug":false}"""
#cur_request = """{"url": "http://cdn02.cdn.justjared.com/wp-content/uploads/headlines/2012/02/anna-faris-oscars-red-carpet-2012.jpg", "debug":true}"""
#cur_request = """{"url": "http://www.viewzone.com/attractive.female.jpg", "debug":true}"""
cur_request = json.loads(cur_request)
print cur_request["url"]
img = Image(str(cur_request["url"]))
img = img.scale(2.0)
debug = True
#if "debug" in cur_request:
# debug = cur_request["debug"]
chosen_faces = []
faces = img.findHaarFeatures(face_cascade)
if faces is not None:
for face in faces:
face_features = []
invalid_face = False
face_rect = Rect(face.x - (face.width() / 2), face.y - (face.height() / 2), face.width(), face.height())
for chosen_face in chosen_faces:
if face_rect.colliderect(chosen_face):
invalid_face = True
break
if invalid_face:
break
nose = None
mouth = None
left_eye = None
right_eye = None
cur_face = img.crop(face.x, face.y, face.width(), face.height(), centered=True)
#cur_face = face.crop()
noses = cur_face.findHaarFeatures(nose_cascade)
mouths = cur_face.findHaarFeatures(mouth_cascade)
eyes = cur_face.findHaarFeatures(eye_cascade)
face_left_edge = face.x - (face.width() / 2)
face_top_edge = face.y - (face.height() / 2)
if noses is not None:
nose = noses[0]
nose_dist = (abs(nose.x - (face.width() / 2)) +
abs(nose.y - (face.height() * 5 / 9)) +
abs(nose.width() - (face.width() / 4)))
for cur_nose in noses:
cur_dist = (abs(cur_nose.x - (face.width() / 2)) +
abs(cur_nose.y - (face.height() * 5 / 9)) +
abs(cur_nose.width() - (face.width() / 4)))
if cur_dist < nose_dist:
nose = cur_nose
nost_dist = cur_dist
if nose and (nose.y < (face.height() / 3)):
nose = None
if nose and mouths is not None:
mouth = mouths[0]
mouth_dist = abs(mouth.x - nose.x) + (abs(mouth.y - (face.height() * 4 / 5)) * 2)
for cur_mouth in mouths:
cur_dist = abs(cur_mouth.x - nose.x) + (abs(cur_mouth.y - (face.height() * 4/ 5)) * 2)
if (cur_dist < mouth_dist) and (cur_mouth.y > nose.y):
mouth = cur_mouth
mouth_dist = cur_dist
if nose and eyes:
right_eye = eyes[0]
right_eye_dist = (abs(right_eye.x - (3 * face.width() / 4)) * 2 +
abs(right_eye.y - (nose.y - (nose.height() / 2)) / 2) +
abs(right_eye.width() - (face.width() / 3)))
for cur_eye in eyes:
cur_right_dist = (abs(cur_eye.x - (3 * face.width() / 4)) +
abs(cur_eye.y - (nose.y - (nose.height() / 2)) / 2) +
abs(cur_eye.width() - (face.width() / 3)))
if (cur_right_dist <= right_eye_dist): # and (cur_eye.y < nose.y):
right_eye = cur_eye
right_eye_dist = cur_right_dist
if nose and right_eye and (((right_eye.y - (right_eye.height() / 2)) > nose.y) or (right_eye.x < nose.x)):
print "Culling right_eye"
right_eye = None
#.........这里部分代码省略.........