i ran this code :
my_folder = 'D:\pcd\tester\ocr\training_set\training_set';
filenames =dir(fullfile(my_folder,'*.bmp'));
total_images = numel(filenames);
input108_2 = [];
se = strel('square', 3);
pad = 2;
%ft =[];
for n = 1 : total_images
fullname = fullfile(my_folder, filenames(n).name);
%our_images = logical(imread(fullname));
rgb = rgb2gray(imread(fullname));
bw = im2bw(rgb, graythresh(rgb));
bw2 = bwareaopen(bw, 15);
%bw2 = padarray(bw2, [pad pad], 'both'); % Adding Pads
iedge = edge(uint8(bw2)); % edge detection operation
imdilate = imdilate(iedge, se); % dilation operation
imfill = imfill(imdilate, 'holes');
our_images = imfill & bw2;
thinImage = bwmorph(our_images, 'thin', Inf); % thinning Operation
%thinImage = thinImage(pad+1:end-1, pad+1:end-1); % Removing Pads
feature = feature_extract(thinImage);
input108_2 = [input108_2; feature'];
end
but i got this error message:
Function 'subsindex' is not defined for values of class 'strel'.
Error in dataTrain (line 17)
imdilate = imdilate(iedge, se); % dilation operation
i'd seen for line that given error. but i think there isn't something wrong with it.
Please someone help me to solve this.
Thanks before

 採用された回答

Rik
Rik 2018 年 12 月 16 日

1 投票

You have overwritten the function imdilate with a variable imdilate. So now, the second time your code gets to that line it tries to subindex the variable imdilate with the iedge and se variables. The easy fix is by using a different name for the variable.
im_dilate = imdilate(iedge, se); % dilation operation
im_fill = im_fill(im_dilate, 'holes');
our_images = im_fill & bw2;

4 件のコメント

Guillaume
Guillaume 2018 年 12 月 16 日
Personally, I use names like dilated_image and filled_image for variable names. Names that are clearly nouns. Function names are usually verbs so there's very little chance of clash between variable names and function names. Plus, it's a lot clearer what's in the variable.
Rik
Rik 2018 年 12 月 19 日
Did this suggestion solve your problem? If so, please consider marking it as accepted answer. It will make it easier for other people with the same question to find an answer. If this didn't solve your question, please comment with what problems you are still having.
Bachtiar Muhammad Lubis
Bachtiar Muhammad Lubis 2018 年 12 月 20 日
yes, thanks a lot rik wisler. i just open this page
Bachtiar Muhammad Lubis
Bachtiar Muhammad Lubis 2018 年 12 月 20 日
thank to you guillaume.

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

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeImage Processing Toolbox についてさらに検索

製品

リリース

R2015b

Community Treasure Hunt

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

Start Hunting!

Translated by