Embedding images in GUI standalone executable
Show older comments
Hi, I constructed a standalone executable file for a MATLAB GUI. The GUI contains images which I have called into the axes by using the code shown.
axes(handles.axes1);
imshow('C:\Users\asinha14\My Documents\MATLAB\DFIG\DFIG_PNG.png')
handles.output = hObject;
Further, while using the deploytool I have also added the image files in the 'Other files' section.
However, while running the 'exe' on any other computer, it gives an error message saying that the executable is unable to locate the path where the image is stored. May anyone guide about how I may 'embed' the images into the GUI exe while packaging or writing the code.
Thanking you for your time.
Anubhav
Accepted Answer
More Answers (1)
Jan
on 7 Nov 2011
0 votes
You can create an M-file, which contains the image data. I've looked in the FEX, but cannot find a tool for this. Does anybody knows a submission for this task?
If there is really no solution yet, I'm going to publish one today.
[EDITED]: Parsing an M-file, which contains a [343x435x3 UINT8] array, needs more then 3 seconds on my computer. This is too slow. Using a base64 encoded string instead consumes 0.5 seconds only, but it should be much more efficient to use IMREAD or MAT-files with a known path (as suggested by Image Analyst). It should be possible to determine the installation folder and store the image or MAT file there.
3 Comments
ANUBHAV SINHA
on 7 Nov 2011
Jan
on 7 Nov 2011
I've created a function, but found a massive problem: Parsing a large array in an M- or P-file needs a lot of time. My test data image has the size [343x435x3 UINT8]. This is written to an M-file: Img.cdata = [255, 2, 1, 2, 0, ...]. Reading this needs 3.1 seconds (Matlab 2009a/64, Core2Duo 2.3GHz, Win7). That's too slow to be useful except for small icons.
Therefore I've added a new suggestion, see [EDITED].
Image Analyst
on 7 Nov 2011
The installation folder can be accessed in the code with the variable called ctfroot.
Categories
Find more on Introduction to Installation and Licensing in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!