从图像上特定点提取的单个像素创建特征向量。

问题描述 投票:0回答:1

我有一张脸部图像,我想从图像的特定部分提取单个像素单位,并为这些点创建一个20维的矢量。

enter image description here

例如,这就是我想做的事情,到目前为止,我已经尝试过使用KeyPoints,从cv2中提取形状,甚至从图形中提取点,但都没有成功。因此,我想简单地尝试一下,但我不知道该怎么做。考虑到特征向量可以从图像中的每一个像素来表示,我希望创建一个简单的20-D特征向量,只由20个我认为在图像中特定位置有用的像素组成.例如:给定一张150x150的图像,我们可以假设有趣的像素在125x100125x5050x35的位置。

等等。

我试图使用PIL,特别是putpoint,我成功地插入了白色像素,但是图像被读为黑色,我仍然不知道如何从像素值中创建一个特征向量。

当我这样做的时候。

from PIL import Image
path = "elvis.jpg"

img = Image.open(path).convert('LA')
width, height = img.size
points = Image.new('L', (width, height))


points.putpixel((149, 59), (255))
points.putpixel((145, 97), (255))
points.putpixel((194, 11), (255))
points.putpixel((93, 92), (255))
points.putpixel((147, 35), (255))
points.putpixel((188, 140), (255))
points.putpixel((97, 195), (255))
points.save("elvispoints.png")

就会出现这种情况

enter image description here

我想手动将20个特定的像素设置为黑色。并将它们存储在一个20D的特征向量中。

python image image-processing computer-vision feature-extraction
1个回答
0
投票

PIL库中的putpixl就是我在寻找的。非常简单的路径="elvis.jpg"

img = Image.open(path).convert('LA')
width, height = img.size

img.show()

img.putpixel((149, 59), (255))
img.putpixel((145, 97), (255))
img.putpixel((194, 11), (255))
img.putpixel((93, 92), (255))
img.putpixel((147, 35), (255))
img.putpixel((188, 140), (255))
img.putpixel((97, 195), (255))
img.save("elvispoints.png")
© www.soinside.com 2019 - 2024. All rights reserved.