Azzera filtri
Azzera filtri

How to solve this error?

2 visualizzazioni (ultimi 30 giorni)
Bajdar Nour
Bajdar Nour il 12 Ott 2019
Commentato: Bajdar Nour il 12 Ott 2019
function COM = jcoMatrix(I1) %Declare the function
% coMatrix : co-occurrence matrix
d_i = 0;
d_j = 1;
COM = zeros(256, 256); % Declare the size of the CCM
for i = 1:(size(I1, 1) - d_i)
for j = 1:(size(I1, 2) - d_j)
index_i = I1(i, j) + 1;
index_j = I1(i + d_i, j + d_j) + 1;
COM(index_i, index_j) = COM(index_i, index_j) + 1;
% To calculate the repeatition of pixel value so to generate CCM
end
end
Attempted to access COM(1.01408,2); index must be a positive integer or logical. Error in jcoMatrix (line 13)
COM(index_i, index_j) = COM(index_i, index_j) + 1;

Risposta accettata

KALYAN ACHARJYA
KALYAN ACHARJYA il 12 Ott 2019
Modificato: KALYAN ACHARJYA il 12 Ott 2019
Save the function file in different MATLAB script and ensure that filename must be same as function name, that is jcoMatrix.m
function COM = jcoMatrix(I1) %Declare the function
% coMatrix : co-occurrence matrix
d_i = 0;
d_j = 1;
COM = zeros(256, 256); % Declare the size of the CCM
for i = 1:(size(I1, 1) - d_i)
for j = 1:(size(I1, 2) - d_j)
index_i = I1(i, j) + 1;
index_j = I1(i + d_i, j + d_j) + 1;
COM(index_i, index_j) = COM(index_i, index_j) + 1;
% To calculate the repeatition of pixel value so to generate CCM
end
end
Next call the function from command window or another main MATLAB script by passing input argument I1 (matrix here)

Più risposte (0)

Categorie

Scopri di più su Cell Arrays in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by