From: Rory Carrillo on 17 Mar 2010 14:45 Hi, I am trying to convert an 8-bit bmp image to Hex and then output the Hex data to a text file. Does anybody have a good solution for this? I use imread to to read in the bmp file dec2hex to convert data to Hex fprintf to write Hex data to file this method doesn't seem to work quite right. Thanks
From: Ashish Uthama on 17 Mar 2010 15:14 On Wed, 17 Mar 2010 14:45:19 -0400, Rory Carrillo <carrillr(a)bsci.com> wrote: > Hi, I am trying to convert an 8-bit bmp image to Hex and then output the > Hex data to a text file. Does anybody have a good solution for this? > > I use imread to to read in the bmp file > dec2hex to convert data to Hex > fprintf to write Hex data to file > > this method doesn't seem to work quite right. what comes out wrong?
From: Walter Roberson on 17 Mar 2010 15:26 Rory Carrillo wrote: > I am trying to convert an 8-bit bmp image to Hex and then output the Hex > data to a text file. Does anybody have a good solution for this? > I use imread to to read in the bmp file > dec2hex to convert data to Hex > fprintf to write Hex data to file > this method doesn't seem to work quite right. fprintf() has a %lx format that can output directly to hex. I notice, though, that in 2008b it gets the last 9 bits wrong, truncating at 14 nibbles and then outputting two 0's. Could someone check this in 2009* or 2010a? >> sprintf('%lx',typecast(189.1,'uint64')) ans = 4067a33333333400 The correct answer should end in 334 instead of 400.
From: Rory Carrillo on 17 Mar 2010 16:46 "Ashish Uthama" <first.last(a)mathworks.com> wrote in message <op.u9p7qwowa5ziv5(a)uthamaa.dhcp.mathworks.com>... > On Wed, 17 Mar 2010 14:45:19 -0400, Rory Carrillo <carrillr(a)bsci.com> > wrote: > > > Hi, I am trying to convert an 8-bit bmp image to Hex and then output the > > Hex data to a text file. Does anybody have a good solution for this? > > > > I use imread to to read in the bmp file > > dec2hex to convert data to Hex > > fprintf to write Hex data to file > > > > this method doesn't seem to work quite right. > > what comes out wrong? Well, I look at the hex data, and it seems to be correct...the data is either 00 or FF. When I write to the file, the FF is 46 instead and the 00 is 30. The bmp image is just a black and white image of a big X (image size is 128x240pixels). In the file you can see the 'X' repeating multiple times, rather than just being one big 'X'. When I use the 'fwrite' command to write hex data to a file, the Hex data is loaded into the file as expected (all 00 or FF) but by looking at the data, you can't really see the image.
From: David Young on 17 Mar 2010 18:13 Walter Roberson <roberson(a)hushmail.com> wrote in message <hnradr$8tm$1(a)canopus.cc.umanitoba.ca>... > > Could someone check this in 2009* or 2010a? > > >> sprintf('%lx',typecast(189.1,'uint64')) > ans = > 4067a33333333400 > > The correct answer should end in 334 instead of 400. I get the same behaviour in 2010a.
|
Pages: 1 Prev: Initializaition fail in mmreader. Next: Inverting system of matrices |