Borrar filtros
Borrar filtros

How to plot a 2D histogram of pixel pairs ?

3 visualizaciones (últimos 30 días)
Shounak Shastri
Shounak Shastri el 30 de Mzo. de 2014
Respondida: Image Analyst el 30 de Mzo. de 2014
I have a 'M by 2' matrix consisting of pixel pairs in an image. I want to find which pixel pairs occur more frequently. For this I need to plot a 2D histogram. Any suggestions ?

Respuestas (2)

Azzi Abdelmalek
Azzi Abdelmalek el 30 de Mzo. de 2014
This looks like the previous question
If you can find the frequency of each pair, then you can find the most frequent one.
A=[1 2;3 4;1 2;5 6;1 2;5 6]
[ii,jj,kk]=unique(A,'rows')
f=histc(kk,1:numel(jj))
[a,idx]=max(f)
out=[ii(idx,:) a]

Image Analyst
Image Analyst el 30 de Mzo. de 2014
There is a special function made to exactly that. It's called graycomatrix() and is in the Image Processing Toolbox. It calculates what is called the Gray Level Cooccurrence Matrix. The GLCM is what you called the 2D histogram. My demo script is attached below in blue text. I show the GLCM as a 2D image, like a heat map.

Categorías

Más información sobre Histograms en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by