Merge branch 'master' of github.com:jeena/catdog
This commit is contained in:
commit
b038d89d7e
1 changed files with 3 additions and 3 deletions
|
@ -32,7 +32,7 @@ Then I cut out all the drawings from the big image and saved them as a black and
|
|||
|
||||
## 2.3. Resizing
|
||||
|
||||
I wrote a small shellscript which would take all pictures and resize them proportionally to a max width and height of 200 px. It also fills up the missing borders with a white background color. To do that I used the [ImageMagick suite](www.imagemagick.org) software suite:
|
||||
I wrote a small shellscript which would take all pictures and resize them proportionally to a max width and height of 200 px. It also fills up the missing borders with a white background color. To do that I used the [ImageMagick](www.imagemagick.org) software suite:
|
||||
|
||||
<pre>#!/bin/sh
|
||||
|
||||
|
@ -95,7 +95,7 @@ I also extracted the amount of black pixels in the image to use it as a possible
|
|||
# 4. _k_-nearest neighbor algorithm
|
||||
|
||||
I chose to use the _k_-Nearest Neighbors algorithm which only locally looks at the neighbors of the document in a radius predefined by the user. It assumes that the document is of the same category as the highest number of neighbors within this radius.
|
||||
In the following figure you can see that depending if the user choses k = 3, as showed by the solid line, the algorithm will conclude that the document in the center (green smiley) is of the type triangle because most of this three neighbors are triangles. If on the other hand the user choses k = 7, as showed by the dotted line, then the amount of neighbors which are rectangles is greater as the amount of neighbors which are triangles, so it concludes that the smiley is of type rectangle.
|
||||
In the following figure you can see that depending if the user choses k = 3, as showed by the solid line, the algorithm will conclude that the document in the center (green smiley) is of the type triangle because most of this three neighbors are triangles. If on the other hand the user choses k = 7, as showed by the dotted line, then the amount of neighbors which are rectangles is greater as the amount of neighbors which are triangles, so it concludes that the smiley is of type rectangle.
|
||||
|
||||

|
||||
|
||||
|
@ -207,4 +207,4 @@ And then it would be interesting to use this approach on photos of real cats and
|
|||
d, i = tree.query(test_features[t], k=3)
|
||||
print "-"
|
||||
for j in xrange(0, len(i)):
|
||||
print test_labels[t] + " is a " + labels[i[j]]
|
||||
print test_labels[t] + " is a " + labels[i[j]]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue