Re: mapping a pixel to a character




j0mbolar wrote:
> I have access to the pixels of an image in grayscale.
> I would like to map each pixel to a character.
> I have 64 characters arranged in order based on
> their densities. What is a technique that would
> perform this kind of mapping?
>
> There are also 24 bits per pixel and 3 bytes per
> pixel.
>

>>From section 4.5 of:

http://www.jgcampbell.com/ip/ip4.txt

Your input image is f1. Suppose, a<=f1(x,y)<=b, i.e. the range of f1()
is [a,b], and you
want the range mapped to z0<=z'<=G, then the transformation is

(4.5-2) z'= (zG-z0).(z-a)/(b-a) + z0

= (zG-z0).z/(b-a) + (z0.b-zG.a)/(b-a)
scale shift

Your [a, b] is [0, 63]; round or truncate the value to an integer and
you have an index into a character array -- i.e. put the grey level
characters in an array. If you want, I have some very kludgy C code
that prints an image as a page of characters; but I could never find
more than ten suitable. On a line printer, one could do overstrike, so
i think i managed 24 grey levels with that.

Assuming that is what you mean. Initially I thought OCR was your goal.

Best regards,

Jon C.

.



Relevant Pages

  • Tk canvas: why are some lines a pixel too short?
    ... My Tk application draws its own characters, ... to have one few pixel fewer lit up on the two right-hand ends compared ... the supposedly symmetrical pattern has a distinctly flat ...
    (comp.lang.tcl)
  • Re: Screen Size
    ... So I presume you mean that you used the conversion obtained from Point to Pixels to set up the size of your font in the LOGFONT structure that you used with CreateFontIndirect API and then just happened to draw that text to the screen DC using DrawText. ... If that is the case then you've probably used the pixel value directly when using CreateFontIndirect, ... When you use a negative value for the pixel size in the lfHeight entry in the LOGFONT structure then you are effectively asking Windows to select a font size such that the height of the "glyph" (the part of the character cell actually occupied by the shape of the characters) is the requested pixel height. ...
    (microsoft.public.vb.general.discussion)
  • Re: Setting the column width size to n number of characters
    ... size in pixel. ... number of characters. ... for some possible choices of font. ... Roedy Green Canadian Mind Products ...
    (comp.lang.java.gui)
  • Re: Rasterizing text (simple html for example) to low resosultion grahics
    ... small buffers for all the characters you want to be able to display. ... you output a pixel on screen of the desired color. ... also come in handy if you want to add scroll capabilities but don't ...
    (comp.lang.forth)
  • Re: char problem
    ... > fgets(wholeLine, 45, ptr); ... > it into three different character array? ... a buffer of 45 characters is rather mean. ... and replaces the separator with a NUL. ...
    (comp.lang.c)