Python Forum
problem adding two numpy arrays
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
problem adding two numpy arrays
#3
The problem is not adding the arrays, the problem is that one of the arrays has the wrong dtype. The dtype for base_image1 should be np.int8. You could have determined this by looking at the dtype for image1, or just use dtype from image1.
image = Image.open(path)
image.putalpha(255)
image1 = np.array(image)

# Make larger numpy array of all zeroes
base_image1 = np.zeros((605, 405, 4), dtype=image1.dtype)
You can copy image1 into base_image1 without the extra addition step.
base_image1[x:(x+height),y:(y+width),:] = image1
Reply


Messages In This Thread
problem adding two numpy arrays - by djf123 - Jul-19-2020, 04:00 PM
RE: problem adding two numpy arrays - by Addweb - Aug-09-2022, 10:49 AM
RE: problem adding two numpy arrays - by deanhystad - Aug-09-2022, 08:31 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Matplot / numpy noisy data problem the57chambers 1 708 Feb-09-2023, 03:27 AM
Last Post: deanhystad
  Django: Adding Row Data To Existing Model Instance Question/Problem. Steven_Pinkerton 1 1,265 Aug-09-2022, 10:46 AM
Last Post: Addweb
  how to join by stack multiple types in numpy arrays caro 1 1,156 Jun-20-2022, 05:02 PM
Last Post: deanhystad
  SOlving LInear Equations in Python(Symoy, NUmpy) - Coefficient Problem quest 3 1,769 Jan-30-2022, 10:53 PM
Last Post: quest
  numpy.dot() result different with classic computation for large-size arrays geekgeek 5 1,919 Jan-25-2022, 09:45 PM
Last Post: Gribouillis
  Two numpy arrays Sandra2312 1 1,822 Jan-18-2021, 06:10 PM
Last Post: paul18fr
  numpy in1d with two simple arrays claw91 3 2,611 Sep-21-2020, 12:43 PM
Last Post: scidam
  Type coercion with Numpy arrays Mark17 2 2,544 Jul-24-2020, 02:04 AM
Last Post: scidam
  filling and printing numpy arrays of str pjfarley3 4 3,327 Jun-07-2020, 09:09 PM
Last Post: pjfarley3
  Problem with adding arbitrary parrameters to __init__ method sebastianvdn 1 2,005 Feb-03-2020, 09:30 PM
Last Post: micseydel

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020