How to input an image from the user in simulink?
2 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
I have a MATLAB script that I want to run in Simulink (by converting it into a MATLAB function). The code I want to run goes like this:

In this script, the input can be taken from the uigetfile(). How can I take the input from the user in Simulink and pass it in this function so that it can be converted into its binary bits?
Just, for more clarification, the block to be used is,

For the input "u", I want to take image input from the user and on the "y", I would like to have it converted into its binary bits (500*500*3 uint8, in my case).
Thanks
0 commentaires
Réponses (1)
Aastha
le 15 Juin 2025
I understand you want to load an image "u" using user input. To achieve this, you can use the "Image From File" block in Simulink, which allows you to read an image from a specified file location and import it into the Simulink workspace. The input file can be a binary image, grayscale image, or color image.
You can set the "Output Data Type" parameter of the "Image From File" block to "uint8" to ensure that the image is output in the desired format.
For more details about the "Image From File" block, you can refer to the MathWorks documentation at: https://www.mathworks.com/help/vision/ref/imagefromfile.html
I hope this helps!
1 commentaire
Walter Roberson
le 15 Juin 2025
The difficulty with this is that it does not directly support user selection of the file. The filename option of the Image From File block is a parameter not a signal.
Possibly the easiest way would be to put the filename selection into some MATLAB code that does a set_param() on the Image From File block and then calls sim() to run the simulation.
Voir également
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!