Version 2 of Binary image compression challenge - Theo Verelst's entry

Updated 2004-09-08 12:36:52 by TV

TV

A bit late (I was in France doing a rock and roll performance) I thought I'd take up this nice challenge and enter my (fill in amount here) .. $ .

I've in the past done a page on C compiled image processing on an interactive Bwise canvas, which is a frame which probably can be used, but in similar BWise spirit, I thought I'd do an at least little insightfull JPEG2000 encoding variation for the challenge, or at least for a part of the actual assignment.

JPEG2000 is an interesting addition to the existing JPEG encoding scheme, which is a lossy algorithm good for encoding photographs with quite a good compression ratio, though not with perfect results. There is a lossless and a lossy variation of the jpeg2000 algorithm suite, and quite severe compression ratios are possible, though I'd say after having played around a bit (not much) that the main application would be very high compression ratios for large pictures, which then still look pretty good, but not more photographically perfect. So let's say you yanked the compression control in Gimp all the way down when saving in jpeg format, and all edges have started to blurr at the desired output picture size, then you might want jpeg2000 to still get a pretty good result instead of a complete blurr.

Anyhow, back to the challenge. I've come up with 3 major compression thoughts, maybe not original, but relevant:

  • the first entries can of course be OCR-ed, and then rendered in a suitable font
  • the (also presentin GIF) run lenght encoding theme can be varied on
  • existing image compression schemes, especially open source ones, are usually worth a look, because of course a lot of work was already put into them

I wanted to at least make an example of the last point, using the relatively new and not widely used JPEG2000 compression method, for which as far as I know there is no tcl library or DLL. To make the whole scheme a bit more insightfull, I though I'd use Bwise to visualize the datapath.

First, a assesment of validity of the approach, to see if it is worth while persuing this method, and discern ins and outs of using this compression method for this assignment, and if we'll score any points for this solution...

http://82.168.209.239/Wiki/challenge1.jpg

Here is the bwise file for this solution, which calls the external program 'jasper.exe' (in my case on windows XP, fitted with cygwin) from [L1 ] for which the tcl variable jasperexec points to the executable.


 # canrsassign2.tcl
 global bcount scopeindex wireindex shellindex drumindex entrycount moncount proccount seqcount  stackcount termindex textcount
 set bcount 0
 set scopeindex 0
 set wireindex 11
 set shellindex 0
 set drumindex 0
 set textcount 1
 image create photo courier12 -file courier12.gif
 image create photo courier12_back -file courier12_back.ppm
 .mw.c create rectangle 241.0 53.0 281.0 98.0 -activedash {} -activefill {} -activeoutline {} -activeoutlinestipple {} -activestipple {} -activewidth 0.0 -dash {} -dashoffset 0 -disableddash {} -disabledfill {} -disabledoutline {} -disabledoutlinestipple {} -disabledstipple {} -disabledwidth 0 -fill yellow -offset 0,0 -outline darkblue -outlineoffset 0,0 -outlinestipple {} -state {} -stipple {} -tags {tojpeg2000 newblock block} -width 1.0
 .mw.c create text 261.0 98.0 -activefill {} -activestipple {} -anchor n -disabledfill {} -disabledstipple {} -fill darkblue -font {{MS Sans Serif} 8} -justify left -offset 0,0 -state {} -stipple {} -tags {tojpeg2000 crb label} -text tojpeg2000 -width 0
 .mw.c create text 240.0 72.0 -activefill {} -activestipple {} -anchor se -disabledfill {} -disabledstipple {} -fill black -font {{MS Sans Serif} 8} -justify left -offset 0,0 -state {} -stipple {} -tags {tojpeg2000 crb pinname image} -text image -width 0
 .mw.c create line 221.0 73.0 241.0 73.0 -activedash {} -activefill {} -activestipple {} -activewidth 0.0 -arrow none -arrowshape {8 10 3} -capstyle butt -fill darkblue -dash {} -dashoffset 0 -disableddash {} -disabledfill {} -disabledstipple {} -disabledwidth 0.0 -joinstyle round -offset 0,0 -smooth 0 -splinesteps 12 -state {} -stipple {} -tags {tojpeg2000 newblock pin image typein} -width 2.0
 .mw.c create text 240.0 87.0 -activefill {} -activestipple {} -anchor se -disabledfill {} -disabledstipple {} -fill black -font {{MS Sans Serif} 8} -justify left -offset 0,0 -state {} -stipple {} -tags {tojpeg2000 crb pinname compression} -text compression -width 0
 .mw.c create line 221.0 88.0 241.0 88.0 -activedash {} -activefill {} -activestipple {} -activewidth 0.0 -arrow none -arrowshape {8 10 3} -capstyle butt -fill darkblue -dash {} -dashoffset 0 -disableddash {} -disabledfill {} -disabledstipple {} -disabledwidth 0.0 -joinstyle round -offset 0,0 -smooth 0 -splinesteps 12 -state {} -stipple {} -tags {tojpeg2000 newblock pin compression typein} -width 2.0
 .mw.c create text 282.0 72.0 -activefill {} -activestipple {} -anchor sw -disabledfill {} -disabledstipple {} -fill black -font {{MS Sans Serif} 8} -justify left -offset 0,0 -state {} -stipple {} -tags {tojpeg2000 crb pinname out} -text out -width 0
 .mw.c create line 301.0 73.0 281.0 73.0 -activedash {} -activefill {} -activestipple {} -activewidth 0.0 -arrow none -arrowshape {8 10 3} -capstyle butt -fill darkblue -dash {} -dashoffset 0 -disableddash {} -disabledfill {} -disabledstipple {} -disabledwidth 0.0 -joinstyle round -offset 0,0 -smooth 0 -splinesteps 12 -state {} -stipple {} -tags {tojpeg2000 newblock pin out typeout} -width 2.0
 .mw.c create rectangle 321.0 132.0 361.0 162.0 -activedash {} -activefill {} -activeoutline {} -activeoutlinestipple {} -activestipple {} -activewidth 0.0 -dash {} -dashoffset 0 -disableddash {} -disabledfill {} -disabledoutline {} -disabledoutlinestipple {} -disabledstipple {} -disabledwidth 0 -fill yellow -offset 0,0 -outline darkblue -outlineoffset 0,0 -outlinestipple {} -state {} -stipple {} -tags {filesize newblock block} -width 1.0
 .mw.c create text 341.0 162.0 -activefill {} -activestipple {} -anchor n -disabledfill {} -disabledstipple {} -fill darkblue -font {{MS Sans Serif} 8} -justify left -offset 0,0 -state {} -stipple {} -tags {filesize crb label} -text filesize -width 0
 .mw.c create text 320.0 151.0 -activefill {} -activestipple {} -anchor se -disabledfill {} -disabledstipple {} -fill black -font {{MS Sans Serif} 8} -justify left -offset 0,0 -state {} -stipple {} -tags {filesize crb pinname in} -text in -width 0
 .mw.c create line 301.0 152.0 321.0 152.0 -activedash {} -activefill {} -activestipple {} -activewidth 0.0 -arrow none -arrowshape {8 10 3} -capstyle butt -fill darkblue -dash {} -dashoffset 0 -disableddash {} -disabledfill {} -disabledstipple {} -disabledwidth 0.0 -joinstyle round -offset 0,0 -smooth 0 -splinesteps 12 -state {} -stipple {} -tags {filesize newblock pin in typein} -width 2.0
 .mw.c create text 362.0 151.0 -activefill {} -activestipple {} -anchor sw -disabledfill {} -disabledstipple {} -fill black -font {{MS Sans Serif} 8} -justify left -offset 0,0 -state {} -stipple {} -tags {filesize crb pinname out} -text out -width 0
 .mw.c create line 381.0 152.0 361.0 152.0 -activedash {} -activefill {} -activestipple {} -activewidth 0.0 -arrow none -arrowshape {8 10 3} -capstyle butt -fill darkblue -dash {} -dashoffset 0 -disableddash {} -disabledfill {} -disabledstipple {} -disabledwidth 0.0 -joinstyle round -offset 0,0 -smooth 0 -splinesteps 12 -state {} -stipple {} -tags {filesize newblock pin out typeout} -width 2.0
 .mw.c create line 301.0 73.0 301.0 152.0 -activedash {} -activefill {} -activestipple {} -activewidth 0.0 -arrow none -arrowshape {8 10 3} -capstyle butt -fill darkblue -dash {} -dashoffset 0 -disableddash {} -disabledfill {} -disabledstipple {} -disabledwidth 0.0 -joinstyle round -offset 0,0 -smooth 0 -splinesteps 12 -state {} -stipple {} -tags {wire2 connect wire tojpeg2000 out filesize in} -width 1.0
 .mw.c create rectangle 127.0 53.0 167.0 83.0 -activedash {} -activefill {} -activeoutline {} -activeoutlinestipple {} -activestipple {} -activewidth 0.0 -dash {} -dashoffset 0 -disableddash {} -disabledfill {} -disabledoutline {} -disabledoutlinestipple {} -disabledstipple {} -disabledwidth 0 -fill yellow -offset 0,0 -outline darkblue -outlineoffset 0,0 -outlinestipple {} -state {} -stipple {} -tags {toppm newblock block} -width 1.0
 .mw.c create text 147.0 83.0 -activefill {} -activestipple {} -anchor n -disabledfill {} -disabledstipple {} -fill darkblue -font {{MS Sans Serif} 8} -justify left -offset 0,0 -state {} -stipple {} -tags {toppm crb label} -text toppm -width 0
 .mw.c create text 126.0 72.0 -activefill {} -activestipple {} -anchor se -disabledfill {} -disabledstipple {} -fill black -font {{MS Sans Serif} 8} -justify left -offset 0,0 -state {} -stipple {} -tags {toppm crb pinname in} -text in -width 0
 .mw.c create line 107.0 73.0 127.0 73.0 -activedash {} -activefill {} -activestipple {} -activewidth 0.0 -arrow none -arrowshape {8 10 3} -capstyle butt -fill darkblue -dash {} -dashoffset 0 -disableddash {} -disabledfill {} -disabledstipple {} -disabledwidth 0.0 -joinstyle round -offset 0,0 -smooth 0 -splinesteps 12 -state {} -stipple {} -tags {toppm newblock pin in typein} -width 2.0
 .mw.c create text 168.0 72.0 -activefill {} -activestipple {} -anchor sw -disabledfill {} -disabledstipple {} -fill black -font {{MS Sans Serif} 8} -justify left -offset 0,0 -state {} -stipple {} -tags {toppm crb pinname out} -text out -width 0
 .mw.c create line 187.0 73.0 167.0 73.0 -activedash {} -activefill {} -activestipple {} -activewidth 0.0 -arrow none -arrowshape {8 10 3} -capstyle butt -fill darkblue -dash {} -dashoffset 0 -disableddash {} -disabledfill {} -disabledstipple {} -disabledwidth 0.0 -joinstyle round -offset 0,0 -smooth 0 -splinesteps 12 -state {} -stipple {} -tags {toppm newblock pin out typeout} -width 2.0
 .mw.c create line 221.0 73.0 187.0 73.0 -activedash {} -activefill {} -activestipple {} -activewidth 0.0 -arrow none -arrowshape {8 10 3} -capstyle butt -fill darkblue -dash {} -dashoffset 0 -disableddash {} -disabledfill {} -disabledstipple {} -disabledwidth 0.0 -joinstyle round -offset 0,0 -smooth 0 -splinesteps 12 -state {} -stipple {} -tags {wire4 connect wire tojpeg2000 image toppm out} -width 1.0
 .mw.c create rectangle 335.0 53.0 375.0 83.0 -activedash {} -activefill {} -activeoutline {} -activeoutlinestipple {} -activestipple {} -activewidth 0.0 -dash {} -dashoffset 0 -disableddash {} -disabledfill {} -disabledoutline {} -disabledoutlinestipple {} -disabledstipple {} -disabledwidth 0 -fill yellow -offset 0,0 -outline darkblue -outlineoffset 0,0 -outlinestipple {} -state {} -stipple {} -tags {jp2toppm newblock block} -width 1.0
 .mw.c create text 355.0 83.0 -activefill {} -activestipple {} -anchor n -disabledfill {} -disabledstipple {} -fill darkblue -font {{MS Sans Serif} 8} -justify left -offset 0,0 -state {} -stipple {} -tags {jp2toppm crb label} -text jp2toppm -width 0
 .mw.c create text 334.0 72.0 -activefill {} -activestipple {} -anchor se -disabledfill {} -disabledstipple {} -fill black -font {{MS Sans Serif} 8} -justify left -offset 0,0 -state {} -stipple {} -tags {jp2toppm crb pinname in} -text in -width 0
 .mw.c create line 315.0 73.0 335.0 73.0 -activedash {} -activefill {} -activestipple {} -activewidth 0.0 -arrow none -arrowshape {8 10 3} -capstyle butt -fill darkblue -dash {} -dashoffset 0 -disableddash {} -disabledfill {} -disabledstipple {} -disabledwidth 0.0 -joinstyle round -offset 0,0 -smooth 0 -splinesteps 12 -state {} -stipple {} -tags {jp2toppm newblock pin in typein} -width 2.0
 .mw.c create text 376.0 72.0 -activefill {} -activestipple {} -anchor sw -disabledfill {}  -disabledstipple {} -fill black -font {{MS Sans Serif} 8} -justify left -offset 0,0 -state {} -stipple {} -tags {jp2toppm crb pinname out} -text out -width 0
 .mw.c create line 395.0 73.0 375.0 73.0 -activedash {} -activefill {} -activestipple {} -activewidth 0.0 -arrow none -arrowshape {8 10 3} -capstyle butt -fill darkblue -dash {} -dashoffset 0 -disableddash {} -disabledfill {} -disabledstipple {} -disabledwidth 0.0 -joinstyle round -offset 0,0 -smooth 0 -splinesteps 12 -state {} -stipple {} -tags {jp2toppm newblock pin out typeout} -width 2.0
 .mw.c create line 301.0 73.0 315.0 73.0 -activedash {} -activefill {} -activestipple {} -activewidth 0.0 -arrow none -arrowshape {8 10 3} -capstyle butt -fill darkblue -dash {} -dashoffset 0 -disableddash {} -disabledfill {} -disabledstipple {} -disabledwidth 0.0 -joinstyle round -offset 0,0 -smooth 0 -splinesteps 12 -state {} -stipple {} -tags {wire5 connect wire tojpeg2000 out jp2toppm in} -width 1.0
 .mw.c create rectangle 427.0 132.0 487.0 172.0 -activedash {} -activefill {} -activeoutline {} -activeoutlinestipple {} -activestipple {} -activewidth 0.0 -dash {} -dashoffset 0 -disableddash {} -disabledfill {} -disabledoutline {} -disabledoutlinestipple {} -disabledstipple {} -disabledwidth 0 -fill yellow -offset 0,0 -outline darkblue -outlineoffset 0,0 -outlinestipple {} -state {} -stipple {} -tags {Text1 newblock block} -width 1.0
 .mw.c create text 457.0 172.0 -activefill {} -activestipple {} -anchor n -disabledfill {} -disabledstipple {} -fill darkblue -font {{MS Sans Serif} 8} -justify left -offset 0,0 -state {} -stipple {} -tags {Text1 crb label} -text Text1 -width 0
 .mw.c create text 426.0 151.0 -activefill {} -activestipple {} -anchor se -disabledfill {} -disabledstipple {} -fill black -font {{MS Sans Serif} 8} -justify left -offset 0,0 -state {} -stipple {} -tags {Text1 crb pinname in} -text in -width 0
 .mw.c create line 407.0 152.0 427.0 152.0 -activedash {} -activefill {} -activestipple {} -activewidth 0.0 -arrow none -arrowshape {8 10 3} -capstyle butt -fill darkblue -dash {} -dashoffset 0 -disableddash {} -disabledfill {} -disabledstipple {} -disabledwidth 0.0 -joinstyle round -offset 0,0 -smooth 0 -splinesteps 12 -state {} -stipple {} -tags {Text1 newblock pin in typein} -width 2.0
 .mw.c create text 433.0 142.0 -activefill {} -activestipple {} -anchor nw -disabledfill {} -disabledstipple {} -fill navy -font {courier 10} -justify left -offset 0,0 -state {} -stipple {} -tags {Text1 textfield} -text 2578 -width 0
 .mw.c create line 381.0 152.0 407.0 152.0 -activedash {} -activefill {} -activestipple {} -activewidth 0.0 -arrow none -arrowshape {8 10 3} -capstyle butt -fill darkblue -dash {} -dashoffset 0 -disableddash {} -disabledfill {} -disabledstipple {} -disabledwidth 0.0 -joinstyle round -offset 0,0 -smooth 0 -splinesteps 12 -state {} -stipple {} -tags {wire6 connect wire filesize out Text1 in} -width 1.0
 .mw.c create rectangle 176.0 238.0 550.0 284.0 -activedash {} -activefill {} -activeoutline {} -activeoutlinestipple {} -activestipple {} -activewidth 0.0 -dash {} -dashoffset 0 -disableddash {} -disabledfill {} -disabledoutline {} -disabledoutlinestipple {} -disabledstipple {} -disabledwidth 0 -fill yellow -offset 0,0 -outline darkblue -outlineoffset 0,0 -outlinestipple {} -state {} -stipple {} -tags {courier12_back newblock block} -width 1.0
 .mw.c create text 363.0 284.0 -activefill {} -activestipple {} -anchor n -disabledfill {} -disabledstipple {} -fill darkblue -font {{MS Sans Serif} 8} -justify left -offset 0,0 -state {} -stipple {} -tags {courier12_back crb label} -text courier12_back -width 0
 .mw.c create text 175.0 257.0 -activefill {} -activestipple {} -anchor se -disabledfill {} -disabledstipple {} -fill black -font {{MS Sans Serif} 8} -justify left -offset 0,0 -state {} -stipple {} -tags {courier12_back crb pinname in} -text in -width 0
 .mw.c create line 156.0 258.0 176.0 258.0 -activedash {} -activefill {} -activestipple {} -activewidth 0.0 -arrow none -arrowshape {8 10 3} -capstyle butt -fill darkblue -dash {} -dashoffset 0 -disableddash {} -disabledfill {} -disabledstipple {} -disabledwidth 0.0 -joinstyle round -offset 0,0 -smooth 0 -splinesteps 12 -state {} -stipple {} -tags {courier12_back newblock pin in typein} -width 2.0
 .mw.c create text 551.0 257.0 -activefill {} -activestipple {} -anchor sw -disabledfill {} -disabledstipple {} -fill black -font {{MS Sans Serif} 8} -justify left -offset 0,0 -state {} -stipple {} -tags {courier12_back crb pinname out} -text out -width 0
 .mw.c create line 570.0 258.0 550.0 258.0 -activedash {} -activefill {} -activestipple {} -activewidth 0.0 -arrow none -arrowshape {8 10 3} -capstyle butt -fill darkblue -dash {} -dashoffset 0 -disableddash {} -disabledfill {} -disabledstipple {} -disabledwidth 0.0 -joinstyle round -offset 0,0 -smooth 0 -splinesteps 12 -state {} -stipple {} -tags {courier12_back newblock pin out typeout} -width 2.0
 .mw.c create image 176.0 238.0 -activeimage {} -anchor nw -disabledimage {} -image courier12_back -state {} -tags {courier12_back newimage block image}
 .mw.c create line 395.0 73.0 156.0 258.0 -activedash {} -activefill {} -activestipple {} -activewidth 0.0 -arrow none -arrowshape {8 10 3} -capstyle butt -fill darkblue -dash {} -dashoffset 0 -disableddash {} -disabledfill {} -disabledstipple {} -disabledwidth 0.0 -joinstyle round -offset 0,0 -smooth 0 -splinesteps 12 -state {} -stipple {} -tags {wire7 connect wire jp2toppm out courier12_back in} -width 1.0
 .mw.c create rectangle 29.0 53.0 69.0 83.0 -activedash {} -activefill {} -activeoutline {} -activeoutlinestipple {} -activestipple {} -activewidth 0.0 -dash {} -dashoffset 0 -disableddash {} -disabledfill {} -disabledoutline {} -disabledoutlinestipple {} -disabledstipple {} -disabledwidth 0 -fill yellow -offset 0,0 -outline darkblue -outlineoffset 0,0 -outlinestipple {} -state {} -stipple {} -tags {courier12_gif newblock block} -width 1.0
 .mw.c create text 49.0 83.0 -activefill {} -activestipple {} -anchor n -disabledfill {} -disabledstipple {} -fill darkblue -font {{MS Sans Serif} 8} -justify left -offset 0,0 -state {} -stipple {} -tags {courier12_gif crb label} -text courier12_gif -width 0
 .mw.c create text 70.0 72.0 -activefill {} -activestipple {} -anchor sw -disabledfill {} -disabledstipple {} -fill black -font {{MS Sans Serif} 8} -justify left -offset 0,0 -state {} -stipple {} -tags {courier12_gif crb pinname out} -text out -width 0
 .mw.c create line 89.0 73.0 69.0 73.0 -activedash {} -activefill {} -activestipple {} -activewidth 0.0 -arrow none -arrowshape {8 10 3} -capstyle butt -fill darkblue -dash {} -dashoffset 0 -disableddash {} -disabledfill {} -disabledstipple {} -disabledwidth 0.0 -joinstyle round -offset 0,0 -smooth 0 -splinesteps 12 -state {} -stipple {} -tags {courier12_gif newblock pin out typeout} -width 2.0
 .mw.c create line 107.0 73.0 89.0 73.0 -activedash {} -activefill {} -activestipple {} -activewidth 0.0 -arrow none -arrowshape {8 10 3} -capstyle butt -fill darkblue -dash {} -dashoffset 0 -disableddash {} -disabledfill {} -disabledstipple {} -disabledwidth 0.0 -joinstyle round -offset 0,0 -smooth 0 -splinesteps 12 -state {} -stipple {} -tags {wire9 connect wire toppm in courier12_gif out} -width 1.0
 .mw.c create rectangle 49.0 176.0 423.0 222.0 -activedash {} -activefill {} -activeoutline {} -activeoutlinestipple {} -activestipple {} -activewidth 0.0 -dash {} -dashoffset 0 -disableddash {} -disabledfill {} -disabledoutline {} -disabledoutlinestipple {} -disabledstipple {} -disabledwidth 0 -fill yellow -offset 0,0 -outline darkblue -outlineoffset 0,0 -outlinestipple {} -state {} -stipple {} -tags {courier12 newblock block} -width 1.0
 .mw.c create text 236.0 222.0 -activefill {} -activestipple {} -anchor n -disabledfill {} -disabledstipple {} -fill darkblue -font {{MS Sans Serif} 8} -justify left -offset 0,0 -state {} -stipple {} -tags {courier12 crb label} -text courier12 -width 0
 .mw.c create text 48.0 195.0 -activefill {} -activestipple {} -anchor se -disabledfill {} -disabledstipple {} -fill black -font {{MS Sans Serif} 8} -justify left -offset 0,0 -state {} -stipple {} -tags {courier12 crb pinname in} -text in -width 0
 .mw.c create line 29.0 196.0 49.0 196.0 -activedash {} -activefill {} -activestipple {} -activewidth 0.0 -arrow none -arrowshape {8 10 3} -capstyle butt -fill darkblue -dash {} -dashoffset 0 -disableddash {} -disabledfill {} -disabledstipple {} -disabledwidth 0.0 -joinstyle round -offset 0,0 -smooth 0 -splinesteps 12 -state {} -stipple {} -tags {courier12 newblock pin in typein} -width 2.0
 .mw.c create text 424.0 195.0 -activefill {} -activestipple {} -anchor sw -disabledfill {} -disabledstipple {} -fill black -font {{MS Sans Serif} 8} -justify left -offset 0,0 -state {} -stipple {} -tags {courier12 crb pinname out} -text out -width 0
 .mw.c create line 443.0 196.0 423.0 196.0 -activedash {} -activefill {} -activestipple {} -activewidth 0.0 -arrow none -arrowshape {8 10 3} -capstyle butt -fill darkblue -dash {} -dashoffset 0 -disableddash {} -disabledfill {} -disabledstipple {} -disabledwidth 0.0 -joinstyle round -offset 0,0 -smooth 0 -splinesteps 12 -state {} -stipple {} -tags {courier12 newblock pin out typeout} -width 2.0
 .mw.c create image 49.0 176.0 -activeimage {} -anchor nw -disabledimage {} -image courier12 -state {} -tags {courier12 newimage block image}
 .mw.c create line 89.0 73.0 29.0 196.0 -activedash {} -activefill {} -activestipple {} -activewidth 0.0 -arrow none -arrowshape {8 10 3} -capstyle butt -fill darkblue -dash {} -dashoffset 0 -disableddash {} -disabledfill {} -disabledstipple {} -disabledwidth 0.0 -joinstyle round -offset 0,0 -smooth 0 -splinesteps 12 -state {} -stipple {} -tags {wire10 connect wire courier12_gif out courier12 in} -width 1.0

 # now the block related variables\n
 set tojpeg2000.bfunc { exec $jasperexec --input ${tojpeg2000.image} --output [lrange [split ${tojpeg2000.image} .] 0 end-1 ].jpc --output-format jpc -O rate=${tojpeg2000.compression} ; set tojpeg2000.out "[lrange [split ${tojpeg2000.image} .] 0 end-1 ].jpc" }
 set tojpeg2000.bfunc_init {}
 set tojpeg2000.compression {0.05}
 set tojpeg2000.image {courier12.ppm}
 set tojpeg2000.out {courier12.jpc}
 set filesize.bfunc { set filesize.out [file size ${filesize.in} ]}
 set filesize.bfunc_init {}
 set filesize.in {courier12.jpc}
 set filesize.out {2578}
 set toppm.bfunc {[lrange [split ${toppm.in} .] 0 end-1 ] write [lrange [split ${toppm.in} .] 0 end-1 ].ppm -format ppm ; set toppm.out "[lrange [split ${toppm.in} .] 0 end-1 ].ppm"}
 set toppm.bfunc_init {}
 set toppm.in {courier12.gif}
 set toppm.out {courier12.ppm}
 set jp2toppm.bfunc { exec $jasperexec --input ${jp2toppm.in} --output [lrange [split ${jp2toppm.in} .] 0 end-1 ]_back.ppm --output-format pnm ; set jp2toppm.out "[lrange [split ${jp2toppm.in} .] 0 end-1 ]_back.ppm" }
 set jp2toppm.bfunc_init {}
 set jp2toppm.in {courier12.jpc}
 set jp2toppm.out {courier12_back.ppm}
 set Text1.bfunc {global mc; $mc itemco [tag_and { Text1 textfield }] -text ${Text1.in} }
 set Text1.bfunc_init {}
 set Text1.in {2578}
 set courier12_back.bfunc { set courier12_back.out [courier12_back read ${courier12_back.in}] }
 set courier12_back.bfunc_init {}
 set courier12_back.in {courier12_back.ppm}
 set courier12_back.out {}
 set courier12_back.bfunc { set courier12_back.out [courier12_back read ${courier12_back.in}] }
 set courier12_back.bfunc_init {}
 set courier12_back.in {courier12_back.ppm}
 set courier12_back.out {}
 set courier12_gif.bfunc { set courier12_gif.out courier12.gif}
 set courier12_gif.bfunc_init {}
 set courier12_gif.out {courier12.gif}
 set courier12.bfunc { set courier12.out [courier12 read ${courier12.in} ]}
 set courier12.bfunc_init {}
 set courier12.gif.bfunc { set courier12.gif.out ${courier12.gif.in} }
 set courier12.gif.bfunc_init {}
 set courier12.gif.out {}
 set courier12.in {courier12.gif}
 set courier12.out {}
 set courier12.bfunc { set courier12.out [courier12 read ${courier12.in} ]}
 set courier12.bfunc_init {}
 set courier12.gif.bfunc { set courier12.gif.out ${courier12.gif.in} }
 set courier12.gif.bfunc_init {}
 set courier12.gif.out {}
 set courier12.in {courier12.gif}
 set courier12.out {}

 # This will probably need different setting for you
 set jasperexec c:/cygwin/usr/local/bin/jasper

(The above is of course not the most compressed way of defining a bwise canvas, I've been working on extracting create or new* commands which make this canvas a single page only. I'm also not sure all initialization is correct for this version, that may require some bwise canvas hacking. It is not my habit to put such untested results on these pages, but if necessariy in this case make the blocks by hand (or, as I did, using interactive command composer): shouldn't be too hard.)

I set compression to 0.01 for the above example, which of course gives an unusable result, like anchient scribles or something, this was done in about 72 milliseconds on a fast 2.6 GHz pentium machine, using simply the exec jasper .... tcl construct.

Clearly, we want better results to at least enter jpeg2000 into the contest, so I made the compression factor not so huge:

http://82.168.209.239/Wiki/challenge3.jpg

Which seems like not enough improvement, but that is not completely true: in this case, though the result still looks horrible, we at least do have a serious compression (though not competitive at all) till about 2kB, and in this case interesting properties of the jpeg2000 transform give as the possibility to get back at our original image, using image post-processing. Alternatively, we could have used lossless jpeg2000 compression, which gives a file size of 6937 bytes, so a lot less competitive and bigger than the gif file.

The image processing is simple, and could (especially when it would be more involved) be done using my Gimp driving with BWise (based on SS's Gimp Client) to fully include it in the automated tcl / bwise canvas. It is based on simple pixel-wise thresholding of the backtransformed image (which I stored in ppm format, to get rid of the black areas in the jpc result:

http://82.168.209.239/Wiki/challenge2.jpg

I didn't do a pixel for pixel check of the result, but it may well be lossless.