Page 1 of 1

quantize tree walking mistake for RiemersmaDither

Posted: 2013-07-12T02:51:54-07:00
by yoya
I found tree walking mistake for RiemersmaDither function.

* ImageMagick-6.8.6-4/magick/quantize.c

Code: Select all

/*
  Identify the deepest node containing the pixel's color.
*/
node_info=p->root;
for (index=MaxTreeDepth-1; (ssize_t) index > 0; index--)
{
  id=ColorToNodeId(cube_info,&pixel,index);
  if (node_info->child[id] == (NodeInfo *) NULL)
    break;
  node_info=node_info->child[id];
}
node_info=node_info->parent;
/*
  Find closest color among siblings and their children.
*/
p->target=pixel;
p->distance=(MagickRealType) (4.0*(QuantumRange+1.0)*((MagickRealType)
  QuantumRange+1.0)+1.0);
ClosestColor(image,p,node_info->parent);
p->cache[i]=(ssize_t) p->color_number;

It's 2 times walking through parent until ClosestColor, so not siblings but uncle node.
I think L1805 code must be removed.

Code: Select all

node_info=node_info->parent;

ref) my patch at 6.x
- https://github.com/gree/YoyaMagick/comm ... 93af982b4d

Re: quantize tree walking mistake for RiemersmaDither

Posted: 2013-07-12T04:03:29-07:00
by magick
We can reproduce the problem you posted and applied your patch to ImageMagick 6.8.6-5 Beta available by sometime tomorrow. Thanks.