Borrar filtros
Borrar filtros

How to solve this error?

2 visualizaciones (últimos 30 días)
Bajdar Nour
Bajdar Nour el 12 de Oct. de 2019
Comentada: Bajdar Nour el 12 de Oct. de 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;

Respuesta aceptada

KALYAN ACHARJYA
KALYAN ACHARJYA el 12 de Oct. de 2019
Editada: KALYAN ACHARJYA el 12 de Oct. de 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)

Más respuestas (0)

Categorías

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

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by