supplierdeeply

rawconvert.c update

  • 8 Replies
  • 3204 Views
rawconvert.c update
« on: 21 / May / 2010, 17:09:22 »
Advertisements
Hi.
I have updated source code for rawconvert.c
Added support for widely used and supported by many viewers PGM (portable graymap) file format.
8 and 16 bits per pixel supported, but 16 bit is supported by limited subset of viewers so it's better to use 8 bit PGM.
PGM output is enabled with -pgm option, and you must specify .PGM extension to output file.
For example for my camera the conversion to PGM looks like this:
Code: (dos) [Select]
rawconvert.exe -10to8 -pgm -w=2672 -h=1968 CRW_0005.RAW IMG_0005.PGMWhat need to be updated:
1. Author of the original code in the header comment inside source file
2. Wiki options description for rawconvert.c
And ofcourse it would be great to add this update to SVN :)
Bye.

*

Offline fe50

  • ******
  • 3038
  • IXUS50 & 860, SX10 Star WARs-Star RAWs
    • fe50
Re: rawconvert.c update
« Reply #1 on: 22 / May / 2010, 07:07:46 »
I have updated source code for rawconvert.c
...
What need to be updated:
1. Author of the original code in the header comment inside source file
2. Wiki options description for rawconvert.c

Added to the trunk, changeset #894.

Quote
REVISIONS:
1. Initial release. Author: reyalP (28-Oct-2009)
    CHDK trunk SVN changeset #823 --> http://tools.assembla.com/chdk/changeset/823
    Forum link: http://chdk.setepontos.com/index.php/topic,2509.msg42402.html#msg42402
    
2. Portable Gray Map support added by cppasm (21-May-2010)
    Forum link: http://chdk.setepontos.com/index.php/topic,5207.msg50599.html#msg50599
    Changes:
      Added support PGM (portable graymap) file format
      8 and 16 bits per pixel supported, but 16 bit is supported by limited subset of viewers so it's better to use 8 bit PGM
     PGM output is enabled with -pgm option, and you must specify .PGM extension to output file.
     example:  rawconvert.exe -10to8 -pgm -w=2672 -h=1968 CRW_0005.RAW IMG_0005.PGM

...i'll update the wikia article soon...done.
« Last Edit: 23 / May / 2010, 05:07:32 by fe50 »

Re: rawconvert.c update
« Reply #2 on: 22 / May / 2010, 08:27:00 »
Thanks.

Re: rawconvert.c update
« Reply #3 on: 02 / July / 2010, 01:03:20 »
Does it save 16-bit PGMs in big-endian?

I actually modified rawconvert.c to save as PGM as well. It only took a few lines of code. However, it saved 16-bit PGMs in little-endian. Then I discovered 16-bit PGMs should be saved in big-endian. Making that change to rawconvert.c did not seem trivial to me.

Comparing the output of my modified rawconvert (16-bit little-endian) to dcraw (16-bit big-endian) led me to believe that dcraw was overflowing. I'd like to save someone else the trouble.

Update:
OK I looked at the code and compared it's output to dcraw. It does save 16-bit as big-endian.
reyalp is the original author. I suggested adding the ability to output PGM to him in April, but he didn't want to.
However, I believe this is a useful addition. Might I suggest that you separate the height and width with a space instead of a newline in the header. I know the specification just says whitespace, but IIRC all the examples show height and width on the same line, plus dcraw uses a space.
« Last Edit: 02 / July / 2010, 01:46:40 by yardleydobon »


*

Offline reyalp

  • ******
  • 10055
Re: rawconvert.c update
« Reply #4 on: 02 / July / 2010, 20:47:29 »
Quote
reyalp is the original author. I suggested adding the ability to output PGM to him in April, but he didn't want to.
However, I believe this is a useful addition.
fe50 already added this to the trunk in May :)
Don't forget what the H stands for.

Re: rawconvert.c update
« Reply #5 on: 02 / July / 2010, 21:32:35 »
Yes, I know. I found this thread by browsing the change log. Glad to see it has a PGM option now. Thanks reyalp and ccpasm.

*

Offline vit40

  • ****
  • 276
Re: rawconvert.c update
« Reply #6 on: 26 / September / 2010, 11:16:09 »
Hm ...

I'v been playing with rawconvert.c  with raw files for my A620

I think there is an error in the code if -noshift parameter is NOT used. If I convert from 10 bit to 16 bit and back, resulting file is different than original one. On the other side, conversion with -noshift seems to be ok

I'm not very familiar in c, as I'm pascal/delphi programer, but maybe someone take a look ...

*

Offline reyalp

  • ******
  • 10055
Re: rawconvert.c update
« Reply #7 on: 26 / September / 2010, 22:48:31 »
Hm ...

I'v been playing with rawconvert.c  with raw files for my A620

I think there is an error in the code if -noshift parameter is NOT used. If I convert from 10 bit to 16 bit and back, resulting file is different than original one. On the other side, conversion with -noshift seems to be ok

I'm not very familiar in c, as I'm pascal/delphi programer, but maybe someone take a look ...
Hmmm. I can't reproduce
Code: [Select]
>rawconvert -10to16 -w=2888 -h=2136 TEST.CRW test10to16.raw

input:  TEST.CRW 2888x2136 10 bpp 7710960 bytes
output: test10to16.raw 16 bpp 12337536 bytes
 multiply pixel values 64
done
>rawconvert -16to10 -w=2888 -h=2136 test10to16.raw test16to
10.raw
input:  test10to16.raw 2888x2136 16 bpp 12337536 bytes
output: test16to10.raw 10 bpp 7710960 bytes
 discard lower 6 bits
done
>md5sum TEST.CRW
d63dd0d31fdba8e440f3c963b9a48edd *TEST.CRW
>md5sum test16to10.raw
d63dd0d31fdba8e440f3c963b9a48edd *test16to10.raw
Note that rawconvert will not read PGM format. It should give a warning about file size mismatch if you try to do this

edit:
if you can describe how they differ, that might give some clues.
« Last Edit: 26 / September / 2010, 22:50:55 by reyalp »
Don't forget what the H stands for.


*

Offline vit40

  • ****
  • 276
Re: rawconvert.c update
« Reply #8 on: 27 / September / 2010, 02:17:43 »
Hi, reyalp

Thanks for the quick answer. Tried to recreate the problem, but it turned out it was an error in my code, that generated 16 bit file from 10 bit values, namely in the line

BlackLevel + Round(V * (WhiteLevel - BlackLevel)) shl 6

forgot to include parenthesis - it should be

(BlackLevel + Round(V * (WhiteLevel - BlackLevel))) shl 6


I'm currently working on the project of CHDK DNG profile generator, that's why I needed this program, and if everything goes well, we'll finally be able to get the same colors from raw files as they are on jpegs, which is currently not the case


 

Related Topics