how to convert an image into a matrix or more?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • wessam3011
    New Member
    • Mar 2010
    • 6

    how to convert an image into a matrix or more?

    1-i want a code in c# which can analyze an image and converts it into a matrix or more.

    2-when i enter the resulting matrix in the program ,it coverts the matrix into an image again.

    please help me and thanks
  • GaryTexmo
    Recognized Expert Top Contributor
    • Jul 2009
    • 1501

    #2
    What do you mean by "matrix"? My understanding of a matrix is just a 2D array, which is pretty much what an image is by default. If you want the actual data, you can take a look at the Bitmap class on MSDN, specifically the GetPixel and SetPixel methods. If you're in XNA and you're using a Texture2D object, I know you can get the data as an array of Color objects.

    Anything else and you'll have to do some digging I'm afraid. Usually the MSDN documentation is sufficient to show you how to access the data the the image is comprised of.

    Comment

    • wessam3011
      New Member
      • Mar 2010
      • 6

      #3
      thank u for replying on me

      the point is that ,i want to encrypt the image with specific algorithm so i want a code to transform the image into matrices so i can add the encryption key to the image's matrices to encrypt it and i want the inverse of this operation to transform the matrices into an image again.

      thanks.

      Comment

      • wessam3011
        New Member
        • Mar 2010
        • 6

        #4
        i did this operation long time ago but by matlab,now i need it by c# and do not know how to make it

        Comment

        • wessam3011
          New Member
          • Mar 2010
          • 6

          #5
          matrix here = array this is wt i mean

          Comment

          • GaryTexmo
            Recognized Expert Top Contributor
            • Jul 2009
            • 1501

            #6
            Yea ok, so see my first post. If you load the image into a Bitmap object, you should be able to directly access it's image data. From there, you can do a couple of things...

            1) Modify the image data, write it back to the image, and save it. The image will be loadable as a normal bitmap but will look like nonsense.

            2) Write the encrypted image data to a file. When you read that file back in, you decrypt it and set the image data on a new bitmap to restore the image.

            3) Some other method you've thought of :D

            Comment

            • wessam3011
              New Member
              • Mar 2010
              • 6

              #7
              3) Some other method you've thought of :D
              --------------------------------------------------------------
              thx for replying and no i do not have a one

              put pls can u give me the code?

              Comment

              • GaryTexmo
                Recognized Expert Top Contributor
                • Jul 2009
                • 1501

                #8
                The code is for you to write, not me. I've shown you where the tools are, there's lots of information available to you, and I'm quite happy to help you work through any issues you have when coding, but you're the one who has to write it.

                Roll up your sleeves and get cracking. If you have any troubles, post the problem and the code related to it.

                Comment

                • wessam3011
                  New Member
                  • Mar 2010
                  • 6

                  #9
                  thank u for helping me

                  and

                  finally i started to write the code
                  it is easier to make it instead of searching for it
                  :)

                  Comment

                  Working...