I am wondering how slide viewers invert the negative slides into positive colours. Sorry if my question could be ill posed as I am lacking enough knowledge.
If you're talking about the traditional slide viewers, they don't. The slide is a positive colour slide, all a slide viewer can do is shine light through a slide. If you put a negative slide, or a standard 35mm negative into the slide viewer, then the negative image will be projected.
There are negative viewers available at some photo labs that invert the image.
They are essentially a video camera with a display that shows the inverted colors of the camera. This is helpful for viewing negatives and deciding which ones to print/enlarge.
Early in the history of photography color imaging was demonstrated. Three pictures were taken on black and white film. One with a red filter mounted, one with green, and one with blue. The three pictures were superimposed, projected on a screen. The projectors were fitted with the same color filters. The year was 1855 and the photographer was James Maxwell. That day, the world saw the first color picture made with a camera.
Today color film and TV and computer screens as well as phone screens follow this same principle. They all present three superimposed filtered black & white images. Your eye/brain interpolates and you see an image in full color.
Now the modern digital camera and scanner proceed, taking this method a bit further. The computer logic they use, fractures the picture into millions of super tiny points of red, green, and blue light. Tiny as they are, each is the smallest element of a picture that can convey intelligence. We call this digital imaging as each picture element (pixel) is assigned a numeral value. The word digit is Latin for finger; we all count on our fingers from time to time.
Each color and the intensity of the color is assigned a number value based on an recognized coding method. When the digital camera or scanner makes a picture, the entire representation is broken down to millions of pixels and each assigned a numeral that conveys its color shading. This is truly a paint-by-number scheme.
OK, you now know that all digital pictures consist of pixels and each has a number value. Next you need to know that each color has an opposite color. We call opposite colors “componentry” colors. Red has a compliment; it is cyan, a mix of blue + green. Green’s compliment is magenta, a mix of blue + red. Blue has a compliment, it is yellow. We discover the compliments by making a color wheel and drawing a line from one color, through the center to the color on the opposite side of the circle.
Computer logic can invert any picture to a negative, conversely, a negative can be inverted to a positive by simply changing the pixel value to the value of the color on the opposite side of the color wheel.