Error using textread:'textread' is not recommended.use 'testscan'instead

1 回表示 (過去 30 日間)
imen daboussi
imen daboussi 2018 年 4 月 28 日
コメント済み: Walter Roberson 2018 年 4 月 28 日
hello,I am using the "textread" function to read this file:
image_files = textread(input_file,'%s');
but i have an error :
Error using textread (line 159)
File not found.
Error in show_results (line 20)
[image_files] = textread('input_file','%s');
and he said that's : 'textread' is not recommended.use 'testscan'instead. any help please .thanks

回答 (1 件)

Ameer Hamza
Ameer Hamza 2018 年 4 月 28 日
This error is happening because of the variable input_file has wrong spelling of filename you want to open, or the file is not placed in the current directory. Use it like this
input_file = 'myFile.txt'; % specify full fine name, along with extension.
image_files = textread(input_file,'%s');
Also, make sure the file named 'myFile.txt' is present in the current directory.
  2 件のコメント
imen daboussi
imen daboussi 2018 年 4 月 28 日
編集済み: Walter Roberson 2018 年 4 月 28 日
I found this code in github : https://github.com/suyogduttjain/fusionseg
And I try To execute This code now :
%1 = appearance model
%2 = motion model
model_type = 1;
if model_type == 1
data_dir = './images/';
input_file = './appearance_image_list.txt';
output_file = './appearance_output_list.txt';
elseif model_type == 2
data_dir = './motion_images/';
input_file = './motion_image_list.txt';
output_file = './motion_output_list.txt';
else
return;
end
image_files = textread(input_file,'%s');
image_prefixes = textread(output_file,'%s');
num_images = length(image_files);
for i = 1:num_images
feature_name = [image_prefixes{i} '_blob_0.mat'];
data = load(fullfile(data_dir, feature_name));
raw_result = data.data;
img = imread(fullfile(data_dir,image_files{i}));
img_row = min(size(img, 1),size(raw_result,1));
img_col = min(size(img, 2),size(raw_result,2));
raw_result = permute(raw_result, [2 1 3]);
probs = raw_result(1:img_row, 1:img_col, :);
[~, mask] = max(probs,[],3);
mask = logical(mask-1);
figure(1);
subplot(2,2,1);
imshow(img);
subplot(2,2,2);
imshow(mask);
title('Object Mask');
subplot(2,2,3);
imagesc(probs(:,:,2));
axis image;
title('Object Probability');
pause;
end
Walter Roberson
Walter Roberson 2018 年 4 月 28 日
is appearance_image_list.txt present in your working directory?

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

カテゴリ

Help Center および File ExchangeConvert Image Type についてさらに検索

タグ

製品

Community Treasure Hunt

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

Start Hunting!

Translated by