logo
down
shadow

Python OpenCV: Cannot resize image


Python OpenCV: Cannot resize image

Content Index :

Python OpenCV: Cannot resize image
Tag : python , By : Menno
Date : November 24 2020, 03:01 PM

Hope this helps OpenCV uses NumPy arrays as the fundamental datatype to represent images. Indeed NumPy has a resize method to "resize" the data, but you're not using it properly. By consulting the documentation, the numpy.resize method requires you to reverse the order of your parameters. The input array goes first followed by the desired size. You have it almost correct - just swap the order of the arguments.
However, I don't believe this is what you're looking for since numpy.resize fills in the output array with repeated copies of the input - especially since you're doing this for facial recognition. I believe you want to resize the contents of the image to fit the desired size, not fill in the array with repeated copies of the input with its original size intact.
resize_image = cv2.resize(img, (200,200))
resize_image = cv2.resize(img, (200,200), interpolation=cv2.INTER_CUBIC)

Comments
No Comments Right Now !

Boards Message :
You Must Login Or Sign Up to Add Your Comments .

Share : facebook icon twitter icon

OpenCV Python resize image


Tag : python , By : Al Dimond
Date : March 29 2020, 07:55 AM
With these it helps The problem was I was trying to get coordinate picture that were negative so it couldn't get it. I just expanded condition if pt1+leng > width or pt2+leng > height or pt2 < 0 or pt1 < 0: and it works.

Resize image faster in OpenCV Python


Tag : python , By : Cube_Zombie
Date : March 29 2020, 07:55 AM
I think the issue was by ths following , If you are absolutely intent on doing this in Python, then please just disregard my answer. If you are interested in getting the job done simply and fast, read on...
I would suggest GNU Parallel if you have lots of things to be done in parallel and even more so as CPUs become "fatter" with more cores rather than "taller" with higher clock rates (GHz).
magick mogrify -resize 128x128\! *.jpg
parallel magick mogrify -resize 128x128\! ::: *.jpg
find -iname \*.jpg -print0 | parallel -0 -X --eta magick mogrify -resize 128x128\!
DIR /S /B *.JPG > filenames.txt
magick mogrify -resize 128x128\! @filenames.txt
parallel --eta -a filenames.txt magick mogrify -resize 128x128\!

resize transparent image in opencv python (cv2)


Tag : python , By : RyanMcG
Date : March 29 2020, 07:55 AM

How to resize PNG image in opencv python?


Tag : python , By : Jakub Filak
Date : March 29 2020, 07:55 AM
I hope this helps . i am trying to resize the following PNG image without losing transparent background (alpha channel) using cv2.resize() function but it only shows the original image with same dimensions [![][1]][1] , Try something like this
import cv2

img = cv2.imread('/home/img/python.png', cv2.IMREAD_UNCHANGED)

print('Original Dimensions : ',img.shape)

width = 350
height = 450
dim = (width, height)

# resize image
resized = cv2.resize(img, dim, interpolation = cv2.INTER_AREA)

print('Resized Dimensions : ',resized.shape)

cv2.imshow("Resized image", resized)
cv2.waitKey(0)
cv2.destroyAllWindows()

Image resize do not display the correct image in opencv python


Tag : python-3.x , By : TBG
Date : October 04 2020, 07:00 PM
Hope this helps By downsizing to 1 pixel you loose nearly all image information as all y-pixels get interpolated to a single number per x-pixel. By resizing back that pixel is then copied vertically to 500px, so I expect you to get a stripy pattern.
You should not resize, you have to reshape. That means putting the pixel values from a 2d array to a 1d array, that is what the PCA algorithm expects.
# create 2d array
y = np.array(range(9)).reshape(3,3)
print(y)
# reshape to 1d
x = y.reshape(-1)
print(x)
print(x.shape[:2])
Related Posts Related QUESTIONS :
  • Django: QuerySet with ExpressionWrapper
  • Pandas string search in list of dicts
  • Decryption from RSA encrypted string from sqlite is not the same
  • need of maximum value in int
  • a list of several tuples, how to extract the same of the first two elements in the small tuple in the large tuple
  • Display image of 2D Sinewaves in 3D
  • how to prevent a for loop from overwriting a dictionary?
  • How To Fix: RuntimeError: size mismatch in pyTorch
  • Concatenating two Pandas DataFrames while maintaining index order
  • Why does this not run into an infinite loop?
  • Python Multithreading no current event loop
  • Element Tree - Seaching for specific element value without looping
  • Ignore Nulls in pandas map dictionary
  • How do I get scrap data from web pages using beautifulsoup in python
  • Variable used, golobal or local?
  • I have a regex statement to pull all numbers out of a text file, but it only finds 77 out of the 81 numbers in the file
  • How do I create a dataframe of jobs and companies that includes hyperlinks?
  • Detect if user has clicked the 'maximized' button
  • Does flask_login automatically set the "next" argument?
  • Indents in python 3
  • How to create a pool of threads
  • Pandas giving IndexError on one dataframe but not on another similar dataframe
  • Django Rest Framework - Testing client.login doesn't login user, ret anonymous user
  • Running dag without dag file in airflow
  • Filling across a specified dimension of a numpy array
  • Python populating dataframe in pandas from text files
  • How to interpolate a single ("non-piecewise") cubic spline from a set of data points?
  • Divide 2 integers (leetcode 29) - recursion issue
  • Can someone explain why do I get this output in Python?
  • How do I scrape pdf and html from search results without obvious url
  • Is there a way to automatically make a "collage" of plots with matplotlib?
  • How to combine multiple rows in pandas with shared column values
  • How do I get LOAD_CLASSDEREF instruction after dis.dis?
  • Django - How to add items to Bootstrap dropdown?
  • Linear Regression - Does the below implementation of ridge regression finding coefficient term using gradient method is
  • How to drop all rows in pandas dataframe with negative values?
  • Most Efficient Way to Find Closest Date Between 2 Dataframes
  • Execution error when Passing arguments to a python script using os.system. The script takes sys.argv arguments
  • Looping through a function
  • Create a plot for each unique ID
  • a thread python with 'while' got another thread never start
  • Solution from SciPy solve_ivp contains oscillations for a system of first-order ODEs
  • trigger python events driven by selenium controlled browser
  • Passing line-edits to a contextmanager to set validators
  • Python: globals().items() iterations try to change a dict
  • Is it possible to specify starting values for each parameter (instead of bounds) for scipy's differential evolution?
  • why datetime.now() and constructed datetime using all fields(like year,month...) of now has big timedelta?
  • MySQL multiple table UPDATE query using sqlalchemy core?
  • find if a semantic version is superset of of another version python
  • Type checking against dynamically created objects
  • Struggling with simple reverse function
  • Is there a function for finding the midpoint of n points on sklearn.neighbors.NearestNeighbors?
  • How to set max number of tweets to fetch
  • PYTHON 3.7.4 NOT USING SQLITE 3.29.0
  • How to replace Nan value with zeros in a numpy array?
  • How to speed up calculating variance among sparse matrix
  • cupy code is not fast enough compared with numpy
  • How to count frequency of select values in Python pandas dataframe
  • Scrape Span Text from Google
  • Python watchdog, watch a directory and rename file on event.modification
  • shadow
    Privacy Policy - Terms - Contact Us © scrbit.com