quantize tree walking mistake for RiemersmaDither

Questions and postings pertaining to the development of ImageMagick, feature enhancements, and ImageMagick internals. ImageMagick source code and algorithms are discussed here. Usage questions which are too arcane for the normal user list should also be posted here.
Post Reply
User avatar
yoya
Posts: 4
Joined: 2013-07-11T21:55:26-07:00
Authentication code: 6789
Location: Japan

quantize tree walking mistake for RiemersmaDither

Post 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
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: quantize tree walking mistake for RiemersmaDither

Post 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.
Post Reply