Replace image background [closed]

asked 2019-05-16 03:35:15 -0600

tobia gravatar image

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

edit retag flag offensive reopen merge delete

Closed for the following reason not a real question by berak
close date 2019-05-16 03:38:51.946562

Comments

please take a look at opencv's existing tutorials, it's all in there.

there are also tons of samples to detect a rectangle (e.g. on this site). please search, and try something on your own before asking, right now, we cannot really help you.

berak gravatar imageberak ( 2019-05-16 03:42:19 -0600 )edit
1

Thanks Berak, I'm sorry! I didn't mean to waste anyone's time! I know how to detect rectangles but the problem is quite mode complex and I just hoped that more experienced developers could point me in the right direction. I apologize!

tobia gravatar imagetobia ( 2019-05-16 12:02:10 -0600 )edit