Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

430
Views
Cómo usar img.shape() en javascript

importar cv2

leer imagen

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

obtener las dimensiones de la imagen

dimensions = img.shape

alto, ancho, número de canales en la imagen

 height = img.shape[0] width = img.shape[1] channels = img.shape[2] print('Image Dimension : ',dimensions) print('Image Height : ',height) print('Image Width : ',width) print('Number of Channels : ',channels)
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

por la cantidad de canales que necesitas hacer

 channels = image.shape[-1] if image.ndim == 3 else 1

Esto se debe a que la cantidad de canales no se mostrará si está en escala de grises. Y es por eso que se comprueba image.ndim.

Para obtener ancho y alto, simplemente haga lo que ya hizo en su ejemplo

Y para las dimensiones que podría hacer:

 dimensions = f"{width}x{height}"

si quieres que regrese en una cadena. De lo contrario, si desea que regrese como una tupla, solo serán los primeros 2 objetos en img.shape.

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!