Created
August 3, 2022 17:09
-
-
Save maheshs11/332ac21ed3bbcf8470f0f5fe7b80459e to your computer and use it in GitHub Desktop.
np.reshape
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
image = cv2.imread("/content/paper1.jpg") | |
_shape_1= image.shape | |
print("The shape of image is:",_shape_1) | |
print("The product shape of image is:", np.prod(_shape_1)) | |
dim = np.prod(_shape_1) | |
num = dim | |
factors=[] | |
for i in range(1,num+1): | |
if num%i==0: | |
factors.append(i) | |
#print ("Factors of shape is {} = {}".format(num,factors)) | |
test = [] | |
for i in factors: | |
for j in factors: | |
for k in range(0,1000): | |
if i*j*k == num: | |
if i <= 3000 and j <= 5000 and k <=3: # set this values acc to required shape | |
test.append([i,j,k]) | |
print("The possible values to reshape: ",test) | |
print("The size to be reshaped to:",tuple(test[0])) | |
moy = np.reshape(image,tuple(test[0])) | |
new_shape = moy.shape | |
print("The reshaped image size is: ",new_shape) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment