How to solve this error?

1 次查看(过去 30 天)
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;

采纳的回答

KALYAN ACHARJYA
KALYAN ACHARJYA 2019-10-12
编辑:KALYAN ACHARJYA 2019-10-12
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)

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Use COM Objects in MATLAB 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by