-
Notifications
You must be signed in to change notification settings - Fork 431
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
Applying Matrix zoom flips antialiasing of saved pixmap #1397
Comments
Oooh, just found part of the answer. I don't know why the aliasing flips on zoom, but this looks like it could disable anti-aliasing completely, which is exciting: #467 (comment) Maybe a call out in the get_pixmap() call would help folks find this? |
It does not do that. The real problem is that the rectangle is simply not that precisely defined as to avoid every single non-black pixel at its borders "shining" into the area. When making the pixmap, you should choose If you do this check with that somewhat smaller rect above, you would see these results:
Where dpi is the short form of the Matrix |
BTW the different |
My current approach is to use the standard deviation of the colors, but it's a bit of a pain since I need to average the RGB tuples. The std deviation lets me set a threshold for things that might have a weird pixel here or there. I already limit to a random sample of the first 1,000 pixels, since it can get far too slow on really big images. If there were an |
Confirming:
|
Both the above are implemented as C functions and should be fast enough. This checks a 100 x 100 = 10,000 pixel (white) pixmap: In [6]: pix
Out[6]: Pixmap(DeviceRGB, IRect(100, 100, 200, 200), 0)
In [7]: pix.size
Out[7]: 30088
In [8]: len(pix.samples_mv)
Out[8]: 30000
In [9]: pix.w * pix.h
Out[9]: 10000
In [10]: pix.is_unicolor
Out[10]: True
In [11]: %timeit pix.is_unicolor
32 µs ± 332 ns per loop (mean ± std. dev. of 7 runs, 10000 loops each)
In [12]: |
Yes, that is definitely fast enough. Amazing! |
Resolved by version 1.19.2. |
Just a small follow up here. I switched out my existing approach to this:
And swapped in the new
Some pros/cons:
Anyway, as hoped, it's a nice improvement overall. Thank you! |
There also is a A (probably bad) approximation of this might also be the compressibility ratio |
I am experimenting with the said new method. Otherwise please let me know and I will make a PDF or something. |
Here is a (new) PDF version: There are the following news / changes:
This should be a good replacement for your prior use of random and statistics.
|
New wheels with the new method
|
Wow, this all sounds great. Thank you as always, @JorjMcKie! |
New version 1.19.3 is being uploaded to PyPI. You may want to look at the example code snippet for method |
Describe the bug (mandatory)
I'm dabbling with pixmaps for the first time, and I've found something a bit baffling in the following file:
rectangles_yes.pdf
If you do the following:
You get a file that looks like this:
On a black background at least (if you use Github's dark theme), you can see there are some white/gray lines along the left, top, and bottom, that form anti-aliasing for the rectangle.
Now, if you switch the code above to do a zoom transformation:
You get the zoomed rectangle, but if you look closely, you'll see that it has an left-right flip on the anti-aliasing (it could have a top-bottom flip too, but we wouldn't notice since those are the same):
I was surprised there was any anti-aliasing, let alone that it flipped.
To Reproduce (mandatory)
Use the code and files above.
Expected behavior (optional)
I didn't expect anti-aliasing on this at all, and I definitely didn't expect the zoom to flip it.
Additional context (optional)
This shows up in
pixmap.samples
andpixmap.samples_mv
too.I plan to work around this by just eliminating a few pixels before making the pixmal, but it's all pretty surprising.
Your configuration (mandatory)
Linux, Ubuntu, 64 bit
3.8, 64 bit
1.19.0
The text was updated successfully, but these errors were encountered: