I am trying to perfectly recover a binary image from a JPEG-compressed scan of a printout of the image. I'm hoping there are functions in the Matlab Image Processing Toolbox that can help me with this.
I'm asking this out of curiosity, rather than necessity - I would just like to know if there is a good way to do this in Matlab, I don't really need to do it.
More details: I have a PDF document that was created by scanning a paper document. On the paper document was a printout of a binary image. On the real document, the binary image was fairly sharp and clear, with individual pixels clearly identifiable in some regions. On the PDF document, the image was JPEG compressed (or similar) and the pixel edges became blurry, but they are still clearly discernible to a human.
What I've done: I now have a cropped screenshot of the scanned image, which is about three times larger than the original image (which, I believe, was 256x256). I manually identified the corners of this image, and found a transformation that approximately maps the scanned image to a 256x256 grid. The transformation includes a scaling of about 1/3, and a small rotation and translation.
Questions: 1. I'm not sure about the original image dimensions, so is there a good way to figure that out automatically? 2. Is there a clever way to identify the "correct" transformation, taking advantage of the relatively clear pixel edges present in the scanned image? Maybe the transformation and the original size need to be determined simultaneously? 3. What is the best way to implement the simultaneous general transformation and downsampling? 4. Is there some other application or method that can accomplish this with less effort?