I have an image that I would like to use to make a graph. Pixels are the nodes and edges represents 8-neighbourhood. I tried this

I=imread('cameraman.tif');

[X Y]=size(I);

CONNECTED = 8; %# 4-/8- connected points

%# which distance function

if CONNECTED == 4, distFunc = 'cityblock';

elseif CONNECTED == 8, distFunc = 'chebychev'; end

%# compute adjacency matrix

[X Y] = meshgrid(1:N,1:M);

X = X(:); Y = Y(:);

adj = squareform( pdist([X Y], distFunc) == 1 );

got error as

Error in pdist (line 252)

Y = pdistmex(X',dist,additionalArg);

Error in gra (line 12)

adj = squareform( pdist([X Y], distFunc) == 1 );

More Leena Silvoster's questions See All
Similar questions and discussions