Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Image Matrix

Image Matrix

Scheduled Pinned Locked Moved C / C++ / MFC
helptutorial
10 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • H Offline
    H Offline
    Harish Makaram
    wrote on last edited by
    #1

    I have written a code which takes the data out of the Matrix for an image and converts from RGB to Y component. My next step would be to split this matrix into 4x4 blocks and perform some calculations. After this, I want to take the resultant matrices and do some computations with the original Matrix. I am confused with the loops and how to go about creating the loops. I will be very glad if someone can help me with a code snippet. Thanks a lot. Sharp

    C 1 Reply Last reply
    0
    • H Harish Makaram

      I have written a code which takes the data out of the Matrix for an image and converts from RGB to Y component. My next step would be to split this matrix into 4x4 blocks and perform some calculations. After this, I want to take the resultant matrices and do some computations with the original Matrix. I am confused with the loops and how to go about creating the loops. I will be very glad if someone can help me with a code snippet. Thanks a lot. Sharp

      C Offline
      C Offline
      chandu004
      wrote on last edited by
      #2

      could you please elaborate your problem, and present it clearly with an example?

      -------------------------------------------- Suggestion to the members: Please prefix your main thread subject with [SOLVED] if it is solved. thanks. chandu.

      H 1 Reply Last reply
      0
      • C chandu004

        could you please elaborate your problem, and present it clearly with an example?

        -------------------------------------------- Suggestion to the members: Please prefix your main thread subject with [SOLVED] if it is solved. thanks. chandu.

        H Offline
        H Offline
        Harish Makaram
        wrote on last edited by
        #3

        Here is what I want to do. I have an image which I converted from RGB to Y component. Now I want to group the pixels into a 4x4 block. And then take an average for each block. And then subtract this with the original 4x4 block.

        C M 2 Replies Last reply
        0
        • H Harish Makaram

          Here is what I want to do. I have an image which I converted from RGB to Y component. Now I want to group the pixels into a 4x4 block. And then take an average for each block. And then subtract this with the original 4x4 block.

          C Offline
          C Offline
          chandu004
          wrote on last edited by
          #4

          still not clear about your question. what is your original matrix size, that you want to sub matricize to 4X4 blocks? i require an example to help you out.

          -------------------------------------------- Suggestion to the members: Please prefix your main thread subject with [SOLVED] if it is solved. thanks. chandu.

          1 Reply Last reply
          0
          • H Harish Makaram

            Here is what I want to do. I have an image which I converted from RGB to Y component. Now I want to group the pixels into a 4x4 block. And then take an average for each block. And then subtract this with the original 4x4 block.

            M Offline
            M Offline
            Maximilien
            wrote on last edited by
            #5

            you just re-wrote the original question ... not explain.

            Watched code never compiles.

            H 1 Reply Last reply
            0
            • M Maximilien

              you just re-wrote the original question ... not explain.

              Watched code never compiles.

              H Offline
              H Offline
              Harish Makaram
              wrote on last edited by
              #6

              Ok ... I will try again. I have a matrix of size 128x128. I want to divide this matrix into groups of 4x4 that means the resultant is a matrix of 32x32. The next step is to take an average of this 4x4 matrix, and have the same value for all matrix elements. The resultant will be something like this a b c d e f g h M1=i j k l m n o p M1 is the given matrix. The new matrix M2 is given with the element value q is given by q = a+b+c+d+e+f+g+h+i+j+k+l+m+n+o+p/16 q q q q q q q q M2=q q q q q q q q And in the next step I want to subtract M2-M1. Would be great if you can help me with a code snippet. Thanks

              C 1 Reply Last reply
              0
              • H Harish Makaram

                Ok ... I will try again. I have a matrix of size 128x128. I want to divide this matrix into groups of 4x4 that means the resultant is a matrix of 32x32. The next step is to take an average of this 4x4 matrix, and have the same value for all matrix elements. The resultant will be something like this a b c d e f g h M1=i j k l m n o p M1 is the given matrix. The new matrix M2 is given with the element value q is given by q = a+b+c+d+e+f+g+h+i+j+k+l+m+n+o+p/16 q q q q q q q q M2=q q q q q q q q And in the next step I want to subtract M2-M1. Would be great if you can help me with a code snippet. Thanks

                C Offline
                C Offline
                chandu004
                wrote on last edited by
                #7

                1.if your original matrix of size 128/128 is say "M", 2.write a function as follows

                ComputeSubMatrix(int row,int col)
                {
                int avg=0;
                for(int i=row;i'<'row+4;i++)
                {
                for(int j=col;j'<'col+4;j++)
                {
                avg+=M[j][i];
                }
                }
                for(i=row;i'<'row+4;i++)
                {
                for(int j=col;j'<'col+4;j++)
                {
                M[j][i]=avg-m[j][i];
                }
                }
                }
                //Note:please understand '<' as less than symbol .(there is some display problem)

                3.now, you call this function in nested loops, by passing the start row and column of each sub matrix. 4.and this should solve your problem.

                -------------------------------------------- Suggestion to the members: Please prefix your main thread subject with [SOLVED] if it is solved. thanks. chandu.

                H 1 Reply Last reply
                0
                • C chandu004

                  1.if your original matrix of size 128/128 is say "M", 2.write a function as follows

                  ComputeSubMatrix(int row,int col)
                  {
                  int avg=0;
                  for(int i=row;i'<'row+4;i++)
                  {
                  for(int j=col;j'<'col+4;j++)
                  {
                  avg+=M[j][i];
                  }
                  }
                  for(i=row;i'<'row+4;i++)
                  {
                  for(int j=col;j'<'col+4;j++)
                  {
                  M[j][i]=avg-m[j][i];
                  }
                  }
                  }
                  //Note:please understand '<' as less than symbol .(there is some display problem)

                  3.now, you call this function in nested loops, by passing the start row and column of each sub matrix. 4.and this should solve your problem.

                  -------------------------------------------- Suggestion to the members: Please prefix your main thread subject with [SOLVED] if it is solved. thanks. chandu.

                  H Offline
                  H Offline
                  Harish Makaram
                  wrote on last edited by
                  #8

                  In the main program how do I make the nested loop. For examaple I assign Trow=128 and Tcol=128. Here Trow and Tcol are the total row and column. 1. I need to here scan through Trow * Tcol. 2. And take each block and perform the above function. 3. What will be the values for row and col in the above code? 4. does m[j][i] represent the original matrix? Thanks

                  C 2 Replies Last reply
                  0
                  • H Harish Makaram

                    In the main program how do I make the nested loop. For examaple I assign Trow=128 and Tcol=128. Here Trow and Tcol are the total row and column. 1. I need to here scan through Trow * Tcol. 2. And take each block and perform the above function. 3. What will be the values for row and col in the above code? 4. does m[j][i] represent the original matrix? Thanks

                    C Offline
                    C Offline
                    chandu004
                    wrote on last edited by
                    #9

                    sorry my friend, i ve got to leave for the day now. if i give any short answer, you may again get confused. i have put a mail to your id. keep in touch and we will solve it tomorrow.

                    -------------------------------------------- Suggestion to the members: Please prefix your main thread subject with [SOLVED] if it is solved. thanks. chandu.

                    1 Reply Last reply
                    0
                    • H Harish Makaram

                      In the main program how do I make the nested loop. For examaple I assign Trow=128 and Tcol=128. Here Trow and Tcol are the total row and column. 1. I need to here scan through Trow * Tcol. 2. And take each block and perform the above function. 3. What will be the values for row and col in the above code? 4. does m[j][i] represent the original matrix? Thanks

                      C Offline
                      C Offline
                      chandu004
                      wrote on last edited by
                      #10

                      you need to do something like this.

                      for(int row=0;row<128;row+=3)
                      {
                      for(int col=0;col<128;col+=3)
                      {
                      ComputeSubMatrix(row,col);
                      }
                      }

                      let me know if you have any doubts.

                      -------------------------------------------- Suggestion to the members: Please prefix your main thread subject with [SOLVED] if it is solved. thanks. chandu.

                      1 Reply Last reply
                      0
                      Reply
                      • Reply as topic
                      Log in to reply
                      • Oldest to Newest
                      • Newest to Oldest
                      • Most Votes


                      • Login

                      • Don't have an account? Register

                      • Login or register to search.
                      • First post
                        Last post
                      0
                      • Categories
                      • Recent
                      • Tags
                      • Popular
                      • World
                      • Users
                      • Groups