Free Utility That Displays RAW Pixels?

Discussion in 'Digital Photography' started by jim evans, Aug 15, 2007.

  1. jim evans

    jim evans Guest

    Anybody know of a free Windows utility that shows the raw pixels of a
    RAW image? The individual pixels are all grayscale before the Bayer
    conversion. I'm giving a talk and would like to be able to show these
    gray pixels and also show them in the red, green and blue colors each
    pixel represents. The utility would take a small area of a RAW image
    and show the pattern of gray dots and also convert them to the color
    they represent before Bayer conversion.
     
    jim evans, Aug 15, 2007
    #1
    1. Advertisements

  2. jim evans

    gowanoh Guest

    If such a program is not available it is perfectly legitimate to deconstruct
    an image and use it to illustrate what you want to convey to your audience.
    This is a standard method for science textbook illustrations.
     
    gowanoh, Aug 15, 2007
    #2
    1. Advertisements

  3. jim evans

    acl Guest

    IRIS:
    http://www.astrosurf.com/buil/us/iris/iris.htm

    Also dcraw (which IRIS uses) can take a raw file and output the
    uninterpolated data (either gamma corrected or not). do
    dcraw -D -T filename
    for example (or whatever the appropriate form is for the switches
    under DOS).

    IRIS probably does the job you want, though.
     
    acl, Aug 15, 2007
    #3
  4. jim evans

    jim evans Guest

    Thanks. It looks like IRIS is doing what I want. I got the
    grayscale, but haven't figured out how to get the respective RGB
    pixels. I figure that will come. Somehow it shows combinations of RG
    GB RB instead of the basic Rs, Gs and Bs
     
    jim evans, Aug 15, 2007
    #4
  5. jim evans

    John Sheehy Guest

    I don't think IRIS has any way to color the pixels according to their
    filters. You have to load the image into photoshop and color them.

    If you use IRIS to interpolate color, the options have to be set to the
    correct camera, or one that has the same CFA pattern. Most cameras will
    have a cyanish-green cast when the correct CFA pattern is used for color
    interpolation (which is the natural response of most digitals).


    --
     
    John Sheehy, Aug 16, 2007
    #5
  6. From the man page for dcraw,

    -d Show the raw data as a grayscale image with no
    interpolation. Good for photographing black-
    and-white documents.

    -D Same as -d, but totally raw (no color scaling).

    The output is a greyscale image (pgm format), not at
    all a pattern that looks like a colored pre-Bayer
    conversion.

    I'm not sure what you meant for -T, as dcraw has no -T
    option.
     
    Floyd L. Davidson, Aug 16, 2007
    #6
  7. jim evans

    acl Guest

    Yes, but it could still be useful for him. Apologies for the
    inaccuracy.
    Well the one I have on my laptop does, and it outputs tiff. I don't
    remember the version, probably less than a year old. I am sure that
    didn't add the tiff output myself.
     
    acl, Aug 16, 2007
    #7
  8. jim evans

    Ray Paseur Guest

    Jim: Look for the feature called a "channel splitter" in the program. A
    google search is not very helpful, but if you have an image processing
    program the channel splitter usually gives you a way to isolate each of the
    three RGB channels. ~Ray
     
    Ray Paseur, Aug 16, 2007
    #8
  9. Well, it doesn't appear that you were inaccurate. It is
    a greyscale image (while the OP asked for color), but it
    is indeed a direct representation of the sensor pixel
    values on a greyscale.

    I haven't thought of an easy way to convert it to color,
    though. But if nothing else, converting it to a text
    based PPM format should make it possible to do with just
    text editing tools.

    One thing that I did do which was interesting, at least
    to me, was cut out a 75x50 pixel chunk of an NEF file,
    and resample it to 750x500 for easy viewing.

    dcraw -c -D -T d2x_7247.nef | \
    convert - -crop 75x50+1513+1725 +dither \
    -sample 750x500 out.ppm
    Yep, you're right on that. I tend to upload Coffin's
    source code on a fairly regular basis (I had Version
    8.76 and just now downloaded 8.77), but since I rarely
    ever actually use /dcraw/ itself for anything other than
    looking at the source code (I use /UFRAW/ to convert NEF
    files) I didn't have a recent binary installed. When I
    checked your suggestion against a binary (that was a
    year old) I was thinking I'd installed a newer binary,
    but that wasn't so.
     
    Floyd L. Davidson, Aug 16, 2007
    #9
  10. jim evans

    acl Guest

    Yes I also haven't thought of a simple way to go from the grayscale
    file to what he wants, at least under windows. PPM looks simple
    enough to do it without wasting time to code complicated input/output
    stuff. But "simple" and "complicated" are relative terms!
    Did you try Raw Therapee?
    http://www.rawtherapee.com/download.html
    It's not open source, though. It's free otherwise (beer). It's just
    excellent, one of the best (and has very convenient sharpening
    controls, too).

    As for reading dcraw code, am I the only one who finds it very hard to
    understand Coffin's code? I'm no expert coder, of course.
     
    acl, Aug 16, 2007
    #10
  11. I diddled with a bash shell script long enough to know
    1) I can do it and 2) I don't want to... :)
    I'd never heard of it before; so I downloaded and played
    with it just now, for a few minutes. It has a *very*
    nice histogram. It lacks at least two things (or at
    least in 5-10 minutes I didn't find them).

    First was some type of black or blink where over exposed
    and white or blink where under exposed. UFRAW has that
    and I find it extremely useful, along with a percentage
    indication of how much of the image is all white or all
    black.

    The other missing feature is not being able, apparently,
    to give it a command line working directory argument, or
    even having it default to the current directory. It
    appeared me that each time is is invoked the GUI
    selector has to be used to access the desired directory.
    That's a royal pain. (I didn't read the docs, so I
    might have missed the obvious...)

    I have no use for features like sharpening in a raw
    converter program. At that stage I can't tell how much
    sharpening is needed, plus since sharpening is the last
    edit done before making a production copy (for printing,
    or web site use, or whatever) it just is not useful in
    any tool than a full blown image editor. (I have at
    least two other program, xv and convert from
    ImageMagick, that also provide a sharpening feature that
    I virtually never use.) Whatever, there are several
    similar features, such as noise reduction, distortion,
    c/a correction, that I would never use in a raw
    converter. (UFRAW also has a couple of those..., but
    they don't clutter the interface as much.)

    I didn't mess with it a whole lot, but it appears
    possible to re-arrange the display layout too, which I
    find to be of significant value. I'm trying to talk the
    UFRAW people into adding that feature to their program.
    They haven't quite caught on the the value yet, as it
    appears they are all used to using a single monitor (and
    I'll bet they have one virtual desktop and run
    everything "fullscreen"). The program works fine that
    way. But I have two monitors and never run anything
    full screen. They've got the control panel on the left
    side. I need it on the right side (the monitor with a
    digital interface is on the left, and that's where I
    want the image display). As it is, when I increase the
    size of the image, the first part that overflows onto
    the right monitor is *not* the control panel, but the
    right side of the image. So thats the size I'm limited
    to. If I could put the controls on the right side, I'd
    be able to have a slightly larger image display window.
    (They'll see the light at some point though..., and I'm
    about to replace my 19" monitors with 22"ers, so it won't
    be as restricting.)
    Well... he writes in C++, and I don't. That does make
    it rough.

    Otherwise, his style is pretty much similar to what I
    use. He obviously came from a UNIX world, with K&R at
    heart, but changed to using 2 spaces for indents instead
    of a full tab. He uses underscores_instead_of
    CapitalsForVariables. And two of the nicest things are
    the brace style and putting a space between operators
    and parens and none between a function name and parens


    if (condition) {
    expression();
    }

    I always use braces, even for one liners like that, and he
    doesn't, but I'm not bothered much by that.

    He could also sprinkle blank lines into things now and
    then, and make it much more readable! ;-)

    I'm very finicky about my own coding style, but as long
    as someone is consistent with a logical style I don't
    mind if it's not like mine.
     
    Floyd L. Davidson, Aug 17, 2007
    #11
  12. jim evans

    Paul Allen Guest

    On Thu, 16 Aug 2007 08:25:07 -0800
    How 'bout this:

    Shoot raw images of red, green, and blue targets and convert them
    using "dcraw -D". Blow them up in an image editor to see which
    pixels "light up" for each color. Then hack a little loop to read
    PGM and output PPM with the pattern imposed. Use that to
    "colorize" more interesting raw files that have been converted
    with "dcraw -D". Sounds like a fun way to spend a rainy afternoon
    in Seattle. :)

    Paul Allen
     
    Paul Allen, Aug 18, 2007
    #12
  13. jim evans

    Paul Allen Guest

    He's not asking for a way to split the red, green, and blue channels of
    a color image. He's asking for a way to superimpose the colors of the
    Bayer filter over the one-value-per-pixel raw data.

    Paul Allen
     
    Paul Allen, Aug 18, 2007
    #13
  14. Well, thank goodness, I don't live in Seattle! (I was
    born in Bremerton. And today, not at all by accident, I
    live in a place that gets less than 5 inches of rain per
    year... ;-)

    Actually, I did just about exactly that, down to the
    point of working out a shell script that did everything
    except implement the pattern. When it occurred to me
    how tedious it was going to be to come up with the
    algorithm to switch colors in at the right times
    (basically by counting pixels)...

    Well, I decided to quit that an go do something truely
    useless. Take pictures, take a nap, eat ice cream, go
    for a swim in the ocean... anything that didn't involve
    thinking about the pattern that pixel counter needed to
    match.
     
    Floyd L. Davidson, Aug 18, 2007
    #14
  15. [A complimentary Cc of this posting was sent to
    Floyd L. Davidson
    Right.

    The complicated solution is to use -fx of ImageMagick.

    The simplest solution is to (optionally) convert grayscale to RGB,
    output as .txt format via ImageMagick, run a simple
    Perl/TCL/Python/etc script to edit the resulting .txt file, then
    convert back to "more conventional" image representations via
    ImageMagick again.

    Hope this helps,
    Ilya

    P.S. Conversion to RGB is useful so that the format of .txt file does
    not need to be changed, only the appropriate 2 numbers of 3 in a raw
    need to be zeroed...
     
    Ilya Zakharevich, Aug 18, 2007
    #15
  16. "-fx" ???
    Actually the greyscale already is RGB (in PGM format). It just
    has all three color values set identically for each pixel.
    ImageMagick won't write ASCII based PPM files, so yes
    the TXT format is the only one that can be used (with
    ImageMagick). It happens to make things easy too,
    because each pixel is one line, and in addition to pixel
    information it provides the row and column, within the
    image, too. I was originally working with ASCII based
    PPM files, and that was just too tedious to do for fun.
    Sheesh. Just use bash.
    It's fairly easy to do...
    There is no need to convert it, it already is RGB.

    Whatever, you've goaded me into actually coding it up.
    This script is slow, so wait for it... also I don't guarantee
    it, as I just sort of did this for fun and have only run it
    a few times. I did try to make it a little more bomb proof
    than the average shell hack, but there have to be bugs in it.

    #!/bin/bash
    #
    #
    #
    function help () {
    echo ""
    echo " This script generates a 750x500 PPM formatted represention"
    echo " of the raw data generated by a digital camera's sensor using"
    echo " data from a 75x50 pixel crop of a specified RAW format file."
    echo ""
    echo " The command line must specify the file and the x and y"
    echo " offsets into the RAW image where the 75x50 crop is to"
    echo " be taken. For example:"
    echo ""
    echo " ${0} d2x_7247.nef 1420 1611"
    echo ""
    echo ""
    exit 1
    }

    function clean () {
    rm -f ${$}tmpa.pgm ${$}tmpb.txt ${$}tmpc.txt
    }

    trap clean 0

    if [ ${#} -ne 3 ] ; then help ; fi

    fname=${1}
    if [ ! -r ${fname} ] ; then echo "Error: No file ${fname}" ; help ; fi

    x=${2}
    case ${x} in
    [0-9]*) ;;
    *) echo "Error: Invalid x corrdinate"; help ;;
    esac

    y=${3}
    case ${y} in
    [0-9]*) ;;
    *) echo "Error: Invalid y corrdinate"; help ;;
    esac

    typeset -i count=0
    typeset -i color=0
    typeset -i cnt=0

    echo "Converting raw file to a greyscale PGM file."
    if ! dcraw -c -D ${fname} > ${$}tmpa.pgm ; then
    echo "ERROR: dcraw failed."
    help
    fi

    echo "Cropping a TXT formatted image at 75x50+${x}+${y}"
    if ! convert ${$}tmpa.pgm -crop 75x50+${x}+${y} ${$}tmpb.txt ; then
    echo "ERROR: convert failed."
    help
    fi

    set $(wc -l ${$}tmpb.txt)
    total=${1}

    #
    # convert the TXT formatted greyscale image to RGB
    # in the same patter as a Bayer filter
    #
    echo "Converting greyscale TXT file to a Bayer color representation..."

    printf "\r 01 %% complete..."

    while read location pixels colors junk1 offset junk2 ; do
    count=$(expr ${count} \+ 1)
    if [ ${count} -eq 1 ] ; then
    echo "${location} ${pixels} ${colors} ${junk1} ${offset} ${junk2}"
    for i in 1 2 3 4 5 6 ; do
    if [ "${offset:${i}:1}" == "," ] ; then
    width=${offset:0:${i}}
    i=$(expr $i \+ 1)
    offset=${offset:${i}}
    fi
    done
    for i in 1 2 3 4 5 6 ; do
    if [ "${offset:${i}:1}" == "," ] ; then
    height=${offset:0:${i}}
    fi
    done
    continue
    fi

    red=${pixels:1:5}
    grn=${pixels:7:5}
    blu=${pixels:13:5}

    line=${location:0:1}

    if [ ${line} -eq 0 ] ; then
    column=0
    fi

    color=$(expr ${count} \% 2)

    if [ $(expr ${column} \% 2) -eq 0 ] ; then
    # pattern is RGRG
    if [ ${color} -eq 0 ] ; then
    # Red
    grn="00000"
    blu="00000"
    else
    # Green
    red="00000"
    blu="00000"
    fi
    else
    # pattern is GBGB
    if [ ${color} -eq 0 ] ; then
    # Green
    red="00000"
    blu="00000"
    else
    # Blue
    red="00000"
    grn="00000"
    fi
    fi

    echo "${location} (${red},${grn},${blu}) ${colors}"

    if [ $(expr ${count} \% 100) -eq 0 ] ; then
    printf "\r %2d %% compete " $(expr 100 \* ${count} \/ ${total}) > /dev/tty
    fi

    done > ${$}tmpc.txt < ${$}tmpb.txt

    if ! convert ${$}tmpa.pgm -crop 75x50+${x}+${y} -sample 750x500 raw.ppm ; then
    echo "ERROR: convert failed attempting to write file raw.ppm."
    help
    fi

    if ! convert ${$}tmpc.txt -sample 750x500 bayer.ppm ; then
    echo "ERROR: convert failed attempting to write file bayer.ppm."
    help
    fi

    echo -e "\rCreated image files \"bayer.ppm\" and \"raw.ppm\""

    exit 0
     
    Floyd L. Davidson, Aug 19, 2007
    #16
  17. [A complimentary Cc of this posting was sent to
    Floyd L. Davidson
    [about 50-lines-long script deleted]

    This is why I said to use an appropriate tool. In Perl, it would be a
    2-line script. [Slightly more if one adds help and includes calls to
    imagemagick inside the script - but I would leave it out.]

    Hope this helps,
    Ilya
     
    Ilya Zakharevich, Aug 19, 2007
    #17
  18. [A complimentary Cc of this posting was sent to
    Floyd L. Davidson
    google for it.

    Hope this helps,
    Ilya
     
    Ilya Zakharevich, Aug 19, 2007
    #18
  19. You opinion noted... (and totally discounted as lacking
    any validity, too.)
    Sure it would, kid.

    But the truth is that you can't even do it at all.
     
    Floyd L. Davidson, Aug 19, 2007
    #19
  20. Doesn't help Ilya. Came up empty.

    (BTW, please do *not* send me emails. We are posting in
    a public forum, there is no purpose in emailing them
    too.)
     
    Floyd L. Davidson, Aug 19, 2007
    #20
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.