[Tioga-users] monochrome image

Edwin edder at tkwsping.nl
Tue Dec 12 16:12:54 EST 2006


On Tue, 12 Dec 2006 17:28:33 -0000, Bill Paxton <paxton at kitp.ucsb.edu>
wrote:

> Here's a little example of a monochrome image using checkerboard data.
>
>      def mono_image
> 	table = build_table(0.1, 0.9)
>          samples = t.create_monochrome_image_data(table, 'boundary'
> => 0.5)
>          t.fill_color = Black
>          t.show_image(
>              'width' => 8,
>              'height' => 8,
>              'color_space' => 'mono',
>              'data' => samples,
>              'interpolate' => false,
>              'll' => [0.1, 0.1],
>              'lr' => [0.9, 0.1],
>              'ul' => [0.1, 0.9])
>      end

Maybe I'm missing how create_monochrome_image_data should be used, but it
only seems to work correctly with a 8x8 table anything smaller produces
the wrong pattern and anything bigger produces a parse error in acroread
(evince is still able to parse it, but also shows the wrong picture). I
tested this with my own data and 8x8 parses fine indeed, but anything else
also produced the wrong results. Below is an edited version of Bill's test
program for a 10x10 table.

Edited program:
def test
      table = build_table(0.1, 0.9)
      samples = t.create_monochrome_image_data(table, 'boundary' => 0.5)
      t.fill_color = Black
      t.show_image(
        'width' => 10,
        'height' => 10,
        'color_space' => 'mono',
        'data' => samples,
        'll' => [0.0, 0.0],
        'lr' => [0.9, 0.0],
        'ul' => [0.0, 0.9])
    end

    def build_table(light, dark)
     num_cols = 10
     num_rows = 10
     table = Dtable.new(num_cols, num_rows)
     row0 = Dvector[light, dark, light, dark, light, dark, light, dark,
light,dark]
     row1 = Dvector[dark, light, dark, light, dark, light, dark, light,
dark,light]
     table.set_row(0,row0)
     table.set_row(1,row1)
     table.set_row(2,row0)
     table.set_row(3,row1)
     table.set_row(4,row0)
     table.set_row(5,row1)
     table.set_row(6,row0)
     table.set_row(7,row1)
     table.set_row(8,row0)
     table.set_row(9,row1)
     return table
    end

Edwin


More information about the Tioga-users mailing list