0

I'm new around here but I've been using answers for a long time and they're always helpful, but I'm not finding this one.

I'm working with spectral python for some data manipulation, and I'm vastly changing my input data. In fact, I'm creating new binary images only based off of the original. I've got all of my code solid, except for the output. I need to have an array with a list for each line and a list (square brackets necessary) for each pixel's bands. It should look like this for a theoretical 3x3 pixel image of zeros:

 [[[ 0.]
   [ 0.]
   [ 0.]]
  [[ 0.]
   [ 0.]
   [ 0.]]
  [[ 0.]
   [ 0.]
   [ 0.]]]

However, the pixel only has one band, and I've been doing it by setting each value and appending them, but python seems to have this aversion to appending a single value list as a list, and what I get instead is:

[[0, 0, 0]
 [0, 0, 0]
 [0, 0, 0]]

...which my end software reads as a single row, 3 pixel image with incorrect bands.

Python doesn't have any issue loading existing images in that format, but won't create them. I've tried assigning each pixel as [0] or [1] rather than 0 or 1, I've tried appending each value to an empty list just for the pixel before appending to the row, and I can't find any other solutions. Is there a workaround I'm not seeing?

0 Answers0