파이썬 Python에서 이미지를 여러 조각으로 분할하는 방법
PIL을 사용하여 사진을 여러 조각으로 분할하려고합니다. def crop(Path,input,height,width,i,k,x,y,page): im = Image.open(input) imgwidth = im.size[0] imgheight = im.size[1] for i in range(0,imgheight-height/2,height-2): print i for j in range(0,imgwidth-width/2,width-2): print j box = (j, i, j+width, i+height) a = im.crop(box) a.save(os.path.join(Path,"PNG","%s" % page,"IMG-%s.png" % k)) k +=1 하지만 작동하지 않는 것 같습니다. 사진을 분할..
2020. 10. 3.
파이썬 Python의 MATLAB 스타일 find () 함수
MATLAB에서는 특정 조건을 충족하는 값의 인덱스를 쉽게 찾을 수 있습니다. >> a = [1,2,3,1,2,3,1,2,3]; >> find(a > 2) % find the indecies where this condition is true [3, 6, 9] % (MATLAB uses 1-based indexing) >> a(find(a > 2)) % get the values at those locations [3, 3, 3] 파이썬에서 이것을 수행하는 가장 좋은 방법은 무엇입니까? 지금까지 다음과 같이 생각했습니다. 값을 얻으려면 : >>> a = [1,2,3,1,2,3,1,2,3] >>> [val for val in a if val > 2] [3, 3, 3] 그러나 각 값의 색인을 원한다면 조금 ..
2020. 10. 3.