You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
labels=sio.loadmat("Indian_pines_gt.mat")['indian_pines_gt']
palette=np.array([[255,0,0],[0,255,0],[0,0,255],[255,255,0],[0,255,255],[255,0,255],[176,48,96],[46,139,87],[160,32,240],[255,127,80],[127,255,212],[218,112,214],[160,82,45],[127,255,0],[216,191,216],[238,0,0]])
palette=palette*1.0/255
X_result=np.zeros((labels.shape[0],3))
num_class=labels.max()
or i in range(0,num_class):
X_result[np.where(labels==i),0]=palette[i,0]
X_result[np.where(labels==i),1]=palette[i,1]
X_result[np.where(labels==i),2]=palette[i,2]
X_result=np.reshape(X_result,(145,145,3))
I am getting the following error,
ValueError: cannot reshape array of size 435 into shape (145,145,3)
The text was updated successfully, but these errors were encountered:
X_result=np.zeros((labels.shape[0]*labels.shape[1],3))
num_class=labels.max()
X_result = np.zeros((labels.shape[0]*labels.shape[1],3))
for i in range(0,num_class):
X_result[np.where(labels==i),0] = palette[i,0]
X_result[np.where(labels==i),1] = palette[i,1]
X_result[np.where(labels==i),2] = palette[i,2]
I repeated the experiment as per your comment but I am not getting the plot of the image.
labels=sio.loadmat("Indian_pines_gt.mat")['indian_pines_gt']
palette=np.array([[255,0,0],[0,255,0],[0,0,255],[255,255,0],[0,255,255],[255,0,255],[176,48,96],[46,139,87],[160,32,240],[255,127,80],[127,255,212],[218,112,214],[160,82,45],[127,255,0],[216,191,216],[238,0,0]])
palette=palette*1.0/255
X_result=np.zeros((labels.shape[0],3))
num_class=labels.max()
or i in range(0,num_class):
X_result[np.where(labels==i),0]=palette[i,0]
X_result[np.where(labels==i),1]=palette[i,1]
X_result[np.where(labels==i),2]=palette[i,2]
X_result=np.reshape(X_result,(145,145,3))
I am getting the following error,
ValueError: cannot reshape array of size 435 into shape (145,145,3)
The text was updated successfully, but these errors were encountered: