Semester assignments for the course "Digital Image Processing" of THMMY in AUTH university.
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
|
function myAffinityMat = Image2Graph (imIn)
|
|
|
|
%Image2Graph produces a graph, in the form of a matrix, from an image
|
|
|
|
% Usage myAffinityMat = Image2Graph (imIn), where:
|
|
|
|
% Inputs
|
|
|
|
% - imIn is the input image
|
|
|
|
% Output
|
|
|
|
% - myAffinityMat is the graph produced
|
|
|
|
|
|
|
|
% Initializes helper variables
|
|
|
|
imageWidth = size(imIn, 2);
|
|
|
|
imageHeight = size(imIn, 1);
|
|
|
|
imageChannels = size(imIn, 3);
|
|
|
|
|
|
|
|
% Produces the matrix
|
|
|
|
singleLineTransform = reshape(imIn, 1, [], imageChannels);
|
|
|
|
myAffinityMat = 1 ./ exp( ...
|
|
|
|
sum(( ...
|
|
|
|
repmat(singleLineTransform, imageWidth * imageHeight, 1, 1) - ...
|
|
|
|
permute(singleLineTransform, [2 1 3])) ...
|
|
|
|
.^ 2, 3) ...
|
|
|
|
.^ 0.5);
|
|
|
|
end
|