本文整理汇总了Python中SimpleCV.Image.getPixel方法的典型用法代码示例。如果您正苦于以下问题:Python Image.getPixel方法的具体用法?Python Image.getPixel怎么用?Python Image.getPixel使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SimpleCV.Image
的用法示例。
在下文中一共展示了Image.getPixel方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: Image
# 需要导入模块: from SimpleCV import Image [as 别名]
# 或者: from SimpleCV.Image import getPixel [as 别名]
from SimpleCV import Image, Color
bluePincels = Image("ex19.jpg") # Open mm.png too :)
# Get a random value for color in a pixel 100,100 of the image
pixel = bluePincels.getPixel(100,100)
print pixel
# Distantiate the color of pixel picked previously
colorDist = bluePincels.colorDistance(pixel)
# Binarize the image and invert the colors to show most of the blue parts of the image
colorDistBin = colorDist.binarize(50).invert()
colorDistBin.show()
示例2: Image
# 需要导入模块: from SimpleCV import Image [as 别名]
# 或者: from SimpleCV.Image import getPixel [as 别名]
from SimpleCV import Image
img = Image('ex15.png')
# Retrieve the RGB triplet from (100, 100)
(red, green, blue) = img.getPixel(100, 100)
# Change the color of the pixel(100,100)
img[100, 100] = (0, 0, blue)
# Show the image for feel seconds
img.show()
# Saves the result image with a diferent name
img.save('ex15-result.png')
示例3: Image
# 需要导入模块: from SimpleCV import Image [as 别名]
# 或者: from SimpleCV.Image import getPixel [as 别名]
from SimpleCV import Image
img = Image('ex13.png')
pixel = img.getPixel(120, 150)
print pixel
示例4: Image
# 需要导入模块: from SimpleCV import Image [as 别名]
# 或者: from SimpleCV.Image import getPixel [as 别名]
from SimpleCV import Image
import time
img = Image('ladies.jpg')
#img.live()
# Gets the information for the pixel located at
# x coordinate = 120, and y coordinate = 150
pixel = img[120, 150]
# or
pixelll = img.getPixel(120, 150)
print pixel
print pixelll
print img.getGrayPixel(120, 150)
print img.height
print img.width
# Retrieve the RGB triplet from (120, 150)
(red, green, blue) = img.getPixel(223, 82)
# Change the color of the pixel+
img[215:230, 82:85] = (0, 0, 0)
# Resize the image so it is 5 times bigger then it's original size
bigImg = img.resize(img.width*1, img.height*1)
bigImg.show()
#img.show()
time.sleep(10)
示例5: __init__
# 需要导入模块: from SimpleCV import Image [as 别名]
# 或者: from SimpleCV.Image import getPixel [as 别名]
class Window2:
generation = 0
def __init__(self, filename, scale=1):
filename = os.path.expanduser(filename)
self.img = Image(filename)
self.max_x, self.max_y = self.img.width, self.img.height
self.scale = scale
self.array_map = np.array([[0 for y in range(self.max_y)] for x in range(self.max_x)])
for x in range(self.max_x):
for y in range(self.max_y):
pixel = self.img.getPixel(x, y)
self.array_map[x][y] = (pixel == (255, 255, 255))
# scale image
self.img = self.img.resize(self.img.width*scale, self.img.height*scale)
self.img_size = self.img.width, self.img.height
self.display = Display(self.img_size)
self.img.save(self.display)
def dot(self, p, color=Color.WHITE, size=0):
x, y = p[0], p[1]
#print "Drawing robot particle at {}, {}".format(x, y)
if x < 0 or x >= self.max_x:
print "Oh my god! x=", x
raise RuntimeError
if y < 0 or y >= self.max_y:
print "Oh shit! y=", y
raise RuntimeError
else:
self.img.dl().circle(center=(x*self.scale, y*self.scale), radius=size, color=color, width=1, filled=True)
def dot_red(self, p, color=Color.RED):
self.dot(p, color, 2)
def dots(self, coords, color=Color.WHITE, size=0):
for (x, y) in coords:
self.dot((x, y), color, size)
def clear(self):
self.img = Image(self.img_size)
#self.display.clear()
self.img.save(self.display)
def clear_dl(self):
self.img.clearLayers()
self.img.save(self.display)
def show(self):
self.img.save(self.display)
self.generation += 1
print "Generation = {}".format(self.generation)
self.wait_for_mouse()
print "Mouse pressed!"
def draw_robot(self, position, orientation):
color = Color.RED
#self.img.drawRectangle(p[0], p[1], 20, 40, color, 1)
self.dot(position, color, 2)
length = 20
bx = int(round(position[0] + cos(orientation) * length))
by = int(round(position[1] + sin(orientation) * length))
self.vector(position, orientation, length, detect_collision=False, color=color)
self.vector((bx, by), orientation - 3*pi/4, length=8, detect_collision=False, color=color)
self.vector((bx, by), orientation + 3*pi/4, length=8, detect_collision=False, color=color)
def vector(self, x, orientation, length, detect_collision=True, color=Color.FORESTGREEN):
bx = int(round(x[0] + cos(orientation) * length))
by = int(round(x[1] + sin(orientation) * length))
#self.dot_red((bx, by))
return self.line(x, (bx, by), detect_collision=detect_collision, color=color)
#return bx, by
# a = startpunkt, b = endpunkt
#@profile
def line(self, a, b, detect_collision=True, color=Color.BLUE):
"""http://en.wikipedia.org/wiki/Bresenham's_line_algorithm"""
# performance => use local vars
max_x = self.max_x
max_y = self.max_y
array_map = self.array_map
x0, y0 = a
x1, y1 = b
dx = abs(x1-x0)
dy = -abs(y1-y0)
if x0 < x1:
sx = 1
else:
sx = -1
if y0 < y1:
sy = 1
else:
sy = -1
#.........这里部分代码省略.........
示例6: Display
# 需要导入模块: from SimpleCV import Image [as 别名]
# 或者: from SimpleCV.Image import getPixel [as 别名]
from SimpleCV import Image, Display
import time
displayObject = Display()
img = Image('starry_night.png')
print 'Initial: %s' % (img.getPixel(25, 25),)
img.save(displayObject)
time.sleep(3)
hsv = img.toHSV()
print 'HSV: %s' % (hsv.getPixel(25, 25),)
hsv.save(displayObject)
time.sleep(3)
rgb = hsv.toRGB()
print 'RGB: %s' % (rgb.getPixel(25, 25),)
rgb.save(displayObject)
time.sleep(3)
gray = img.grayscale()