1
votes

I constructed a graph based on similarity of adjacent superpixels on an image and consequently I computed its corresponding adjacency (affinity) matrix. I saw several instances of visualization of such matrices as in the following figure.

enter image description here

Is this some type of clustering and how producing such a representation is possible in MATLAB? Is there any specific function or method for that?

Update (Finding): As @Yuval Harpaz suggested, I found that it is some type of Spectral clustering and there is a specific Matlab function for that. Now, the question is how to represent spectral clustering results similar to the OP.

1
So you already have the affinity matrix and you just want to see it as an image? Honestly, that's not what I understood from your original question. See image, imagesc and pcolor. - beaker
As @beaker says, the second figure in your question is likely imagesc(matrix); axis off. Is that what you want? - Ander Biguri
And maybe play around a little bit with colormap. - beaker
You should post some preliminary code here, taking an image such as peppers.png, break it to superpixels, try to implement affinity and let us help to improve your code. Otherwise we'd have to read the paper and write the code from scratch. - Yuval Harpaz

1 Answers

2
votes

You can easily visualize the matrix using imagesc(Affinity_Matrix);

Likely you want the axis off axis off and you may want to change the colormap with colormap(parula) or some of the other available colormap.

Finally, if you want to avoid showing the center diagonal values, you can replace them with zeroes.

You can do that with Affinity_Matrix(eye(size(Affinity_Matrix))==1)=0;

Basically create an identity matrix of the same size and make zero where this identity matrix is one.