1

I have scanned copies of currency notes from which I need to extract only the rectangular notes. Although the scanned copies have a very blank background, the note itself can be rotated or aligned correctly. I'm using matlab.

Example input:

enter image description here

Example output:

enter image description here

I have tried using thresholding and canny/sobel edge detection to no avail. I also tried the solution given here but it detects the entire image for cropping and it would not work for rotated images.

PS: My primary objective is to determine the denomination of the currency. There are a couple of methods I thought I could use:

  1. Color based, since all currency notes have varying primary colors. The advantage of this method is that it's independent of the rotation or scale of the input image.
  2. Detect the small black triangle on the lower left corner of the note. This shape is unique for each denomination.
  3. Calculating the difference between 2 images. Since this is a small project, all input images will be of the same dpi and resolution and hence, once aligned, the difference between the input and the true images can give a rough estimate.

Which method do you think is the most viable?

Community
  • 1
  • 1
vinayakshukl
  • 313
  • 3
  • 17
  • If each currency has an own color then go for colour based, looks like the most robust one. If you go for this you may even not need to crop the image! – Ander Biguri Oct 27 '14 at 10:36
  • I thought so. But I could use the other methods as a comparative study to show the differences in accuracy between the methods. Any idea on that? – vinayakshukl Oct 27 '14 at 10:39
  • Well, you can do that, that would be a good project ;). About taking out the white: try the method you linked (even with rotated images). Probably you can, after removing practically all the background, rotate the image if you detect the 4 corners. – Ander Biguri Oct 27 '14 at 10:41
  • Okay. I used thresholding, median filter and a slight crop to get this: http://imgur.com/dGnq07Z How do find the angle by which to rotate the boundary box? – vinayakshukl Oct 27 '14 at 10:45

1 Answers1

3

It seems you are further advanced than you looked (seeing you comments) which is good! Im going to show you more or less the way you can go to solve you problem, however im not posting the whole code, just the important parts.

You have an image quite cropped and segmented. First you need to ensure that your image is without holes. So fill them!

Iinv=I==0; % you want 1 in money, 0 in not-money;
Ifill=imfill(Iinv,8,'holes');     % Fill holes

After that, you want to get only the boundary of the image:

Iedge=edge(Ifill);

And in the end you want to get the corners of that square:

C=corner(Iedge);

Now that you have 4 corners, you should be able to know the angle of this rotated "square". Once you get it do:

Irotate=imrotate(Icroped,angle);

Once here you may want to crop it again to end up just with the money! (aaah money always as an objective!)

Hope this helps!

Ander Biguri
  • 35,140
  • 11
  • 74
  • 120
  • 1
    Thanks for your answer! It seemed to work pretty well but there was a slight problem - I tried to work it out but it still remains. I'll post in detail tomorrow morning. Thanks for the help! – vinayakshukl Oct 27 '14 at 16:33
  • The corner function finds many corners in the image, out of which only 4 are the correct ones. The reason for this is that the edge detection done before this function call returns a very wavy and 'edgey' contour. When I try to find the 4 true corners using max_x, max_y etc, I get good results for the tilted inputs but not for aligned inputs due to the wavy nature of the edges. Example: http://imgur.com/a/k9SxD Red are all corners, blue are the 4 true ones detected. – vinayakshukl Oct 28 '14 at 05:47
  • @vinayakshukl Interesting problem.... I suggest you to smooth the Iedge image using LoG or gaussian filter, to see of those corners are a bit smoothed. You can also try dilate and erode to see if you get smoother images. Hoowever, your problem seems very suitable for another SO question! so, if this suggestions dont work, I reccomend you to open a question with the specific problem of the corners! – Ander Biguri Oct 28 '14 at 10:23