Hacking firmware to improve image quality
Links: home · search · speed test · login · more ·

 
Links: Reply New Topic
Forums » Technical » Digital Imaging » Hacking firmware to improve image quality
page: 1 · 2
DigitalJeff @ 13th Nov 03:56PM:
Hacking firmware to improve image quality

Hey all,

You've probably seen me complaining about my Kodak DX6340's awful compression. My 3.2 MP digital pics generally come out ~500kb (depending on picture complexity, of course.) I have a vendetta against Kodak for choosing this high compression ratio: It was a marketing ploy to get more images on storage media by sacrificing quality.

Well, I downloaded Kodak's firmware update. Then I opened the firmware file in a hex editor, and... found the standard JPEG compression quantization tables! (Thank God for standards!)

Not excited yet? Let me explain:

Skipping all the gory, technical JPEG details, these tables control the amount of compression my camera produces. If I manually reduce the values in these tables, the images produced will be less compressed and of higher quality.

Then I'd have to defeat any checksums (which make sure the firmware file is in tact and un-edited), flash my camera with the upgrade, and voila! My camera produces higher quality output!

On the down side, if I screw up the firmware, my camera may never work again. But it's a chance I'm willing to take for possible freedom from JPEG artifacts.

I will document my experiment here for the world to see with before and (hopefully) after test images. If it works, maybe others can benefit from hacked firmware! If I never post again, it's because my wife killed me for destroying our digital camera.
--
::: Starving college student, will work for Digital Rebel. God bless! :) :::

reply
Rygel @ 13th Nov 04:04PM:
Re: Hacking firmware to improve image quality

Sounds cool. Keep us posted.
reply
natedj @ 13th Nov 05:14PM:
Re: Hacking firmware to improve image quality

There you go ...... let us know how it turned out!
reply
X X X X X X @ 13th Nov 05:23PM:
Re: Hacking firmware to improve image quality

Good Luck and if it doesnt work which camera will you purchase to replace that one :)
reply
aggiejy @ 13th Nov 06:43PM:
Re: Hacking firmware to improve image quality

Sounds like an excuse to upgrade. ;-) Just kidding! Good luck!
reply
climbers @ 13th Nov 06:56PM:
Hacking cameras...

...has been done by a few fearless souls. For instance, here's a hack to enable RAW mode in a Nikon Coolpix 2500:

»e2500.narod.ru/raw_format_e.htm#cpixraw

--
Aggressive drivers kill.

My photos

reply
SandShark @ 14th Nov 08:21AM:
Re: Hacking firmware to improve image quality

I wish you all the best in this endeavor and look forward to learning the results.
reply
DigitalJeff @ 14th Nov 09:44AM:
Re: Hacking cameras...

Cool link, climbers. Maybe I'll have to get in touch with them.

Man, I thought I had Kodak pinned when I found the quantization tables in my firmware. Strangely, when I flashed the camera, it said "upgrade successful", then... nothing. No change in quality. Tried tons of dirrerent edits.

Tried changing the revision number or the menu text (just for fun, to put my name in the camera menu) and then I got an upgrade error (the camera knew the file wasn't authentic.) Luckily, all is still well with the little DX6340.

Man, I'm frustrated. :( :( :( However, I won't give up. I'll keep researching, and let you know if anything changes.

Maybe the quant tables are on read-only memory in the camera. Or maybe it doesn't upgrade that portion of the program. But why would they be in there in the first place? Any thoughts?
reply
X X X X X X @ 14th Nov 10:11AM:
Re: Hacking firmware to improve image quality

While your not giving up whch camera are you looking to buy to replace that one when it gives up from being tortured LOL! :)
--
"The true measure of a man is how he treats someone who can do him absolutely no good." - Samuel Johnson (1709-1784)

reply
DigitalJeff @ 14th Nov 11:41AM:
Kodak cameras REALLY DO use extreme compression

Well, here's the evidence (attached) that Kodak doesn't want you to see. My sister's Fuji FinePix 3800 uses much less compression (note the much lower values in both tables) than my DX6340, and therefore, it produces much nicer pictures.

Let me explain...

I compared my Kodak to my sister's (comparably priced and featured Fuji FinePix 3800). Her pictures looked so much sharper than mine.

So, I extracted the quantization tables out of one of her images and out of mine. (One table for luma, or lightness, and one for chroma, or color.) These images were both "best quality", 3.2 MP pics, direct from each camera.

While quantization tables aren't an exact measure of image compression or quality, they are a decent indiactor. Higher values indicate higher compression.

I'm considering starting a campaign with data like this to try to force Kodak to provide better in camera control over quantization (compression) settings. :)


For a technical description of how JPEG works and what quantization tables are, see this great webpage: »www.cs.auckland.ac.nz/compsci708···peg.html


X X X X X X, I can't afford to buy a different camera at this point. Which is why I'm delving into this.
Click for full size
Fuji 3800 vs. DX6340... ouch!
reply
Rygel @ 14th Nov 01:23PM:
Re: Hacking firmware to improve image quality

Would seeing firmware from other cameras help you at all?
reply
DigitalJeff @ 14th Nov 01:34PM:
Re: Hacking firmware to improve image quality

said by Rygel:
Would seeing firmware from other cameras help you at all?


Maybe I'll look into that. There are two versions (1.10 and 1.08) at Kodak's site for my camera. Being ~3 MB each, it's difficult to do much comparing. But running a comparison program, they do seem a bit different.

It's quite puzzling... I know that it uses a TI-DSC25 digital signal processor, which runs off C code. I assume the firmware file is some sort of compiled object file, because it runs an actual upgrade sequence when uploaded on my camera.

One problem I face is that it has a checksum or CRC protection... which didn't go off when I edited the tables... strange... Makes me think that the software might only upload portions on the firmware that have been updated.

Also, this is the camera's entire "operating system", so to speak, so there's a TON of unrelated junk, from menus and MPEG movie encoding to multi-lingual error messages. All of it neatly disguised and buried in this file.

I have a feeling I'll be digging for some time, and may never come up with anything. :[
--
::: Starving college student, will work for Digital Rebel. God bless! :) :::

reply
climbers @ 15th Nov 12:31AM:
Re: Hacking firmware to improve image quality

The work you've already done might be interesting enough to them to get you a summer internship with them, if your own interests lie that way.

--
Aggressive drivers kill.

My photos


reply
oldhand @ 15th Nov 01:06AM:
Re: Hacking firmware to improve image quality

I used to store a collection of freeware decompilers on the University server for my C students. If they're still there, or if I still have them, I'll post FTP links to them.
reply
PeteC2 @ 15th Nov 12:18PM:
Re: Hacking firmware to improve image quality

At any rate....a most interesting thread, thanks!
--
Deeds, not words

reply
DigitalJeff @ 15th Nov 01:09PM:
Re: Hacking firmware to improve image quality

Thanks, PeteC2. It really seems feasible for almost any camera, and a worthwhile topic (even if only for the brave.)

climbers, that's not a bad idea... Actually, I've worked the past two summers for Texas Instruments, and I'm quite enjoying it. However, Kodak probably has positions for Electrical Engineers in case there're no jobs here. I was sorta hoping Pixar might as well. :)

Anyway, it looks like the quant tables are tweaked slightly for each image. They're not exactly the same in every JPEG. So, by examining a score of these tables from my pics at different quality settings, perhaps I'll be able to find the quality scalars and change them in the firmware.

I also emailed a Kodak software engineer about this. Not surprisingly, he hasn't gotten back to me yet. :)
--
::: Starving college student, will work for Digital Rebel. God bless! :) :::

reply
drjim @ 15th Nov 10:37PM:
Re: Hacking firmware to improve image quality

Nice work!
reply
anon @ 18th Nov 10:33AM:
Re: Hacking firmware to improve image quality

I have a Kodak DX3900, and I'd absolutely LOVE to get in there and hack a few features:

1) Flash OFF by default (Please!)

2) Digital zoom until pixels (for fine macro focus)

3) Append file-name, shutter-speed, F-stop etc to .TXT
file as well as encoded inside file (where it gets
lost if I post process with any other than Kodak SW).

4) Look into and fix why I get tiny spots if I tweak the
brightness & contrast up too much on my computer
(probably related to compression issues mentioned
earlier in this thread).

-- Just a thought.
/PJF
reply
DigitalJeff @ 19th Nov 08:17AM:
Re: Hacking firmware to improve image quality

Well, I've had some success. After 30 some hours of research and trial-and-error hex editing, my pictures are over 3 times as large (1.8 MB on average.)

Unfortunately, the overall quality hasn't increased as much as I'd have liked, but as you can see in the comparison above, the actual JPEG artifacts are much diminished. I guess I can't expect DSLR performance from a tiny point and shoot. :)

The nice thing is I can also go back and forth between firmware versions, so nothing's permenant.

To correct my upper posts (always learning) there can be more than one set of quantization tables in an image. I was working on the first set, when I realized most of the data was encoded by the second.

The firmware protection didn't allow me to enter my own values into the table. Rather, I had to randomly try various functions on the data already there (values / 3, values - 2, some of the values mod 4, etc.) and see if they were accepted by the camera. Somewhat of a shotgun approach. Only 3 out of 30 or more tries were accepted. This last one shows the greatest improvement.

To answer your questions, UoGPJ-F, I'm just in the tinkering stages. The only reason I can improve quality is because I know what "a quantization table" looks like. Then I can find it amongst the 3.1 million bytes in the firmware file. I don't forsee being able to change any camera operation (program code) at all. I wish I could!

Anyway, I would have brought an entire sample photo, but they don't fit on a disk anymore. Maybe Kodak had a point in the first place... Nah. ;)

EDIT: The image looks really dark on this monitor. I hope it's not so for all. Plus, the thumbnail is super ugly. Oh, life.
--
::: Starving college student, will work for Digital Rebel. God bless! :) :::


Click for full size
Before and After
reply
DigitalJeff @ 19th Nov 08:46AM:
Re: Hacking firmware to improve image quality

One more thing... I had to include a snippet of Kodak's response to my customer support question. It cracks me up.

Me: (assuming 32 bits per pixel)
"The pictures from my DX6340 look awful ... An uncompressed 3.2 MP image would be about 12 megabytes. My DX6340 images are on average, 500 kb, indicating 25:1 compression."

Kodak:
"In regards to the compression ratio for this camera, it is actually 1:5. I'm afraid your math is a little off. The resolution for the Best quality is 2032 x 1524. This should equal 3096768 million pixels, or roughly 3.1MP. This number is calculated by multiplying the two numbers together."

Gee, thanks for helping me multiple 2032 x 1524. Did I mention filesize was the important factor? And I'm not sure where they get that 1:5 ratio, but I intend on asking.
reply
NoelC @ 19th Nov 09:33AM:
Bravo, Jeff!

Jeff, I must say I'm impressed at what you've done. I see some of myself in you, back when I had time. :)

-Noel
reply
MLOK5 @ 19th Nov 10:14AM:
Re: Hacking firmware to improve image quality

Oh Wow!! I only use Hex Editors for work because I *have* to. I'm super impressed, Jeff! You know...I could use another minion around here.... ;) :D

--
My Photo Gallery

reply
Rygel @ 19th Nov 10:28AM:
Re: Hacking firmware to improve image quality

Nice work.

Are you seeing any noticeable difference it the full size versions of the shots?

Also, have you come across anyone else doing this? I can't imagine no one has thought of it before!
--
My Blog

reply
X X X X X X @ 19th Nov 12:16PM:
Re: Hacking firmware to improve image quality

I found an old Kodak DC215 in my junk closet think I can hack it?
reply
KAD Imaging @ 19th Nov 12:27PM:
Re: Hacking firmware to improve image quality

Uhh...I am not trying to be a thread-crapper here and it is really cool that you are "hacking" your digicam which I can appreciate because I've done a little of that myself. But..(you knew it was coming! ;-))

The primary determining factor in picture quality is the glass (lense) followed by the calibur of the CCD. If your Kodak (admittedly fine for novice PNS but lacking in pro performance) has a second-rate CCD then if the Compression were 1:1 and took up 8MB per shot, they would "still" look bad. Understand that I'm a noob by all intents and purposes but at one time I was persuing a career as a Graphic Artist and understand that if your sorce is poor, the result will be poor. (To that fact we paid $1000's for RAW images back in '92 so we had the highest quality for editing.

If I'm wrong, someone shut me up! :D

;-)
--
-The Cobra
"Heh, your broadband style is good grasshopper....but not good enough. Watch my Bellsouth style..."
1180K download 218K upload (BS FastAccess 1.5M/256K @ 19,000ft!)

reply
DigitalJeff @ 19th Nov 12:55PM:
Re: Hacking firmware to improve image quality

Thanks for the encouragement, guys. I'll post a full shot comparison when I have time.

Rygel: Others have done this, as climbers pointed out... Just search "digital camera firmware hack" or something in Google.

X X X X X X: Good luck. ;) This kind of work is ultra frustrating! Most folks'd be better off just buying a better camera!

KAD Imaging, you're absolutely right. However, the JPEG compression is where most of the image information is "thrown away". Whether that information is accurate or not depends on the glass, CCD, etc, which is why the overall quality increase was not huge.

My goal was to improve the process where I could: in the digital realm. I think that Kodak should leave the final decision of throwing away information to the user via more compression options.

Anyway, I feel I've met my goal.
--
::: Starving college student, will work for Digital Rebel. God bless! :) :::

reply

Thank you for using lo-fi dslreports.com - report bugs
© 99-2010 silver matrix LLC