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.

Respuestas (1)

Azzi Abdelmalek
Azzi Abdelmalek el 14 de Mzo. de 2013

0 votos

Use Image From File block

5 comentarios

Ahmed A. Selman
Ahmed A. Selman el 14 de Mzo. de 2013
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.
Kaustubha Govind
Kaustubha Govind el 15 de Mzo. de 2013
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 :)
Kaustubha Govind
Kaustubha Govind el 18 de Mzo. de 2013
You might want to read the documentation on using structures in the MATLAB Function block to resolve the errors.
Ahmed A. Selman
Ahmed A. Selman el 19 de Mzo. de 2013
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.

Iniciar sesión para comentar.

Categorías

Más información sobre Simulink en Centro de ayuda y File Exchange.

Etiquetas

Preguntada:

el 14 de Mzo. de 2013

Community Treasure Hunt

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

Start Hunting!

Translated by