# How to convert RGB to One Hot encoding of Pixel in Pascal VOC Dataset?

I am trying to implement Semantic Segmentation on PASCAL VOC 2007 Dataset using Fully Convolutional Network. My Network outputs images of (Height, Width, Classes); but the training label masks are of dimension (Height, Width, 3). How do I convert the training label mask to the dimension (Height, Width, Classes) so that proper loss can be computed?

I tried to extract out unique Pixel values of the image shown below. If the dataset contains 20 Unique classes then there should be 20 Unique values but I am getting around 380 unique values for one Image. Why?? What is the correct way of getting one hot encoded value of a pixel?

img = np.array(cv.imread(AddressofPngImage))
img = tf.cast(tf.image.resize(img,[274,274]),dtype = np.int32)
img = tf.reshape(img,[-1,3]).numpy()
np.unique(img,axis = 0)

array([[  0,   0,   0],
[  0, 192, 128],
[  1,   1,   1],
...,
[191, 222, 222],
[191, 223, 223],
[192, 224, 224]])