Time to look more into histograms and how I can use them to automatically detect if a picture is a label. It is highly advised to first read part 1 before reading this blog post.
By selectively looking at parts of the image and analyzing those it might be possible to make a much better guess.
For example, in the corners of the image I would expect to find dark/black (unless the vinyl was a different colour) and then a circle with usually a handful of colours, and then something in the middle (in this case white, because a scanner was used). One approach to detect this is to slide a square of 100x100 pixels diagonally across the image and then analyze the contents of that square. To visualise that, for the sleeve that would like this:
and for the label that would look like this:
and the expectation would be to have black in squares
1 and 6, and the same colour in squares 2 and 5 (counting from the
upper left corner). Personally I don't think that this is the best approach.
Another approach would be to guess where the label is and only determine the histogram for that, for example, using a square, with the middle cut out:
or using a circle (with the middle cut out):
Using the circle approach is obviously superior!
What I find quite cool is that the label image the circular mask is almost exact: if you didn't know you would not say that a mask had been applied. This should work for any label that has been scanned and cropped properly (which is a challenge in Discogs), as the record industry standardized on just a few formats and dimensions a long time ago and for the labels there are basically only two choices: big hole (the release here) and small hole (almost all 12" records and some 7" records).
So what I could do is apply one of these filters and compare them to the rest of the image. Let me illustrate that by comparing with the inverse of the mask, first for the square:
and then the circles:
although it should be noted that actually the center hole is not very relevant as it is not part of the release, so I am going to leave that one out from now on. Again: the circle approach is much better, so that's what I'm going to use.
More selective histograms
In the first blog post I looked into histograms, but there I was (mostly) looking at the entire image, which in the case of the label is not helpful, as there is usually a lot of other stuff on the picture too (center hole, parts of the record, etc.).By selectively looking at parts of the image and analyzing those it might be possible to make a much better guess.
For example, in the corners of the image I would expect to find dark/black (unless the vinyl was a different colour) and then a circle with usually a handful of colours, and then something in the middle (in this case white, because a scanner was used). One approach to detect this is to slide a square of 100x100 pixels diagonally across the image and then analyze the contents of that square. To visualise that, for the sleeve that would like this:
Sliding a 100x100 pixel square diagonally across an image |
and for the label that would look like this:
Sliding a 100x100 pixel square diagonally across an image |
Another approach would be to guess where the label is and only determine the histogram for that, for example, using a square, with the middle cut out:
or using a circle (with the middle cut out):
Using the circle approach is obviously superior!
What I find quite cool is that the label image the circular mask is almost exact: if you didn't know you would not say that a mask had been applied. This should work for any label that has been scanned and cropped properly (which is a challenge in Discogs), as the record industry standardized on just a few formats and dimensions a long time ago and for the labels there are basically only two choices: big hole (the release here) and small hole (almost all 12" records and some 7" records).
So what I could do is apply one of these filters and compare them to the rest of the image. Let me illustrate that by comparing with the inverse of the mask, first for the square:
and then the circles:
although it should be noted that actually the center hole is not very relevant as it is not part of the release, so I am going to leave that one out from now on. Again: the circle approach is much better, so that's what I'm going to use.
Comments
Post a Comment