How to solve this error?

1 回表示 (過去 30 日間)
Bajdar Nour
Bajdar Nour 2019 年 10 月 12 日
コメント済み: Bajdar Nour 2019 年 10 月 12 日
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)
  1 件のコメント
Bajdar Nour
Bajdar Nour 2019 年 10 月 12 日
thanks dear it works

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeCell Arrays についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by