I'm trying to create a 3D matrix stacking multiple images in order to create a 3D visualization of densities in order to interpolate those data and other operations... right now I'm trying to stack images with this code:
import numpy as np
import matplotlib.pyplot as plt
stacked = np.ndarray(shape=(300,300,20))
for s in range(11):
s=s+1
source = cv2.imread('IMAGE_#'+ str(s) +'.png',0)
m = np.asmatrix(source)
stacked[:,:,s]=m
x=stacked[:,0]
y=stacked[:,1]
z=stacked[:,2]
fig = plt.figure()
ax = fig.add_subplot(111, projection='3d')
ax.scatter(x,y,z)
plt.xlim(0,300)
plt.ylim(0,300)
plt.show()
but the plot results in something like this wrong plot
While I'm expecting a cloud of dots in the middle of the graph. What am I doing wrong?
EDIT 1>
To test the code feel free to use 'Image Stacking\StarM '+ str(s) +'.png',0
in the 10th line with this images:
https://wetransfer.com/downloads/7a3cdac121427d122787b5e24943d4b320210412123454/edfcc9
EDIT 2> changed the code as follows:
import numpy as np
import matplotlib.pyplot as plt
stacked = np.ndarray(shape=(300,300,20))
for s in range(11):
s=s+1
source = cv2.imread('ss\StarM '+ str(s) +'.png',2)
m = np.asmatrix(source)
stacked[:,:,s]=m
x=stacked[:,:,0]
y=stacked[:,:,1]
z=stacked[:,:,2]
fig = plt.figure()
ax = fig.add_subplot(111, projection='3d')
ax.scatter(x,y,z)
plt.xlim(0,300)
plt.ylim(0,300)
plt.show()
And now the plot shows: WrongPlot2
thx