Half-byte shift in raw gray scale images?

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Post Reply
dave718

Half-byte shift in raw gray scale images?

Post by dave718 »

I'm trying to use ImageMagick to create "Analyze Format" images, and the raw gray scale files are almost equivalent except for some reason they shift everything over half a byte. (i.e. if you are looking at it in a hex editor, instead of seeing "01 AB 23 CD" you see "1A B2 3C D4".)

I'll admit that I'm more than a bit over my head here, but everything else is exactly the same (after flipping the image), so if anyone either a) knows how to easily shift an entire file over by 4 bits (ideally using Perl) or b) knows what setting I can change to fix this, I'd really appreciate it.

The command I'm using is basically "convert <files> -flip -adjoin gray:combined_file.img". Thanks.
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: Half-byte shift in raw gray scale images?

Post by magick »

ImageMagick should reproduce the same pixel values when all you are doing is flipping. Can you post a URL to one of your images so we can run your command and reproduce the problem?
dave718

Re: Half-byte shift in raw gray scale images?

Post by dave718 »

I've looked into it some more and there are bigger differences between the two formats which are posing difficulties. I'll probably have to stick with scripting ImageJ (which has support for "Analyze format" images) rather than using ImageMagick and trying to figure out the slight differences in the two binary formats. Thanks for the quick response though. -Dave
Post Reply