Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hextree PNG quant too aggressive #2292

Open
springmeyer opened this issue Jul 3, 2014 · 8 comments
Open

Hextree PNG quant too aggressive #2292

springmeyer opened this issue Jul 3, 2014 · 8 comments

Comments

@springmeyer
Copy link
Member

Take this 24bit png:

And run it through Mapnik using hextree quant:

python -c "import mapnik as m;m.Image.open('input.png').save('out.png','png8:m=h')"

and the small blue line in the upper right drops out:

out

Leading to an artifact between tiles like:

Another testcase is from #1987

@springmeyer springmeyer added this to the Mapnik 2.3.0 milestone Jul 3, 2014
@Andrey-VI
Copy link

This bug previously reported here.

@artemp
Copy link
Member

artemp commented Jul 3, 2014

@springmeyer

(((cur_node->reduce_cost / cur_node->pixel_count + 1) * std::log(double(cur_node->pixel_count))) > 15)
- this is the test that cuts off colours. Try changing 15 to 10 and blue line will re-appear but with doubling file size from 103b to 282b.

@springmeyer
Copy link
Member Author

okay, let's hold on this for further thought.

@springmeyer springmeyer removed this from the Mapnik 2.3.0 milestone Jul 29, 2014
@springmeyer
Copy link
Member Author

refs #1990 (comment)

@springmeyer
Copy link
Member Author

noting this is not fixed by #2671 since it is a slightly different problem as @artemp mentions (#2292 (comment))

@springmeyer
Copy link
Member Author

@rcoup - pinging you here as I'm curious whether you are also aiming to fix this or not? I'm recalling now that we held off on this change specifically due to filesize bloat so I'm not sure if it is viable. But I'd welcome attention if you think it is viable.

@rcoup
Copy link
Contributor

rcoup commented Feb 3, 2015

I'd like to fix it - issues like this tend to trip up our safety asserts like "you shouldn't have rendered a blank image here but you somehow did".

Feels like if you have fewer unique colours before hextree-encoding maybe we should throttle back the quantizing aggressiveness? Since PNG compression should work well if there's mostly solid colours in a tile.

Though from a quick read of the code I'm not 100% on why my test image from #2599 (with 2 colours and 1px per colour) doesn't disappear yet the test image from here does - implies maybe the tree creation or cost reduction functions have some edge cases?

/cc @sarametz

@springmeyer
Copy link
Member Author

Feels like if you have fewer unique colours before hextree-encoding maybe we should throttle back the quantizing aggressiveness? Since PNG compression should work well if there's mostly solid colours in a tile.

Definitely agree - I think putting effort into better detecting how to optimally encode/quantize (whether hextree or octree, etc) would be useful.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants