Created
January 10, 2018 08:24
-
-
Save JakubMifek/abe41779e566be5cee5d04396caa53d3 to your computer and use it in GitHub Desktop.
Matlab function for creating Hopfield network from an image containing the alphabet
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function [input network] = CreateNetwork( path, width, height ) | |
%CREATENETWORK Summary of this function goes here | |
% Detailed explanation goes here | |
img = imread(path); | |
img = 1-im2double(img(:,:,1)); | |
img = img == 1; | |
colormap(gray); | |
img = 1-img; | |
imagesc(img); | |
tileW = size(img, 2) / width; | |
tileH = size(img, 1) / height; | |
cols = (im2col(img, [round(tileH) round(tileW)],'distinct')); | |
input = unique(cols', 'rows', 'stable')'; | |
T = input * 2 - 1; | |
network = newhop(T); | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment