Skip to main content

Using image processing to automatically detect labels (part 2)

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.

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
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.

Comments

Popular posts from this blog

SID codes (part 1)

One thing that I only learned about after using Discogs is the so called Source Identification Code, or SID. These codes were introduced in 1994 to combat piracy and to find out on which machines a CD was made. It was introduced by Philips and adopted by IFPI, and specifications are publicly available which clearly describe the two available SID codes (mastering SID code and mould SID code). Since quite a few months Discogs has two fields available in the " Barcode and Other Identifiers " (BaOI) section: Mould SID code Mastering SID code A few questions immediately popped up in my mind: how many releases don't have a SID field defined when there should be (for example, the free text field indicates it is a SID field)? how many releases have a SID field with values that should not be in the SID field? how many release have a SID field, but a wrong year (as SID codes were only introduced in 1994) how many vinyl releases have a SID code defined (which is impossi...

SPARS codes (part 1)

Let's talk about SPARS codes used on CDs (or CD-like formats). You have most likely seen it used, but maybe don't know its name. The SPARS code is a three letter code indicating if recording, mixing and mastering were analogue or digital. For example they could look like the ones below. There is not a fixed format, so there are other variants as well. Personally I am not paying too much attention to these codes (I simply do not care), but in the classical music world if something was labeled as DDD (so everything digital) companies could ask premium prices. That makes it interesting information to mine and unlock, which is something that Discogs does not allow people to do when searching (yet!) even though it could be a helpful filter. I wanted to see if it can be used as an identifier to tell releases apart (are there similar releases where the only difference is the SPARS code?). SPARS code in Discogs Since a few months SPARS is a separate field in the Discogs ...

Using matrix numbers of CDs to verify release years (1)

One of the first steps when making CDs is to produce a "glass master". From that (using a few more steps) a "stamper" is created which is then used to press the actual CDs. When looking at a CD you can often see text in a ring in the middle of the CD. This is the so called matrix which comes from the glass master. Apart from the matrix other text (like the IFPI mastering SID code) could possibly also come from the glass master. A bit of background information can be found on page 7 of the IFPI SID code implementation guide although I would also highly recommend watching some of the clips about glass masters on YouTube, which are highly informative. One company making a lot of these glass masters is Cinram . For most of their glass masters they stored the production date in matrix. This is good news, because it means that it could possibly be used to verify releases and see if the declared year of the release is right: it could never have been released before...