Q:

Matlab vs C# Image pixel values

I have read the same image in Matlab and C# then compared the RGB channel values to find there is a slight difference (between 3 and -3 variation in about 4% of the pixels).
What is the reason for this difference???
Is that something that can be resolved? 
I used imread in Matlab and the following code in C# (dealt with 0-255 pixel values)
 Image Im1 = Image.FromFile("D:/VisualStudio2013/haarwt/haarwt/highcontrast1_512.jpg");
           Bitmap bmp = new Bitmap(Im1);

           Color c;
           double[,] Red = new double[bmp.Width, bmp.Height];
           double[,] Green = new double[bmp.Width, bmp.Height];
           double[,] Blue = new double[bmp.Width, bmp.Height];

            for (int j = 0; j < bmp.Height; j++)
            {
                for (int i = 0; i < bmp.Width; i++)
                {
                    c = bmp.GetPixel(i, j);
                    Red[i, j] = (double)c.R;
                    Green[i, j] = (double)c.G;
                    Blue[i, j] = (double)c.B;

                }
            }

A:

You are reading a .jpg file. Jpg files use a lossy compression. That is, the exact values are not preserved by encoding and then decoding an image. What you experience is different, yet related.
When you save an image using a lossy compression, exact values of the pixels are lost, that means it is the duty of the decompression algorithm to "guess" values. This leaves room for differences in implementation of the decompression algorithm, and might be the reason behind what you experience.
Jpeg compression/decompression work together to make these differences small and hard to notice, but the variations are there.

