Prev: How to calculate image hash as a bit sequence of 0's and 1's
Next: Variable name for a table in matlab?
From: Randima Hettiarachchi on 16 May 2010 03:48 Hi All, I'm doing a research, which requires the hash value of an image to be calculated as a sequence of 0's and 1's (eg:- 11100101). Any standard algorithm MD5, MD4 or SHA would be fine in calculating image. If some one can help me or give some hints I would be thankful... Please Help! Thanks in advance...
From: Walter Roberson on 16 May 2010 10:57 Randima Hettiarachchi wrote: > I'm doing a research, which requires the hash value of an image to be > calculated as a sequence of 0's and 1's (eg:- 11100101). Any standard > algorithm MD5, MD4 or SHA would be fine in calculating image. If some > one can help me or give some hints I would be thankful... If necessary, cast() the image to an unsigned integer format. Then use dec2bin() to convert to a character string representation of the binary. Subtract the string '0' (the character for the digit 0) from that matrix to get 0 and 1's. Alternately, once you have an unsigned integer representation of the data, you can use getbit to pull out the individual bits. Note that dec2bin() will follow your image along the column and will produce a 2 dimensional matrix, with the rows being the representation of the bits for an individual pixel -- it will *not* produce a matrix with one more dimension than you started with. An implication of this behaviour is that if you have a 3D representation (R, G, and B colour channels for each location) then the different channels for each pixel will be fairly distant from each other in the output of dec2bin. You may wish to permute() to bring the channels together as the columns.
From: Randima Hettiarachchi on 16 May 2010 12:53 Walter Roberson <roberson(a)hushmail.com> wrote in message <jJTHn.7906$HG1.604(a)newsfe21.iad>... > Randima Hettiarachchi wrote: > > > I'm doing a research, which requires the hash value of an image to be > > calculated as a sequence of 0's and 1's (eg:- 11100101). Any standard > > algorithm MD5, MD4 or SHA would be fine in calculating image. If some > > one can help me or give some hints I would be thankful... > > If necessary, cast() the image to an unsigned integer format. Then use > dec2bin() to convert to a character string representation of the binary. > Subtract the string '0' (the character for the digit 0) from that matrix > to get 0 and 1's. > > Alternately, once you have an unsigned integer representation of the > data, you can use getbit to pull out the individual bits. > > Note that dec2bin() will follow your image along the column and will > produce a 2 dimensional matrix, with the rows being the representation > of the bits for an individual pixel -- it will *not* produce a matrix > with one more dimension than you started with. An implication of this > behaviour is that if you have a 3D representation (R, G, and B colour > channels for each location) then the different channels for each pixel > will be fairly distant from each other in the output of dec2bin. You may > wish to permute() to bring the channels together as the columns. Many thanks... It is much appreciated. I will try this out.
From: Randima Hettiarachchi on 18 May 2010 05:22 Walter Roberson <roberson(a)hushmail.com> wrote in message <jJTHn.7906$HG1.604(a)newsfe21.iad>... > Randima Hettiarachchi wrote: > > > I'm doing a research, which requires the hash value of an image to be > > calculated as a sequence of 0's and 1's (eg:- 11100101). Any standard > > algorithm MD5, MD4 or SHA would be fine in calculating image. If some > > one can help me or give some hints I would be thankful... > > If necessary, cast() the image to an unsigned integer format. Then use > dec2bin() to convert to a character string representation of the binary. > Subtract the string '0' (the character for the digit 0) from that matrix > to get 0 and 1's. > > Alternately, once you have an unsigned integer representation of the > data, you can use getbit to pull out the individual bits. > > Note that dec2bin() will follow your image along the column and will > produce a 2 dimensional matrix, with the rows being the representation > of the bits for an individual pixel -- it will *not* produce a matrix > with one more dimension than you started with. An implication of this > behaviour is that if you have a 3D representation (R, G, and B colour > channels for each location) then the different channels for each pixel > will be fairly distant from each other in the output of dec2bin. You may > wish to permute() to bring the channels together as the columns. Dear Sir, Thanks a lot. But my original challenge was to calculate the hash value of a given image as a bit sequence by using a standard encryption algorithm like MD5, MD4 or SHA. It is much appreciated if you can provide some clues on that. Thanks in advance...
From: Steven Lord on 18 May 2010 09:47
"Randima Hettiarachchi" <randishi(a)yahoo.com> wrote in message news:hstm7s$m3t$1(a)fred.mathworks.com... > Walter Roberson <roberson(a)hushmail.com> wrote in message > <jJTHn.7906$HG1.604(a)newsfe21.iad>... >> Randima Hettiarachchi wrote: >> >> > I'm doing a research, which requires the hash value of an image to be >> > calculated as a sequence of 0's and 1's (eg:- 11100101). Any standard >> > algorithm MD5, MD4 or SHA would be fine in calculating image. If some >> > one can help me or give some hints I would be thankful... >> >> If necessary, cast() the image to an unsigned integer format. Then use >> dec2bin() to convert to a character string representation of the binary. >> Subtract the string '0' (the character for the digit 0) from that matrix >> to get 0 and 1's. >> >> Alternately, once you have an unsigned integer representation of the >> data, you can use getbit to pull out the individual bits. >> >> Note that dec2bin() will follow your image along the column and will >> produce a 2 dimensional matrix, with the rows being the representation of >> the bits for an individual pixel -- it will *not* produce a matrix with >> one more dimension than you started with. An implication of this >> behaviour is that if you have a 3D representation (R, G, and B colour >> channels for each location) then the different channels for each pixel >> will be fairly distant from each other in the output of dec2bin. You may >> wish to permute() to bring the channels together as the columns. > > > Dear Sir, > > Thanks a lot. But my original challenge was to calculate the hash value of > a given image as a bit sequence by using a standard encryption algorithm > like MD5, MD4 or SHA. It is much appreciated if you can provide some clues > on that. 1) Locate the description of one or more of those encryption algorithms. The Handbook of Applied Cryptography by Menezes, van Oorschot, and Vanstone contains a description of each of these in pseudocode form. 2) Implement the algorithm you located in step 1. 3) Review the code and fix the bugs you find. [It is almost certain you will have bugs to fix the first several times you execute this step.] 4) Run some known test cases through your code. If your code fails the tests, return to step 3. -- Steve Lord slord(a)mathworks.com comp.soft-sys.matlab (CSSM) FAQ: http://matlabwiki.mathworks.com/MATLAB_FAQ |