1
我想從一幅圖像中提取綠色矢量。圖像上有紅色和綠色的點,並制定電網從一幅圖像中提取綠色矢量
def each_green_vector(im):
pixels = im.load_image(im)
utils.apply_to_each_pixel(pixels, lambda x: 0.0 if x >10 else 1.0)
msize = m_mesh.rows*m_mesh.cols;
(x, y) = imsize
vec = []
for i in range(1,x -1):
for j in range (1, y -1):
grid = grid_at(pixels, i, j)
if grid != "none":
if grid ==1:
vec.append((i,j));
gx = list[i].x/m_mesh.gWidth;
gy = list[i].y/m_mesh.gHeight;
grid = gx + gy *m_mesh.cols;
vec[grid] == 1;
return vec
一個可能的解決辦法是使用OpenCV的,在HSV轉換,然後綠顏色的面具。 – Mathieu