Shop OBEX P1 Docs P2 Docs Learn Events
Displaying grayscale images with VGA — Parallax Forums

Displaying grayscale images with VGA

homosapienhomosapien Posts: 147
edited 2014-02-03 01:23 in Propeller 1
I'm using a P8X32A to manipulate images produced by a CMOS camera, basically an array of bytes that define the grayness of each pixel from 0 = black to 15 = white, grays are values in-between. I need to display the image on a VGA monitor to help myself with debugging issues, simply plot each byte as a pixel ranging from white to black, depending on the value of the byte.

I do not see any suitable objects in OBEX, and am willing to roll my own, but am beginning to think this may be more complicated than I originally thought: The standard system for outputting VGA from the prop using 2 bits for RGB with a resistor ladder seems to limit me to 4 'gray' values, namely white, light gray, dark gray and black -> corresponding to $11_11_11, $10_10_10, $01_01_01 and $00_00_00, which is going to make a pretty choppy picture, essentially cutting my resolution from 16 to 4. Am I missing something obvious? Is there a way to display a 16-bit grayscale via VGA?

I have found the TV grayscale overlay object created by Phil P., and may end up using that for this debugging, but that means I would need to find an analog TV, which are non-existent in my household at this point in time....

Thanks,
Nate

Comments

  • Mike GreenMike Green Posts: 23,101
    edited 2014-01-30 15:57
    Probably the best thing would be to use a cluster of 4 pixels for each grey-scale pixel. That would theoretically give you 256 grey levels and you could pick the best value for each of the 16 grey levels you want to show.
  • homosapienhomosapien Posts: 147
    edited 2014-01-30 16:07
    That may be a viable route, I will need to figure out if it will fit on the monitor. Also, an effective way to translate each byte to 2 pixels on adjacent scan lines.

    I am thinking the only way to do it with one pixel to show more shades of gray would be to use more pins and a larger resistor ladder/network. I am assuming that for a VGA signal to produce gray R must equal G must equal B. Is that true?


    Nate
  • RaymanRayman Posts: 14,659
    edited 2014-01-30 17:20
    For regular Prop hardware, the TV output is going to give the best results.
    Even the latest TVs seem to include an old style NTSC input...

    I've posted info on hardware and drivers to use the SSD1963 chip with the Prop to output DVI/HDMI or VGA in 24-bit color.
    This would give a perfect image, but uses several Propeller pins...

    You might also want to look at Phil Pilgrims' camera drivers and see what he may have done in this area...
  • TubularTubular Posts: 4,703
    edited 2014-01-30 17:49
    Hi Nate

    Here are the resistor values that give you 64 level VGA grayscale
    http://forums.parallax.com/showthread.php/131622-Resistor-values-for-64-GreyScale-VGA-output-from-the-Propeller

    You can use it with Kye's 160 x 120 driver as is, or other VGA objects, just changing the resistor values. That's why there isn't a separate obex object. I think I did put some comments in the old obex about this but they haven't made the transition to the new obex.

    An example here using a line scan (TSL3301) with some fast moving sheet music, and the 160x120 driver
  • homosapienhomosapien Posts: 147
    edited 2014-01-30 19:41
    Thanks for the replies, exactly what I was looking for, just found and spent an hour or so reading Phil's exploits with the propCAM, lots of good info there.

    Tubular, thanks for confirming I wasn't loosing my sanity, I was doubting myself when it appeared more difficult to produce a grayscale image than a color one in VGA, but I guess that is just how the standard was designed. That resistor sculpture is crazy!


    Thanks again,
    Nate
  • TubularTubular Posts: 4,703
    edited 2014-01-30 20:12
    Not a problem. Yes Lawson's resistor equivalent of stonehenge would be a certainty in my list for the prop projects calendar
  • ericballericball Posts: 774
    edited 2014-01-31 10:20
    Just to expand on the comments. The Propeller's video circuit in "VGA mode" simply drives 8 pins. This is normally connected as HVRrGgBb for 64 colors + sync. But there's no reason you couldn't use a different resistor network to drive RGB with the same value and have 64 level greyscale. However, if your horizontal resolution is less than 132 pixels you might also want to look at http://forums.parallax.com/showthread.php/127775-Greyscale-bitmap-TV-driver
  • LoopyBytelooseLoopyByteloose Posts: 12,537
    edited 2014-02-01 02:24
    Quite awhile ago, there was a thread on tweaking the resistor values of the VGA interface to get a more faithful color range.

    I suspect that the same tweak applies to using an accurate grey scale. Phil had added 100ohm SMD resistors in parallel to the existing configuration on a Propeller Proto board. That fix works, but it not exactly universal.

    It might be wise to reopen the discussion here.
  • TubularTubular Posts: 4,703
    edited 2014-02-03 01:23
    Good point Loopy. I think this is the thread you refer to - "Better VGA DAC Resistors"

    You shouldn't need to tweak the greyscale resistors. They take into account the internal prop driving impedance.
Sign In or Register to comment.