1
$\begingroup$

I work with python and images of tables (taken from above). My aim is to take a photo of a random table and then find the most similar tables to it in my database. By most similar I mean tables of similar shape(square, rectangular, round, oval), texture, colour etc.

For now, I am just running a PCA and then a KNN on all the pixels of rgb images of tables to let my computer find the most similar ones among them. Obviously the k-nearest neighbours of a table image must be images with tables which are very similar to it. The images are common images of tables and are of 529x940 dimensions.

My final goal is to run this program with 2000 or even 4000 table images so I need a more efficient machine learning algorithm for my task than the PCA and the KNN.

Can you recommend me another more efficient machine learning algorithm for this task? Is Support Vector Machine significantly or Histogram of Gradient better for this task?

$\endgroup$
  • $\begingroup$ Have you looked a convolutional neural network? These nets recognize cats, dogs, faces- basically image patterns - Lots of tools available too!, Given there is enough data, L2 regularization, and so on, can be done during training $\endgroup$ – user3483902 Feb 1 '18 at 6:18
  • $\begingroup$ Thank you for your response. Yes, I had them in mind obviously but I did not want to go into them without trying throughly some simple machine learning algorithms. $\endgroup$ – Outcast Feb 1 '18 at 9:44
1
$\begingroup$

One possible approach is to train a classifier that, given a table, outputs its shape; train a classifier that, given a table, outputs its texture; train a classifier that, given a table, outputs its colour; and so on for each of the feature values you care about. Thus, given a table, you can compute a feature vector that has the value of each of these attributes. You can then define a distance metric on these feature vectors (e.g., some kind of weighted L2 distance), which will let you measure how similar two tables are by comparing their feature vectors.

Once you've done this, there's a straightforward way to find the most similar tables. Use the classifiers to find the feature vectors for all the tables. Then, use k-nearest neighbors to find the k most similar images to each given image. If the number of features is not too large, this should be efficient, as you are now doing k-NN in a low-dimensional space. For instance, you can use k-d trees or other data structures for nearest neighbor search to speed up the search. These data structures are a lot more efficient when the number of dimensions is small.

I expect this should be plenty efficient for your needs. Handling 4000 table images should be no problem.

There are other possible approaches as well, but the above is the first thing I'd try.

$\endgroup$
  • $\begingroup$ Thank you for your interesting answer. Yes, I had this procedure/algorithm in my mind from the beginning. However, I was thinking if I can get similar results without training any separate classifiers (shape, texture, colour) but by using one machine algorithm like KNN to find the most similar images which will implicitly include features like shape, texture, colour. This is why I asked if other machine learning algorithms are significantly better because KNN is not in this approach. But perhaps finally I should follow what you also suggest. $\endgroup$ – Outcast Feb 1 '18 at 9:57
  • $\begingroup$ Then following your answer, I would ask the following: which machine learning algorithm do you suggest for the shape, texture, colour classifiers (if not a KKN or a SVM classifier)? $\endgroup$ – Outcast Feb 1 '18 at 11:49
  • $\begingroup$ @Universalis, OK. For the future, if you already have considered an approach but have rejected it for some reason, I would encourage you to describe that in the question from the start, so that we don't waste your time and ours by typing up something you are not interested in. I can only answer the question that was asked. For learning shape, texture, etc., I would suggest trying a convolutional neural network as the first thing to try. There are undoubtedly many other possibilities as well, but that's what I would suggest trying first. $\endgroup$ – D.W. Feb 1 '18 at 16:25
  • $\begingroup$ Ok @D.W., I agree with your suggestion to me and thanks for your additional answers. $\endgroup$ – Outcast Feb 1 '18 at 16:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.