Skip to main content

Posts

Showing posts with the label opencv

Finding promising releases for fixing (part 2)

Time to bring two topics together: finding promising releases for fixing and image processing. The first topic I wrote about in this post , the second topic I wrote about in a series of posts, ending with a large test of images of a specific Spanish label . I specifically focused on cherry picking the releases with 1 image to see if that image contained a label. I found 1299 releases with 1 image for this label and compared it with the releases that I found a label for. The results were, as expected, very poor: for only 9 releases with 1 image the image was actually a label. Of these a few already had the right depósito legal information on the release page (and I hadn't filtered for that this time), some had already been updated and others didn't show the label with the depósito legal information on it, but the label of the other side. Still I would consider this a resounding success, because now I don't have to look at the 1290 other releases, but can very efficient...

Label detection: testing with a large collection of images

In the past few weeks I have been experimenting a bit with OpenCV and other techniques to find out if  pictures contain labels and wrote about that ( part 1 , part 2 , part 3 , part 4 , part 5 and part 6 ). As you know the proof of the pudding is in the eating and I do like pudding, so I decided to run a test to see if I could say if an image has a label on it, or could not say it (so basically the result is "has label" or "don't know if there is a label"), as up until now I had only tested with about 30 images. I wanted to keep my test small because of time constraints (I still need to add multiprocessing to my labeling script) but big enough to draw interesting conclusions I chose one particular Spanish label called Belter . This is not because I like the music they released but just one that I encountered many times and that has a rather simple clean label design, so it seemed like a good candidate, although it could also mean that my results need to be...

Using image processing to automatically detect labels (part 6)

It is time to wrap up my quest to automatically detect labels from images in Discogs. If you haven't read it yet, I highly advise reading the previous post for more background information. In the previous post I explained about edge detection and finding the outer edge. What I did next is that I cropped the image, adapted the size of the mask and then used my proven method with histograms on the cropped image. The complete method that I use is like this: use a donut shaped mask and compute histograms to see if there is a label (only works for perfectly cropped and centered images of labels) if no label was found try to detect outer edges if only one outer edge is found, crop the image, resize the donut shaped mask and try the histogram method again Step 2 and 3 are actually repeated several times for different values of the size of the kernel used for blurring. For my extremely small set of test images this method allows me to correctly find an extra two labels that I ...

Using image processing to automatically detect labels (part 5)

I wanted to dig a bit further into image processing and seeing what else I could do to automatically detect labels. Please read part 1 , part 2 , part 3 and part 4 first, if you haven't already. My previous methods focused on histograms using masks but this only works well if the image is perfectly centered and cropped properly. This is not always the case, as I already showed in the last articles. It would work better if I knew where the label would be in the image, so I can create a different mask for the right part of the image and then work with histograms. Detecting where a label starts can be done with edge detection. This should work in most cases, because the label has a different colour than the vinyl. In OpenCV there are various ways to detect outer edges and I am going to use the " Canny edge detector ". For this I first translate the image to greyscale, and then run the edge detector (for the threshold values I used 40 and 200). For one of my testing i...

Face detection for record sleeves

I have been digging a bit into image processing in the last few weeks using OpenCV. OpenCV is very powerful and comes with lots of built-in goodies, such as a face detector. So, I was thinking: what can I do with that? How easy is it to detect sleeves that have people's faces on it? As it turns out: trivial. I grabbed my copy of Practical Python and OpenCV and followed chapter 14. I then downloaded an image and fed it to my code: Not perfect as only three out of four faces get recognized, probably due to a limitation in the classifier but not bad at all for less than 50 lines of Python code. Another example: So, why is this useful? Let's make this a bit more concrete with another example. Some users collect sleeves with a certain theme. One possible theme could be cats. At least one user at Discogs has a list with sleeves that have cats on them . And, believe it or not, OpenCV also has a built-in cat classifier (for frontal cat faces only), so I used that on one...

Using image processing to automatically detect labels (part 4)

This is the last blog post (at least for now) about using image processing to automatically detect labels of 7" singles. It is advised to first read part 1 , part 2 and part 3 before reading this post. In my previous blog post I looked at histogram comparisons and for my test image that worked really well. In this post I am going to look at how well it worked on some other images. The first label image that I tried: a Wham! promo single with an (almost) white label, with a perfect white circle around it (either a very good scanner, or the uploader cut the label from the scan), so I was not expecting a lot. The masked versions look like this: I was expecting quite a bad result here, but the comparison for the full image is: correlation: 0.07351815513756556 chi squared: 15.131605789349916 intersection: 0.08877012991160882 Bhattycharyya distance: 0.8772594089938355 That is even better than with my test image, which puzzles me to be honest. The next image ...

Using image processing to automatically detect labels (part 3)

Finally getting to the meat of using image processing to detect labels automatically. For background information you should first read part 1 and part 2 before reading this. Just computing a histogram won't get me very far. For it to be useful I need to compare it to something. As said what I will do is to compare one part of the image (where I think the label is) with the rest of the image, minus the center hole as that isn't part of the record. The idea is that the overlap between the two will be minimal, but possibly not in the cases where the vinyl and the label have the same colour, or a similar colour. With OpenCV there are built in functions to compare these and basically what I did is follow this blog post at PyImageSearch about comparing histograms and used it on my test images. After computing the histograms (32 buckets) I computed the four types of histogram comparisons from the PyImageSearch post for the red, green and blue channels, as well as the full ima...

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

Using image processing to automatically detect labels (part 1)

One thing that I don't like about Discogs is that the images in the database are not tagged with metadata about the contents. It would be a lot easier if I would know if an image is a label, or a sleeve, or something else. I actually talked about this before , but so far my suggestion hasn't been picked up yet. One of the reasons for it is that it would help my quest for finding promising candidates for fixing releases and I don't have to actually click on a release to then find out that there is no label image. It is a really repetitive process, so I wanted to see how easy it is to automatically identify that an image contains a label. The quality of the images in Discogs varies a lot, but typically good quality images are (at least) 600x600. At least a few years ago images were automatically scaled which confused people, as they uploaded what they thought were "better images" only to seem them scaled to the same dimensions! I picked a release from Discogs...