hi every body. I am trying to use nmi.m which is attached below and downloaded from mathworks to calculate normalized mutual information between to images.
x=rgb2gray(imread('a.jpg'));
y=rgb2gray(imread('b.jpg'));
z = nmi(x, y);
but i have this error:
Error using sparse
Index into matrix must be an integer.
Error in nmi (line 19)
Mx = sparse(idx,x,1,n,k,n);
could anyone solve this error for me?

댓글 수: 6

Walter Roberson
Walter Roberson 2020년 4월 4일
After you create x and y, please show class(x) and class(y), and also min(unique(diff([x(:);y(:)])))
hello sir, thanks for your respond. you mean this?
x=rgb2gray(imread('a.jpg'));
y=rgb2gray(imread('b.jpg'));
class(x)
class(y)
min(unique(diff([x(:);y(:)])))
z = nmi(x, y);
the class of x and y is uint8
What showed up for
min(unique(diff([x(:);y(:)])))
?
Also please show min(x(:)), max(x(:))
talayeh ghodsi
talayeh ghodsi 2020년 4월 4일
> min(unique(diff([x(:);y(:)])))
ans =
uint8
0
> min(x(:)), max(x(:))
ans =
uint8
0
ans =
uint8
255
Replace
x = x-l+1;
y = y-l+1;
with
x = double(x-l+1);
y = double(y-l+1);
talayeh ghodsi
talayeh ghodsi 2020년 4월 4일
thanks sir it works well

댓글을 달려면 로그인하십시오.

답변 (0개)

카테고리

도움말 센터File Exchange에서 Images에 대해 자세히 알아보기

질문:

2020년 4월 4일

댓글:

2020년 4월 4일

Community Treasure Hunt

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

Start Hunting!

Translated by