get_image more robust

A little better class recognition in get_image()
co-occurrence produces sparse matrix

4D co-occurrence for threshold 255 does not fit in memory. Therefore I
implemented simple sparse matrix variant.