Reading multiple image files with Simulink

Is it possible to read multiple image files e.g., the contents of a folder, in Simulink? I need to read a sequence of images from a folder, one at a time.

답변 (1개)

Azzi Abdelmalek
Azzi Abdelmalek 2013년 3월 14일

0 개 추천

Use Image From File block

댓글 수: 5

Thanks for the suggestion, but I meant (sequence of multiple files, automatically file1 then file2 .. then fileN). The image from file block reads a single file each time-- I already tried it.
I've also tried Embedded MATLAB Function and MATLAB Fcn, and Fcn.. All seems to read either single file at each run. If I could have an embedded code to read multiple files, the output generates an error (either must be a single valued or with a non-structured data)...
I can skip this and convert the images into a movie and read it, yet I still wonder if it is possible to do it with a group of image files, using Simulink.
You should be able to use the Embedded MATLAB Function block or MATLAB S-function block to implement your own code that loops through a set of files and reads them. As long as the size of the output doesn't change, this should work. What errors are you seeing exactly?
The error in the case of Embedded M Function is about non structured data output. When tried to have a structure data to read files, then hand-over the info fed in to the output of the function.. the Embedded M Function generates error (structured type data is not allowed). A sample of the code that causes the error is:
% Open files from a whole folder
addpath 'M:\Result_files';
MyFolder = fullfile('M:\Result_files');
MyDirOutput = dir(fullfile(MyFolder,'*.jpg'));
MyFileNames = {MyDirOutput.name}' ; % <------- Here
lfn=length(fileNames); ... etc
and walking around it causes the output to be huge and useless. Of course I took care to add
eml.extrinsic
to declare built-in functions.
As of Level-1 or -2 S Functions, it's a whole new story for me. That's why I thought to ask someone before I spend more time trying to find a solution. Anyway, thanks a lot :)
You might want to read the documentation on using structures in the MATLAB Function block to resolve the errors.
I've solved it. Many thanks to your earlier comment "@Kaustubha Govind: As long as the size of the output doesn't change, this should work". My regards.

댓글을 달려면 로그인하십시오.

카테고리

도움말 센터File Exchange에서 Simulink에 대해 자세히 알아보기

태그

질문:

2013년 3월 14일

Community Treasure Hunt

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

Start Hunting!

Translated by