This is showing eror. Unrecognized function or variable 'chaincode'. Error in PELATIHAN (line 48) cc(k)= chaincode(G(k)); Please tell me where I am making mistake.

2 Ansichten (letzte 30 Tage)
clc; clear; close all; warning off all;
%%% Proses Pelatihan
% Menetapkan lokasi folder data latih
nama_folder = 'DATA LATIH';
% membaca file citra
nama_file = dir(fullfile(nama_folder,'*.png*'));
% membaca jumlah file
jumlah_file = numel(nama_file);
% menginisialisasi variabel
ciri_latih = zeros(jumlah_file,8);
chain_code = zeros(jumlah_file,8);
% melakukan pengolahan citra terhadap seluruh file
for n = 1:jumlah_file
% membaca file citra
A = imread(fullfile(nama_folder,nama_file(n).name));
%figure, imshow(A)
% RGB to Grayscale
G = rgb2gray(A);
%figure, imshow(B)
% deteksi tepi sobel
C=double(G);
sobelhor = [-1 0 1; -2 0 2; -1 0 1];
sobelver = [-1 -2 -1; 0 0 0; 1 2 1];
I1 = conv2(C,sobelhor,'same');
I2 = conv2(C,sobelver,'same');
D = sqrt((I1.^2)+(I2.^2));
D = uint8(D);
%figure, imshow(D)
% Threshold
E = imbinarize(D,.3);
figure, imshow(E)
% operasi opening
G = bwareaopen(E,100);
figure, imshow(G)
% ekstraksi fitur
cc = cell(1,length(G));
for k = 1:length(G)
cc(k)= chaincode(G(k));
end
chain_code(n,1) = sum(cc{1,1}.code==0);
chain_code(n,2) = sum(cc{1,1}.code==1);
chain_code(n,3) = sum(cc{1,1}.code==2);
chain_code(n,4) = sum(cc{1,1}.code==3);
chain_code(n,5) = sum(cc{1,1}.code==4);
chain_code(n,6) = sum(cc{1,1}.code==5);
chain_code(n,7) = sum(cc{1,1}.code==6);
chain_code(n,8) = sum(cc{1,1}.code==7);
end

Antworten (2)

Abhinaya Kennedy
Abhinaya Kennedy am 22 Aug. 2024
The error "Unrecognized function or variable 'chaincode'" suggests MATLAB can't find the chaincode function. Here's how to resolve it:
  • Check for Function: Ensure chaincode.m exists in your project directory or MATLAB path.
  • Add to Path: If the function file exists, add its directory to the MATLAB path:
addpath('path_to_function_directory');
  • Verify Name: Ensure there are no typos in the function name.
  • Implement Function: If missing, you may need to implement chaincode yourself or obtain it from your project source.
These steps should help you address the error.

Walter Roberson
Walter Roberson am 22 Aug. 2024
chaincode() appears to be the following File Exchange contribution: https://www.mathworks.com/matlabcentral/fileexchange/29518-freeman-chain-code
You need to install it; perhaps using Add-On Explorer.

Kategorien

Mehr zu Image Processing Toolbox finden Sie in Help Center und File Exchange

Produkte


Version

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by