0
저는 pyfits를 사용하여 2D 배열에로드 할 이미지가 있습니다. 이미지의 두 픽셀을 통해 선을 그려 새로운 선을 추가하여 저장하려고합니다 (플롯 아님). 이 후 다른 색상으로 이전 선에 수직 인 선을 그립니다. matplotlib를 사용하여 이것을 달성하는 가장 좋은 방법은 무엇입니까? 나는 PIL로 시도했다. 나는 그것을 할 수 없었다. 코드를보고이를 수행 할 수있는 방법을 제안하십시오. 나는 또한 이미지를 붙이고있다이미지 파이썬 matplotlib의 두 점을 통해 선 그리기
def plotAxes(map, angle, x_centroid, y_centroid):
hor = math.floor(x_centroid + 20*(math.cos(angle)))
ver = math.floor(y_centroid - 20*(math.sin(angle)))
hor1 = math.floor(x_centroid + 20*(math.cos(angle+90.0)))
ver1 = math.floor(y_centroid - 20*(math.sin(angle+90.0)))
map_height = len(map)
map_width = len(map[0])
point = [ver, hor]
center = [y_centroid, x_centroid]
Max = np.max(map)
array = np.zeros((map_height, map_width), int)
for i in range(0, map_height):
for j in range(0, map_width):
array[i][j] = (math.floor((float(map[i][j])/float(Max))*255))
im = Image.fromarray(np.uint8(array))
draw = ImageDraw.Draw(im)
draw.line((x_centroid,y_centroid, hor,ver ), fill="red")
draw.line((x_centroid,y_centroid, hor1,ver1 ), fill="red")
im.show()
그러나 위의 코드는 선을 수직으로 인쇄하지 않는 것 같습니다. 각도는 120 대신
이 편집은 확실히 문제를 개선합니다. 재개하기 위해 투표. –
필요한 변경을했습니다. 미안해지기 전에 미안해. :). 감사 – chaithu