I have been trying to implement the algorithm for K times zooming on the above image as an input image. Below is my code:
img = cv2.imread("dog2.jpeg",1)
K = int(input("Enter the value of K: "))
x,y,c=img.shape
image = np.zeros((K * img.shape[0] - K + 1, K * img.shape[1] - K + 1,3),np.uint8)
for i in range(img.shape[0]):
for j in range(img.shape[1] - 1):
c0 = (int(img[i,j+1,0]) - int(img[i,j,0]))/K
c1 = (int(img[i,j+1,1]) - int(img[i,j,1]))/K
c2 = (img[i,j+1,2] - img[i,j,2])/K
for k in range(1,K):
image[K*i,K*j+k,0] = image[K*i,K*j+k-1,0] + c0
image[K*i,K*j+k,1] = image[K*i,K*j+k-1,1] + c1
image[K*i,K*j+k,2] = image[K*i,K*j+k-1,2] + c2
for j in range(img.shape[1]):
for i in range(img.shape[0] - 1):
c0 = (int(img[i+1,j,0]) - int(img[i,j,0]))/K
c1 = (int(img[i+1,j,1]) - int(img[i,j,1]))/K
c2 = (int(img[i+1,j,2]) - int(img[i,j,2]))/K
for k in range(1,K):
image[K*i+k,K*j,0] = image[K*i+k-1,K*j,0] + c0
image[K*i+k,K*j,1] = image[K*i+k-1,K*j,1] + c1
image[K*i+k,K*j,2] = image[K*i+k-1,K*j,2] + c2
I am getting the result shown below but obviously that not the result I am expecting and it's just a zoomed version of the input image. Where am I going wrong? Can someone please correct this.
Выходное изображение