title: C# Dividing a Matrix into Sub Blocks
body: <p>i have a matrix came from an image 1600x1600. now i need to assign this matrix into  4x4 blocks. As an example:</p>
  
  <pre><code>              00 01 02 03
        IMAGE = 04 05 06 07        BLOCK(i) =   00 01       BLOCK(i+1) = 02 03
                08 09 0A 0B                     04 05                    06 07
                0C 0D 0E 0F
                                  BLOCK(i+2) = 08 09        BLOCK(i+3) = 0A 0B
                                               0C 0D                   = 0E 0F
  </code></pre>
  
  <p>1 ) Firstly i dont know the image dimensions , the user opens it. i get it later. my test image 1600x1600.But blocks dimensions are fixed at 4x4. And image dimensions are , lets we agree can be divided with 4 for now...</p>
  
  <p>2 ) I dont know how many blocks going to be.</p>
  
  <p>3 ) I need to acces the row and coloumb of the blocks later because i will be performing mathematical operations with the blocks later... For example , XOR operation with block(n)[x,y] with block(n+1) [x,y].
  So this decleration part , this part of the program is very very important.</p>
  
  <p>i stucked this part of the program for 2 weeks i cant continue. Pls help me. İt looks very simple code but.......</p>
  
  <p>My structure is like this , begining part</p>
  
  <pre><code> private void Form1_Load(object sender, EventArgs e)
    {
      Bitmap bmp = new Bitmap("c:\\yavanna.jpg");
      pictureBox1.Image = Image.FromFile("c:\\yavanna.jpg");
  
      int width = bmp.Width;
      int height = bmp.Height;
      Color p;
      int[,] alpha_map_int = new int[width, height];
      int[,] red_map_int = new int[width, height];
      int[,] green_map_int = new int[width, height];
      int[,] blue_map_int = new int[width, height];
      int[,] grayscale_map_int = new int[width, height];
  
      string[,] gray_scale_map = new string[width, height];
  
      string temp_hexValue;
  
      for (int y = 0; y &lt; height; y++)
      {
          for (int x = 0; x &lt; width; x++)
          {
              //get pixel value
              p = bmp.GetPixel(x, y);
  
              //extract pixel component ARGB
              int a = p.A;
              alpha_map_int[x, y] = a;
  
              int r = p.R;
              red_map_int[x, y] = r;
  
              int g = p.G;
              green_map_int[x, y] = g;
  
              int b = p.B;
              blue_map_int[x, y] = b;
  
              //convert to gryscale
              double grayscale = 0.2126 * red_map_int[x,y] + 0.7152 * green_map_int[x, y] + 0.0722 * blue_map_int[x, y];
              grayscale_map_int[x, y] = Convert.ToInt32(grayscale);
              temp_hexValue = Convert.ToString(grayscale_map_int[x, y]);
              gray_scale_map[x, y] = temp_hexValue;
        }
      }
  </code></pre>