labels[(x, y)]
은 coordinate(x)
및 coordinate(y)
의 값을 반환합니다.
labels[(x, y)]
은 이미지에서 실제로 다른 모양을 나타내고 감지 후에는 각 모양이 다른 이미지로 저장됩니다. 모든 모양 또는 구성 요소에 대해 복수 if
조건을 사용하고 있습니다 (예 : if labels[(x, y)] == 0: # save it as an image
). 그러나 새로운 모든 모양에 대해 나는 을 사용하여 지금까지 새로운 if
을 만들어야합니다. 조건 하나만으로이 문제를 어떻게 해결할 수 있습니까? if
블록 이후coniditions의 경우 복수의 루프를 사용하는 방법
for (x, y) in labels:
component = uf.find(labels[(x, y)])
labels[(x, y)] = component
print (format(x) +","+ format(y)+ " " +format(labels[(x, y)]))
if labels[(x, y)]==0:
Zero[y][x]=int(255)
count=count+1
if count<=43:
continue
elif count>43:
Zeroth = Image.fromarray(Zero)
Zeroth.save(os.path.join(dirs, 'Zero.png'), 'png')
if labels[(x, y)]==1:
One[y][x]=int(255)
count1=count1+1
if count1<=43:
continue
elif count1>43:
First = Image.fromarray(One)
First.save(os.path.join(dirs, 'First.png'),'png')
University of Florida의 배열 파일과 그래서 , 레이블은 모든 좌표 x와 좌표 y에 값은 레이블이라고합니다. 그래서 "== 0"은 "0"으로 라벨이 붙은 하나의 모양을 의미합니다. 등등 – pixelthread
u는 해결할 수 있습니까? – pixelthread