Ask Your Question

Revision history [back]

Replace image background

Hi all,

I'm new to OpenCV and I was wondering if someone could point me in the right direction for a simple program I'm trying to write. Well, the project may not be that simple but it should be simple to explain!

Given the picture of a blocknote, extract the content of the page and put it on a white background.

For example transforms the image on the left into the on on the right:

image description

This picture is a super simple scenario, the notebook does not have lines (which I will need to delete) but I don't need OCR or anything else.

In my mind I would write something like:

  1. identify the rectangle page
  2. delete everything outside the rectangle
  3. identify the color of the page (frequency distribution of colors, the x% most common -> next step)
  4. replace the color of the page with "#ffffff" (eg the 10% most common colors)

Like I said, if you can point me in the right direction would be greatly appreciated! I'm also open to collaboration if anyone is interested!

Thanks, Luca