Re: [Mypaint-discuss] Ordered dithering?

2010-09-13 Thread David Gowers
I've just implemented
A) a better test for roundtripping (slow, though.)
and
B) quick rounding tuning in pixops.hpp via macro use.

because of complicated git history I can't provide a patch, instead
I've attached the amended files.

According to this test, we currently badly roundtrip in approximately
half of the 256 possible cases. Most but not all of these errors are
truncation errors.

Changing the rounding behaviour might improve this. I haven't
managed to figure out how to get the desired behaviour yet, but the
new macros make the conversion formulae easy to tweak.
/* This file is part of MyPaint.
 * Copyright (C) 2008-2009 by Martin Renold martin...@gmx.ch
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 */

// downscale a tile to half its size using bilinear interpolation
// used mainly for generating background mipmaps
void tile_downscale_rgb16(PyObject *src, PyObject *dst, int dst_x, int dst_y) {
#ifdef HEAVY_DEBUG
  assert(PyArray_DIM(src, 0) == TILE_SIZE);
  assert(PyArray_DIM(src, 1) == TILE_SIZE);
  assert(PyArray_TYPE(src) == NPY_UINT16);
  assert(PyArray_ISCARRAY(src));

  assert(PyArray_TYPE(dst) == NPY_UINT16);
  assert(PyArray_ISCARRAY(dst));
#endif

  PyArrayObject* src_arr = ((PyArrayObject*)src);
  PyArrayObject* dst_arr = ((PyArrayObject*)dst);

  for (int y=0; yTILE_SIZE/2; y++) {
uint16_t * src_p = (uint16_t*)(src_arr-data + (2*y)*src_arr-strides[0]);
uint16_t * dst_p = (uint16_t*)(dst_arr-data + (y+dst_y)*dst_arr-strides[0]);
dst_p += 3*dst_x;
for(int x=0; xTILE_SIZE/2; x++) {
  dst_p[0] = src_p[0]/4 + (src_p+3)[0]/4 + (src_p+3*TILE_SIZE)[0]/4 + (src_p+3*TILE_SIZE+3)[0]/4;
  dst_p[1] = src_p[1]/4 + (src_p+3)[1]/4 + (src_p+3*TILE_SIZE)[1]/4 + (src_p+3*TILE_SIZE+3)[1]/4;
  dst_p[2] = src_p[2]/4 + (src_p+3)[2]/4 + (src_p+3*TILE_SIZE)[2]/4 + (src_p+3*TILE_SIZE+3)[2]/4;
  src_p += 6;
  dst_p += 3;
}
  }
}
// downscale a tile to half its size using bilinear interpolation
// used mainly for generating tiledsurface mipmaps
void tile_downscale_rgba16(PyObject *src, PyObject *dst, int dst_x, int dst_y) {
#ifdef HEAVY_DEBUG
  assert(PyArray_DIM(src, 0) == TILE_SIZE);
  assert(PyArray_DIM(src, 1) == TILE_SIZE);
  assert(PyArray_TYPE(src) == NPY_UINT16);
  assert(PyArray_ISCARRAY(src));

  assert(PyArray_DIM(dst, 0) == TILE_SIZE);
  assert(PyArray_DIM(dst, 1) == TILE_SIZE);
  assert(PyArray_TYPE(dst) == NPY_UINT16);
  assert(PyArray_ISCARRAY(dst));
#endif

  PyArrayObject* src_arr = ((PyArrayObject*)src);
  PyArrayObject* dst_arr = ((PyArrayObject*)dst);

  for (int y=0; yTILE_SIZE/2; y++) {
uint16_t * src_p = (uint16_t*)(src_arr-data + (2*y)*src_arr-strides[0]);
uint16_t * dst_p = (uint16_t*)(dst_arr-data + (y+dst_y)*dst_arr-strides[0]);
dst_p += 4*dst_x;
for(int x=0; xTILE_SIZE/2; x++) {
  dst_p[0] = src_p[0]/4 + (src_p+4)[0]/4 + (src_p+4*TILE_SIZE)[0]/4 + (src_p+4*TILE_SIZE+4)[0]/4;
  dst_p[1] = src_p[1]/4 + (src_p+4)[1]/4 + (src_p+4*TILE_SIZE)[1]/4 + (src_p+4*TILE_SIZE+4)[1]/4;
  dst_p[2] = src_p[2]/4 + (src_p+4)[2]/4 + (src_p+4*TILE_SIZE)[2]/4 + (src_p+4*TILE_SIZE+4)[2]/4;
  dst_p[3] = src_p[3]/4 + (src_p+4)[3]/4 + (src_p+4*TILE_SIZE)[3]/4 + (src_p+4*TILE_SIZE+4)[3]/4;
  src_p += 8;
  dst_p += 4;
}
  }
}

void tile_composite_rgba16_over_rgb16(PyObject * src, PyObject * dst, float alpha) {
#ifdef HEAVY_DEBUG
  assert(PyArray_DIM(src, 0) == TILE_SIZE);
  assert(PyArray_DIM(src, 1) == TILE_SIZE);
  assert(PyArray_DIM(src, 2) == 4);
  assert(PyArray_TYPE(src) == NPY_UINT16);
  assert(PyArray_ISCARRAY(src));

  assert(PyArray_DIM(dst, 0) == TILE_SIZE);
  assert(PyArray_DIM(dst, 1) == TILE_SIZE);
  assert(PyArray_DIM(dst, 2) == 3);
  assert(PyArray_TYPE(dst) == NPY_UINT16);
  assert(PyArray_ISBEHAVED(dst));
#endif
  
  PyArrayObject* dst_arr = ((PyArrayObject*)dst);
#ifdef HEAVY_DEBUG
  assert(dst_arr-strides[1] == 3*sizeof(uint16_t));
  assert(dst_arr-strides[2] ==   sizeof(uint16_t));
#endif

  uint32_t opac  = alpha * (115) + 0.5;
  opac = CLAMP(opac, 0, 115);
  if (opac == 0) return;

  uint16_t * src_p  = (uint16_t*)((PyArrayObject*)src)-data;
  char * p = dst_arr-data;
  for (int y=0; yTILE_SIZE; y++) {
uint16_t  * dst_p  = (uint16_t*) (p);
for (int x=0; xTILE_SIZE; x++) {
  // resultAlpha = 1.0 (thus it does not matter if resultColor is premultiplied alpha or not)
  // resultColor = topColor + (1.0 - topAlpha) * bottomColor
  const uint32_t one_minus_topAlpha = (115) - src_p[3]*opac/(115);
  dst_p[0] = ((uint32_t)src_p[0]*opac + one_minus_topAlpha*dst_p[0]) / (115);
  dst_p[1] = ((uint32_t)src_p[1]*opac + one_minus_topAlpha*dst_p[1]) / (115);
  dst_p[2] = ((uint32_t)src_p[2]*opac + one_minus_topAlpha*dst_p[2]) / (115);
  src_p += 4;
  dst_p += 3;
}
p += 

[Mypaint-discuss] Fwd: Students exploring user interface design

2010-09-13 Thread Jon Nordby
-- Forwarded message --
From: Matthew Jadud mja...@allegheny.edu
Date: 12 September 2010 23:04
Subject: Students exploring user interface design
To: Matthew Jadud mja...@allegheny.edu


Hello all,

I will keep my note brief. I'm writing you because you, or a colleague
of yours, responded to my call regarding usability/interaction
design[1]. I've tried to capture all of your projects in a list[2],
and have done my best to (briefly) write something about your
projects. I want to say that I am overwhelmed by the number of
responses I received, and from so many projects that I am familiar
with in one form or another. I'm very excited about the opportunities
your projects represent for the students.

The students are currently engaging in their first UI design and
testing project, which involves student involvement with the Fedora
Design community surrounding their pending website redesign. The
students don't *really* know what they're doing yet, and Máirín Duffy
and the websites team were kind enough to let the students use this as
an opportunity to skin their knees a bit and learn what the whole UI
design/test process looks like. As I've heard some FOSS practitioners
say, the students are learning to be productively lost.

While they're doing that, they're reading Norman, Cooper, Snyder, and
other resources, delving more deeply into the cognitive and practical
aspects of UI design. They're going to be looking at all of your
projects over the coming week, and will likely begin contacting some
of you next week to ask questions and express interest in working with
you.

In short, this note is a heads up as to what we've been up to, and
where we're going next. I'm sorry I didn't write sooner, but I've been
doing a lot of community interaction/bridging myself these past two
weeks. The students are engaged, and the knowledge that they will be
working with real projects has, I think, really focused their efforts
so far.

Please feel free to ask me questions. Mostly, I think you can continue
to sit back and wait for students to come your way. So, again: thank
you!

Cheers,
Matt

PS. Given that we only have 10 students in the class, the fact is that
we won't be able to work with most of the projects that responded.
That said, I'm going to push to see if I can get this course
cross-listed with our Psychology department, and perhaps get it to run
more often. Or, perhaps I'll look at ways I can do something that
blends our local instruction with P2PU. Either way, it is clear that
there are a lot of great opportunities to introduce students to open
communities around the theme of usability.

[1] 
http://www.sububi.org/2010/08/18/free-interaction-design-for-your-open-source-project/
[2] http://rockalypse.org/courses/cmpsc303f10/projects/
[3] http://wiki.rockalypse.org/HCD


-- 
Regards Jon Nordby - www.jonnor.com

___
Mypaint-discuss mailing list
Mypaint-discuss@gna.org
https://mail.gna.org/listinfo/mypaint-discuss