The Smell of Molten Projects in the Morning

Ed Nisley's Blog: Shop notes, electronics, firmware, machinery, 3D printing, laser cuttery, and curiosities. Contents: 100% human thinking, 0% AI slop.

Category: Photography & Images

Taking & making images.

  • Adobe Reader Print Colors

    While printing up handouts for my talk at Cabin Fever, I finally tracked down why Adobe Reader was producing such crappy colors.

    The left is before and the right is after the fix, scanned at the same time with the same image adjustments:

    Oversaturated vs normal printing
    Oversaturated vs normal printing

    All of the print settings appeared correct (plain paper, 720 dpi, normal contrast, etc, etc), but Adobe Reader (and only Adobe Reader) looked like it was trying to print on vastly higher quality paper than I was using. Too much ink, too much contrast, generally useless results.

    The solution was, as always, trivial, after far too much fiddling around.

    In Reader’s Print dialog, there’s a button in the lower-left corner labeled Advanced. Clicky, then put a checkmark in the box that says Let printer determine colors.

    And then It Just Works.

    Equally puzzling: ask for 25 copies of a two-page document, check the Collate box, and you get 25 page 1, 25 page 2, then more page 1 starts coming out. I bet I’d get 25 x 25 sheets of paper by the time it gave up.

    I have no idea what’s going on, either.

    Memo to Self: verify that the box stays checked after updates.

  • DSC-F717 Memory Stick Errors: Socket Cable Reinsertion

    While I was fiddling with the camera to get that first spectrograph, it began coughing up an assortment of Memory Stick errors, including the dreaded C:13:01 error. Having had this happen several years ago, I knew it came from the ribbon cable contacts in the Memory Stick socket and the only way to fix it involves taking the camera apart.

    At the time, I used the guide at http://hbar.servebeer.com/text/f707/, which is now a dead link; you can use archive.org to retrieve it. There’s an exact copy at http://batteringram.org/misc/f707repair/ and a bit of rummaging suggests the same person is running the new site.

    Anyhow, here’s my version of the teardown and fix. This is a bit more aggressive than what you’ll read above, in that I disconnect all the cables to get straightforward access to the guts of the camera, but I think it makes everything easier. In any event, re-plugging the cables in those connectors will probably be a Good Thing.

    Remove the battery, Memory Stick, and all the straps and doodads. This fix will reset the camera to its factory defaults; you must eventually reset everything, so review your settings.

    If your filing system depends on the camera’s numbering system: heads up! This will reset the image sequence numbers; the next picture will be DSC00001.JPG.

    Remove the four Philips-00 screws that hold the rear case in place. Note that they are not identical…

    Two on the left.

    DSC-F717 case screws - left side
    DSC-F717 case screws – left side

    The rear screw on the right side.

    DSC-F717 case screws - right side
    DSC-F717 case screws – right side

    The screw on the right side of the bottom passes through the front part of the case.

    DSC-F717 case screws - bottom
    DSC-F717 case screws – bottom

    Ease the whole rear half of the case, display and all, away from the front half, until you can disconnect the three-wire cable from the power jack. A needle-nose pliers may be helpful, but be gentle!

    DSC-F717 internal power cable
    DSC-F717 internal power cable

    Now things get nasty.

    The flat paddle in the lower right plugs into a socket on the display board in the rear case: pry it out if it hasn’t popped out of its own accord.

    Disconnect the ribbon cable on the left side by prying the gray latch away from the cable; the ribbon will pop out with no effort.

    Put the rear part of the case somewhere out of the way.

    DSC-F717 main board cables
    DSC-F717 main board cables

    Peel the static shield off the main circuit board. The black strip is a surprisingly strong adhesive tape that’s stuck to the ribbon cables along the top edge of the board. Peel gently!

    DSC-F717 static shield
    DSC-F717 static shield

    Pull the three cables out of the sockets along the top of the board. The blue cable seems to be much more fragile than the others, but they all come out by just pulling directly upward: parallel to the board.

    Unscrew the two P-00 screws holding the main board in place: upper left and center of the board.

    DSC-F717 main board cables - top
    DSC-F717 main board cables – top

    Flip the camera over and ease the main board away from the case to expose the white connector on the bottom. This is stuck firmly in place, so try to not brutalize anything around the connector when it pops out.

    DSC-F717 main board cables - bottom
    DSC-F717 main board cables – bottom

    That leaves only the ribbon cable on the right of this picture (left of the camera) connecting the optical section to the main board. Push the two ends of the gray latch bar parallel to the cable (it is not the same as the connector on the other side of the board shown above) away from the connector until the bar releases the cable and it pops out.

    Put the main board somewhere safe.

    DSC-F717 main board cables - rear
    DSC-F717 main board cables – rear

    Now you can actually see the Memory Stick socket behind all the ribbon cables!

    DSC-F717 Memory Stick socket - exposed
    DSC-F717 Memory Stick socket – exposed

    Remove the two P-00 mounting screws, one to the upper right and the other to the lower right in the steel retaining bar.

    Remove the socket from the camera. Whew!

    DSC-F717 Memory Stick socket - retaining screws
    DSC-F717 Memory Stick socket – retaining screws

    Here is the offending cable entry into the Memory Stick socket. Pull the mumble cable out.

    DSC-F717 Memory Stick socket - cable entry
    DSC-F717 Memory Stick socket – cable entry

    The socket pins evidently move just a little bit, every time you put in a  Memory Stick, eroding teeny divots in the cable contact pads. I generally use the USB connection, so the socket doesn’t see a lot of motion. Your mileage may vary.

    DSC-F717 Memory Stick cable indentations
    DSC-F717 Memory Stick cable indentations

    I cleaned off the ribbon cable pads with Caig DeoxIT, although I’m not convinced that really does anything in this situation.

    This guy dismantled the socket to clean the internal contacts, which would probably make sense while you’ve got the hood up. I didn’t do that this time, though.

    Then you reassemble everything in reverse order, after which the camera Just Works. Probably for another few years.

    The puzzling part of this failure: the camera has literally hundreds of ribbon cable contacts, but only the Memory Stick cable goes bad. If any other cable failed, the camera would go Toes Up, right? Next time around I may try soldering thin copper pads on the cable or applying a thin backing layer to improve the resilience, but that sounds pretty risky even to me.

    If you haven’t done so already, put a write-protected image of your biz card / contact info on every Memory Stick you use with your cameras to make it easy for an honest person who finds your camera to get in touch with you. The dishonest ones won’t change their behavior one way or the other.

    Take a picture of your card now: the camera will set up the folders and name it DSC00001.JPG. If you’ve already got such a file, take a picture anyway, delete it, then copy your existing file to the camera as DSC00001.JPG. In either case, write-protect the file.

    Memo to Self: next time, take the socket apart and cast some epoxy around the contacts to prevent further motion.

  • Spectrometer: Quick and Dirty Image Processing

    Having gotten a spectrometer image from the crude camera lashup, the next task is to (figure out how to) extract some meaningful data. The general idea is to use ImageMagick and Gnuplot as much as possible, so as to avoid writing any actual software.

    The original image is the high-res version of this:

    First light - warm-white CFL - no adjustments
    First light – warm-white CFL – no adjustments

    Use ImageMagick to crop out a slice across the middle and convert it to lossless PNG:

    convert -crop 2500x100+0+1000! dsc00273.jpg dsc00273-strip.png
    
    dsc00273-strip.png
    dsc00273-strip.png

    I can’t figure out how to reset the image size using -extract, but -crop gets the job done.

    The default ImageMagic PNG compression is 75, so I should include a -quality 100 option, too.

    Because we have colors separated spatially, all we need is a grayscale intensity plot. The easy and, alas, wrong way to convert the color image to grayscale goes like this:

    convert -colorspace GRAY dsc00273-strip.png dsc00273-strip-gray.png
    
    dsc00273-strip-gray.png
    dsc00273-strip-gray.png

    That grayscale value is a weighted sum of the RGB components that preserves human-vision luminosity:

    Gray = 0.29900*R+0.58700*G+0.11400*B

    I think it’s better to simply add the RGB components without the weights, because we care more about the actual spectral intensity. That might allow overly high intensity in some peculiar situations, but I’ll figure that out later. First, get the red / green / blue channels into separate files:

    convert -separate dsc00273-strip.png dsc00273-strip-chan%d.png
    
    dsc00273-strip-chan0.png
    dsc00273-strip-chan0.png
    dsc00273-strip-chan1.png
    dsc00273-strip-chan1.png
    dsc00273-strip-chan2.png
    dsc00273-strip-chan2.png

    That looks better: the intensities resemble the original colors.

    Then add those three files together, pixel by pixel, to produce a single grayscale file:

    convert -compose plus dsc00273-strip-chan0.png dsc00273-strip-chan1.png -composite dsc00273-strip-chan2.png -composite dsc00273-strip-spect.png
    
    dsc00273-strip-spect.png
    dsc00273-strip-spect.png

    Extract a one-pixel row from the middle and write it as a raw binary file. You could extract the row from the original image, but I think some blurring might be appropriate, so later is better. There’s no point in trying to display a one-pixel-tall image, so I won’t bother.

    convert -crop 2500x1+0+50 dsc00273-strip-spect.png gray:dsc00273-line.bin
    

    Fire up Gnuplot and have it plot the grayscale intensities:

    gnuplot
    plot 'dsc00273-line.bin' binary format="%uint8" record=2500x1 using 1 with lines lt 3
    

    And there’s the spectrogram…

    Gnuplot - dsc00270 - CFL
    Gnuplot – dsc00270 – CFL

    A quick-and-dirty bash script to persuade ImageMagick to make something similar to that happen, including all the commented-out cruft that I’ve been copying forever so I don’t forget the magick incantations when I need them again:

    #!/bin/sh
    base=${1%%.*}
    echo Base name is ${base}
    convert -crop 2500x100+0+1000! $1 ${base}-strip.png
    convert -separate ${base}-strip.png ${base}-strip-chan%d.png
    convert -compose plus ${base}-strip-chan0.png ${base}-strip-chan1.png -composite ${base}-strip-chan2.png -composite ${base}-strip-spect.png
    convert -crop 2500x1+0+50 ${base}-strip-spect.png gray:${base}-line.bin
    export GDFONTPATH="/usr/share/fonts/TTF/"
    gnuplot << EOF
    set term png font "arialbd.ttf" 18 size 950,600
    set output "${base}-spect.png"
    set title "${base} Spectrum"
    set key noautotitles
    unset mouse
    set bmargin 4
    #set grid xtics ytics
    #set xrange [0:1400]
    set xlabel "Red <- Colors -> Violet"
    #set format x "%3.0f"
    #set logscale y
    set ylabel "Light intensity"
    #set format y "%3.0f"
    #set yrange [0:60]
    #set ytic 5
    #set datafile separator "\t"
    #set label 1 "mumble" at 1600,0.300 font "arialbd,18"
    plot	\
    	"${base}-line.bin" \
    	binary format="%uint8" record=2500x1 \
    	using 1 with lines lt 3
    EOF
    display ${base}-spect.png
    

    Observations & ideas:

    It turns out that the flat topped peak in the middle was in the original green channel data: that color was overexposed.

    If I had a camera that could do RAW images, this whole thing would work even better. Using 16-bit intensity channels would be exceedingly good; the original JPG file has only 8-bit channel resolution: 1/256 = -24 dB, which isn’t anywhere near good enough. That’s assuming the camera + JPG compression has 24 dB dynamic range, which I doubt.

    That blue / violet peak over on the right looks great: the optical focus is fine & dandy. I focused the spectrometer at roughly infinity, set the camera to infinity, then tweaked the spectrometer to make the answer come out right.

    FWIW, I think that deep blue-violet line is the mercury G-line emission at 435 nm, which would explain why it’s so narrow. The others are rather broad phosphor emissions from the CFL tube’s surface.

    LEDs can provide spectral wavelength calibration markers, although their peaks are rather broad in comparison to mercury emission lines. A 400-450 nm “UV” LED puts out a broad blue-violet blur on the left (reddish) side of the emission line. Maybe it’s really the mercury emission H-line at 404 nm?

    An IR LED puts a line on the far left side, about twice the distance to the left of the red line as the green line is to its right. I don’t know the exact wavelength, but it’s around 900 nm. The camera (my old DSC-F717) can do IR + visual images, but it insists on auto-setting the exposure and focus, which wipes out the other lines. The line is barely visible with the camera’s internal (and highly effective) hot mirror in place. Maybe with a more stable setup that would work.

    Diode lasers in IR, red, green, and blue? Hmmm…

    ImageMagick (probably) can’t detect those LED markers and scale the output file width, as it deals with intensity over a regular XY grid. A Python script could swallow the output binary file and spit out a scaled binary file with the bump peaks set to known locations. Actually, I’d be willing to bet there’s a perverse way to get IM to do X-axis scaling, but I’m even more certain the command-line syntax would be a wonder to behold.

    Inject the LED images with a beamsplitter or teeny mirror across the bottom of the spectrometer slit and get intensity calibration, too. Vary the LED intensity with a known current for decent calibration over several orders of magnitude. That could compensate for the crappy dynamic range: as long as the LEDs aren’t saturated, you can correct them to a known peak value. IM can probably do that automagically, given known regions on the input curve.

    Blur the strip image to get rid of color noise and irregularities in the slit. Perhaps a vertical sum in each channel along (part of?) the entire strip, then divide by the strip height, which would completely avoid blurring along the horizontal axis. If, of course, the entrance slit is exactly vertical with respect to the camera sensor.

    IM knows how to deskew / rotate images. Apply that before summing, so as to correct small misalignments?

    Different cameras have different entrance pupils. A quick check shows the DSC-H5 has a much smaller entrance pupil at full zoom: the spectrum covers more than the full screen, so the spectroscope won’t work well with that camera. Normally, you’d like to fill the entrance pupil with the image, but …

    Getting all the optical machinery supported and aligned and oriented will require an optical bench of some sort. Perhaps my surface plate with magnetic sticky bases?

    I think this is going to work…

  • Spectrometer: Quick and Dirty Camera Mount

    This is a proof-of-concept lashup for a camera-mounted spectrometer; I wanted to find out if the image processing would work, but needed some images without devoting a lot of time to the hardware.

    The general idea is that a direct-view spectrometer produces a focused-at-infinity image for your eye. Substitute a camera for your eye and you get an image with the spectral components laid out in a spatial array, suitable for measurement and calculation.

    The trick is holding the spectrometer on the lens axis while blocking ambient light. I figured that I could mount the spectrometer in a disk that fit into the camera’s 58 mm filter threads, then hold it in place for the few pix I’d need to get started.

    The end result was Good Enough for the purpose, although it’s definitely a kludge…

    Spectrometer mounted on camera
    Spectrometer mounted on camera

    The (admittedly cheap) prism-based direct-view spectrometer has a slide-to-focus mechanism that substitutes heavy grease for mechanical precision. A guide screw in a slot prevents the focusing tube from rotating in the body tube, so I decided to replace that with a locking screw to clamp the tubes together. It’s a very fine thread, undoubtedly metric, screw, but a bit of rummaging in my teeny-screw drawer turned up a match (those are mm divisions on the scale):

    Spectrometer screw vs standard thread
    Spectrometer screw vs standard thread

    I think the spectroscope makers filed down the head of an ordinary brass screw to fit the slot, rather than using an actual fillister screw. That’s a Torx T-6 head on the flat-head screw, which probably came from a scrapped hard drive. I eventually found a round-head crosspoint screw (requiring a P-1 bit) that worked better, with a brass washer underneath for neatness.

    That got me to this stage:

    Spectrometer with locking screw
    Spectrometer with locking screw

    Making the adapter disk involved, as usual, a bit of manual CNC to enlarge the center hole of a CD from 15 to 15.75 mm, then cut out a 57 mm cookie. A stack of CDs makes a perfectly good sacrificial work surface for this operation, with some fender washers clamping the pile to the tooling plate. Those homebrew clamps are smaller than the Official Sherline clamps and work better for large objects on the small table.

    Milling outside diameter
    Milling outside diameter

    I briefly considered milling a thread into the OD, but came to my senses… I still have that pile of 10-32 taps, but now is not the time!

    While in the Machine Tool Wing of the Basement Laboratory, I bored a short plastic bushing to a tight slip fit on the focusing tube to clamp the disk to the eyepiece, with the intent of keeping the eyepiece from whacking the camera lens. That’s the small white cylinder in the first picture.

    As it turned out, I had to mount the whole affair on a sunshade that screwed into the camera filter mount, because the eyepiece protruded far enough to just barely kiss the lens.

    A liberal covering of black electrical tape killed off all the stray light. Hand-holding all the pieces together and aiming it at the CFL tube over the Electronics Workbench produced this First Light image:

    First light - warm-white CFL - no adjustments
    First light – warm-white CFL – no adjustments

    Believe it or not, that’s pretty much in focus. Much of the width in the red & green lines seems to come from the phosphors, as there’s a bar-sharp narrow blue line to the far right, beyond the obvious blue line.

    Settings: manual focus at infinity, manual exposure 1/60 @ f/2.4, auto ISO = 100. Maybe 30 cm from the 27 W CFL tube: way more light than I’ll ever get through a liquid sample in a cuvette.

    Now to fiddle with ImageMagick and Gnuplot…

  • What Do Squirrels Do When It Rains?

    Rain-soaked squirrel
    Rain-soaked squirrel

    Although I’m not a big fan of tree rats squirrels, I’ll admit this one was having a tough time of it during a recent rainstorm. He (she?) sat motionless on that stub of a branch for well over half an hour, no doubt thinking gloomy thoughts.

    Taken through two layers of mid-1950s window glass, so it’s not the sharpest image in my collection, but I’m not going out in the rain just to take a picture of a squirrel!

  • Our Old Studebaker: Back in the Day

    In addition to those after-restoration images, here are some pix from an old family album that show our 1957 Studebaker President in its prime.

    I think these were taken around 1970, but I really don’t know. As with many family pix, I also have no idea why these were so important…

    The photos were in bad shape, as you can see in the lower-right image, with the magenta dye having faded very little over the decades compared to cyan and yellow; they’ve been brutally color-corrected and contrast-stretched. They were also printed on horrible satin-finish paper and that fishnet overlay is painfully obvious.

    If you need an original image for some perverse purpose, let me know…

  • Turtles on a Log

    If there’s anything to reincarnation, next time around I’m going to put in a request to be a Staff Turtle at the Vassar Farm Environmental Station.

    Vassar Farm Turtles
    Vassar Farm Turtles

    Taken with my Casio EX-Z850 pocket camera, underexposed 2/3 stop to avoid blowing out the highlights even more. This is a dot-for-dot crop from the middle of a much larger 8 MP image, crisped up just slightly. Terrible results, but it’s better than the big camera I didn’t drag along on a guided geology tour (which ended with a generous handful of fine clay from the stream a bit further along).

    And, yeah, I know the whole reincarnation thing says you get what you deserve, not what you want. On the other flipper, nobody really knows how it all works, so I’m not losing hope.