Page 1 of 1

Gamma correction for JPG file

Posted: 2012-07-05T09:26:43-07:00
by splee
I understand that JPG file (sRGB) are corrected for gamma (2.2 if I am not wrong).
How do I "de-gamma" it? i.e. remove the gamma correction, using command line option?

Re: Gamma correction for JPG file

Posted: 2012-07-05T09:45:01-07:00
by fmw42
try converting it to a linear color colorspace, RGB or use -gamma 1/2.2 = 0.454545

convert image.jpg -colorspace RGB newimage.jpg

convert image.jpg -gamma 0.454545 newimage.jpg

Re: Gamma correction for JPG file

Posted: 2012-07-05T20:23:44-07:00
by splee
I tried "convert image.jpg -gamma 0.454545 newimage.jpg" but it gave me the following error:
"Insufficient memory (case 4) newimage.jpg @ error/jpeg.c/JPEGErrorHandler/296"

Then I tried this "convert -limit memory 1 -limit map 1 image.jpg -gamma 0.454545 newimage.jpg" but it gave me the following error:
"unable to extend cache 'image.jpg': No space left on device @ error/cache.c/OpenPixelCache/4139"
"Application transferred too few scanlines image.jpg @ warning/jpeg.c/JPEGErrorHandler/293"
...


What else can I do?

I am using WinXP command line option. The file size is 50MB

Re: Gamma correction for JPG file

Posted: 2012-07-05T21:03:48-07:00
by anthony
Sounds to me like your computer has no disk space available!

Re: Gamma correction for JPG file

Posted: 2012-07-05T22:18:25-07:00
by splee
oh yes "convert -limit memory 1 -limit map 1 image.jpg -gamma 0.454545 newimage.jpg" works after I freed some harddisk space.

However "convert image.jpg -gamma 0.454545 newimage.jpg" still fails. Must I use the "-limit memory 1 -limit map 1" all the time? What is this option doing actually?

Re: Gamma correction for JPG file

Posted: 2012-07-05T23:21:07-07:00
by anthony
Forcing the use of temporary disk for image data cache, rather than memory, though that switch should be reasonably automatic.

Re: Gamma correction for JPG file

Posted: 2012-07-06T02:16:26-07:00
by splee
Hi Anthony,
I want the so called "raw" image pixel, ie. with the gamma effect removed.
Are you sure it is "-gamma 0.454545", not "-gamma 2.2"?
I am confused.
Could you please help?
Thanks...

Re: Gamma correction for JPG file

Posted: 2012-07-07T08:50:07-07:00
by henrywho
Why not "-colorspace RGB". It converts your image to linear RGB for further operations.

sRGB is very similar to gamma 2.2, but not exactly the same. Not sure about AdobeRGB (some DC produces AdobeRGB instead of sRGB).