UnBlock is a filter that removes the "blockiness" of heavily or moderately compressed images with statistical approach.
It is spatial filter for blocks with size 8x8.
Like other deblocking filters, Unblock must be applyed before crop (left, top if not mod 8), resize, denoise and other filters which may modify block boudaries.
UnBlock does not require any user input: the algorithm determines which edge transitions are (most likely to be) blocking artifacts by analyzing the image itself. It automatically corrects image as far as possible.
Plugin uses deblocking algorithm and code library developed by John Costella. See his web page for very detailed information. From the original paper:
We don't have the original image, so we can't be sure that there isn't a sharp discontinuity in the original image that happens to lie right on the boundary. If we removed all discrepancies unconditionally, we would automatically blur out any such sharp edge that happens to unfortunately fall in the wrong place. It is impossible to avoid such an error in every possible case, but we can do so statistically. For any given image, the distribution of the magnitudes of the block boundary discontinuity errors will be determined by the amount of compression employed (the "quality factor"). By computing the distribution of boundary discrepancies across the entire image, and comparing it to the distribtuion of "discrepancies" calculated in the interior of the blocks, we can quantify, statistically, the amount to which the compression has introduced block artifacts. Now, what are we to do with these statistical distributions? A reasonable ansatz is that we should reduce each boundary discrepancy by an amount that will make the interior and boundary discrepancy distributions the same, as far as possible.
In my (Fizick) opinion, the algorithm is really good for strong blockiness but is not very safe for weak blockiness - it can partially destroy some thin image details.
Unblock
(clip, bool "chroma", bool "photo", bool "cartoon")
first parameter is the source clip.
chroma - Set this flag to false to not deblock chroma. Default=true.
photo - Set this flag to true if you know for certain that the image is "photographic" (i.e., continuous tone). This tells Unblock to be somewhat more aggressive in removing block artifacts; more accurately, it leans to the "aggressive" side of its statistical confidence interval. Default=false.
cartoon - Set this flag to true if you know for certain that the image is "cartoon-like" (i.e., solid blocks of color with sharp boundaries between them). This tells Unblock to be somewhat less aggressive in removing block artifacts; more accurately, it leans to the "conservative" side of its statistical confidence interval. Default=false.loadplugin("unblock.dll") avisource("g:\test.avi") converttoYV12() unblock(cartoon=true)
doom9 forum at http://forum.doom9.org/showthread.php?t=133059
This plugin is free software released under the GNU GPL license. See file gpl.txt.
Documentation is distributed under CreativeCommons BY-SA 3.0 license.
Please donate for support.
License terms of costella_unblock library:
Copyright © 19892007 John P. Costella.
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software") to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY CLAIM, DAMAGES, OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT, OR OTHERWISE, ARISING FROM, OUT OF, OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Version 1.0 (23.12.2007) - initial
Version 1.1 (25.12.2007) - separately process color planes (a little faster)