2015-01-25 9:23 GMT+01:00 Tavmjong Bah <tavmjong@...8...>:
No. 7 needs an extra step of transforming but a FFT should work
directly
on the others. I imagine there is photography software that can do the
transforming of 7 automatically.
I'm not sure how the transformation would work. If we can determine
the correct transformation of the grid to rectangular form, we can
also sample the pixels in the grid without transforming.
I am not sure why you think FFT won't work on 5. You have the
background
grid which should provide a large amplitude for the grid frequency. Even
without the background, the shading within the pixel is like a sawtooth
function where the grid frequency should still be the largest component.
I did some tests with ImageMagick and it looks like FFT indeed works
even for the harder cases as long as the grid is rectangular, though
the heuristics required to pick the dominant frequency are not yet
obvious to me. I'm also not sure how to omit the border regions (like
in 2). Two cases that seem to fail are large images that are upscaled
so that each pixel is 2x2 and images where the borders between pixels
are slightly blurry, but maybe that's a numerical accuracy problem (I
inspected the FFT images by saving them to PNG and then auto-adjusting
in GThumb, which bumped every non-black pixel to 100% lightness).
FFT should also work on 6. The roughness along the edges of the
cells
shouldn't over-weigh the dominant frequency.
To remove defacement, histogram the color of the pixels within the cell
and take the color bin with the largest component. You can then compare
that value with the value for neighboring cells or other cells in the
drawing as an additional check.
This will work OK when there are no JPEG artifacts or other color
variations within the cell other than the defacement, but in cases
such as 5 the histogram will be fairly flat. I think histogramming the
pixels according to luminosity with some quantization (e.g. 32 levels
of luminosity) and then averaging the pixels in the bin with the
dominant luminosity might work. The obtained value would then be
subject to global color quantization. However, I'm not sure how that
would extend to cases such as 6.
Regards, Krzysztof