Weighted adjacency matrix of an image using energy function

Creates a weighted adjacency matrix from an energy matrix for an image. Average, similarity, and dissimilarity between the nodes i,j.
22 Downloads
Updated 26 Mar 2024

Weighted adjacency matrix of an image

View Weighted adjacency matrix of an image using energy function on File Exchange Open in MATLAB Online

Creates a weighted adjacency matrix from a energy matrix (E) for an image. Average, similarity and dissimilarity between the nodes i,j can be computed. If a custom energy matrix is provided, the same functions can be used to fill the adjacency matrix with edge weights.

Graphs table

Type Images
4-noded unidirection fig_4noded_1
4-noded bidirection fig_4noded_2
8-noded, six edges, vertical and cross directions fig_6noded_shortpath
8-noded, eight edges, unidirection fig_8noded_1
8-noded, eight edges, bidirection fig_8noded_2

Requirements

MATLAB

Run command

Please use the demo.m to run the program.

Change the hyper parameters accordingly if needed.

% Inputs
h = 3; w = 6;                       % Image size [height x width]
edgeDirection = 1;                  % Edge direction 1 - uni | 2 - bi
noded = 8;                          % Nodes 4-noded, 6-direction, 8-noded (pixels)
weight_type = 'Average';            % Average (E(i), E(j)) / 2 
                                    % Similarity (E(i) - E(j)) 
                                    % Dissimilarity 1 / (E(i) - E(j)).
                                    % Where E is the energy at node i, j.
flowDirection = 'col_wise';         % 'row_wise' | 'col_wise'

Known issues

  1. Sometimes plot(G) or plot(G,'Layout','force') produces strange looking graphs.

Adaptation of open source

Some of the MATLAB adjacency functions are adapted from the Stack Overflow.

Feedback

Please rate and provide feedback for the further improvements.

Cite As

Preetham Manjunatha (2024). Weighted adjacency matrix of an image using energy function (https://github.com/preethamam/Weighted-Adjacency-Matrix-of-Image/releases/tag/1.3.3), GitHub. Retrieved .

MATLAB Release Compatibility
Created with R2022a
Compatible with any release
Platform Compatibility
Windows macOS Linux

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!
Version Published Release Notes
1.3.3

See release notes for this release on GitHub: https://github.com/preethamam/Weighted-Adjacency-Matrix-of-Image/releases/tag/1.3.3

1.3.2

See release notes for this release on GitHub: https://github.com/preethamam/Weighted-Adjacency-Matrix-of-Image/releases/tag/1.3.2

1.3.0

See release notes for this release on GitHub: https://github.com/preethamam/Weighted-Adjacency-Matrix-of-Image/releases/tag/1.3.0

1.0.1

See release notes for this release on GitHub: https://github.com/preethamam/Weighted-Adjacency-Matrix-of-Image/releases/tag/1.0.1

1.0.0

To view or report issues in this GitHub add-on, visit the GitHub Repository.
To view or report issues in this GitHub add-on, visit the GitHub Repository.