for i inrange(2048): for j inrange(2048): if i<=2044and j<=2044: result[i][j]=img[round(i/4)][round(j/4)][0] else: result[i][j]=img[math.floor(i/4)][math.floor(j/4)][0] result=result.astype(np.uint8) cv.namedWindow("test",cv.WINDOW_NORMAL) cv.imshow("test",result) cv.waitKey(0)
for i inrange(2048): for j inrange(2048): if i<2044and j<2044: l=i//4 k=j//4 a=i/4-i//4 b=j/4-j//4 result[i][j]=img[l][k][0]*(1-a)*(1-b)+img[l+1][k][0]*a*(1-b)+img[l][k+1][0]*(1-a)*b+img[l+1][k+1][0]*a*b else: result[i][j]=img[i//4][j//4][0] result=result.astype(np.uint8) cv.namedWindow("test",cv.WINDOW_NORMAL) cv.imshow("test",result) cv.waitKey(0)
defweight(x): a=-0.5 x=abs(x) if x<=1: return (a+2)*x**3-(a+3)*x**2+1 if x<2: return a*x**3-5*a*x**2+8*a*x-4*a return0
for i inrange(2048): for j inrange(2048): if i>4and i<2040and j>4and j<2040: for k inrange(4): for w inrange(4): result[i][j]+=img[i//4+k-1][j//4+w-1][0]*weight(i/4-(i//4+k-1))*weight(j/4-(j//4+w-1)) else: result[i][j]=img[i//4][j//4][0] result=result.astype(np.uint8) cv.namedWindow("test",cv.WINDOW_NORMAL) cv.imshow("test",result) cv.waitKey(0)