simple image recognition

Today, we use similar[op] for simple image recognition. Simple in that we don't need to do any normalizations for it to work. We don't need to translate, rotate, magnify, or otherwise align. And we restrict our pixel values to 0 or 1 (though that is not important, coeffs not in {0,1} should be fine too).

Here are our images:
|letter: H>
#   #
#   #
#   #
#####
#   #
#   #
#   #

|noisy: H>
    #
#   #
#   #
### #
#    
#   #
#   #

|noisy: H2>
#   #
#    
# ###
#####
##  #
#   #
### #

|letter: I>
#####
  #
  #
  #
  #
  #
#####

|noisy: I>
####
  #
  
  
  #
  #
# ###

|noisy: I2>
##  #
 ###
  #
  #
  ###
####
#####

|letter: O>
######
#    #
#    #
#    #
#    #
#    #
######
Now, load these into the console, and have a play.
-- load up the data:
sa: load H-I-pat-rec.sw

-- save some typing:
sa: |list> => relevant-kets[pixels] |>

-- do some processing: 
sa: simm |*> #=> 100 self-similar[pixels] |_self>
sa: drop-simm |*> #=> drop-below[60] 100 self-similar[pixels] |_self>
sa: tidy-simm |*> #=> set-to[100] drop-below[0.6] self-similar[pixels] |_self>
sa: map[simm,similarity] "" |list>
sa: map[drop-simm,drop-similarity] "" |list>
sa: map[tidy-simm,tidy-similarity] "" |list>

-- now check the results:
sa: matrix[similarity]
[ letter: H ] = [  100.00  29.41   40.91   82.35   76.19   17.65   35.00   ] [ letter: H ]
[ letter: I ]   [  29.41   100.00  45.45   26.67   38.10   73.33   65.00   ] [ letter: I ]
[ letter: O ]   [  40.91   45.45   100.00  36.36   50.00   36.36   40.91   ] [ letter: O ]
[ noisy: H  ]   [  82.35   26.67   36.36   100.00  61.90   14.29   25.00   ] [ noisy: H  ]
[ noisy: H2 ]   [  76.19   38.10   50.00   61.90   100.00  19.05   47.62   ] [ noisy: H2 ]
[ noisy: I  ]   [  17.65   73.33   36.36   14.29   19.05   100.00  45.00   ] [ noisy: I  ]
[ noisy: I2 ]   [  35.00   65.00   40.91   25.00   47.62   45.00   100.00  ] [ noisy: I2 ]

sa: matrix[drop-similarity]
[ letter: H ] = [  100.00  0       0       82.35   76.19   0       0       ] [ letter: H ]
[ letter: I ]   [  0       100.00  0       0       0       73.33   65.00   ] [ letter: I ]
[ letter: O ]   [  0       0       100.00  0       0       0       0       ] [ letter: O ]
[ noisy: H  ]   [  82.35   0       0       100.00  61.90   0       0       ] [ noisy: H  ]
[ noisy: H2 ]   [  76.19   0       0       61.90   100.00  0       0       ] [ noisy: H2 ]
[ noisy: I  ]   [  0       73.33   0       0       0       100.00  0       ] [ noisy: I  ]
[ noisy: I2 ]   [  0       65.00   0       0       0       0       100.00  ] [ noisy: I2 ]

sa: matrix[tidy-similarity]
[ letter: H ] = [  100.00  0       0       100.00  100.00  0       0       ] [ letter: H ]
[ letter: I ]   [  0       100.00  0       0       0       100.00  100.00  ] [ letter: I ]
[ letter: O ]   [  0       0       100.00  0       0       0       0       ] [ letter: O ]
[ noisy: H  ]   [  100.00  0       0       100.00  100.00  0       0       ] [ noisy: H  ]
[ noisy: H2 ]   [  100.00  0       0       100.00  100.00  0       0       ] [ noisy: H2 ]
[ noisy: I  ]   [  0       100.00  0       0       0       100.00  0       ] [ noisy: I  ]
[ noisy: I2 ]   [  0       100.00  0       0       0       0       100.00  ] [ noisy: I2 ]
So, a nice simple proof of concept example, but it successfully classifies letters into the right groups. H with H, I with I, and O by itself.

A more interesting example coming up!

Update: I guess it would be instructive to see what we have at the superposition level:
similarity |letter: H> => 100.000|letter: H> + 82.353|noisy: H> + 76.190|noisy: H2> + 40.909|letter: O> + 35.000|noisy: I2> + 29.412|letter: I> + 17.647|noisy: I>
drop-similarity |letter: H> => 100.000|letter: H> + 82.353|noisy: H> + 76.190|noisy: H2>
tidy-similarity |letter: H> => 100.000|letter: H> + 100.000|noisy: H> + 100.000|noisy: H2>

similarity |noisy: H2> => 100.000|noisy: H2> + 76.190|letter: H> + 61.905|noisy: H> + 50.000|letter: O> + 47.619|noisy: I2> + 38.095|letter: I> + 19.048|noisy: I>
drop-similarity |noisy: H2> => 100.000|noisy: H2> + 76.190|letter: H> + 61.905|noisy: H>
tidy-similarity |noisy: H2> => 100.000|noisy: H2> + 100.000|letter: H> + 100.000|noisy: H>

similarity |letter: I> => 100.000|letter: I> + 73.333|noisy: I> + 65.000|noisy: I2> + 45.455|letter: O> + 38.095|noisy: H2> + 29.412|letter: H> + 26.667|noisy: H>
drop-similarity |letter: I> => 100.000|letter: I> + 73.333|noisy: I> + 65.000|noisy: I2>
tidy-similarity |letter: I> => 100.000|letter: I> + 100.000|noisy: I> + 100.000|noisy: I2>

similarity |letter: O> => 100.000|letter: O> + 50.000|noisy: H2> + 45.455|letter: I> + 40.909|letter: H> + 40.909|noisy: I2> + 36.364|noisy: H> + 36.364|noisy: I>
drop-similarity |letter: O> => 100.000|letter: O>
tidy-similarity |letter: O> => 100.000|letter: O>



Home
previous: some simple similar op examples
next: new function such that

updated: 19/12/2016
by Garry Morrison
email: garry -at- semantic-db.org