Embedding images in GUI standalone executable
7 次查看(过去 30 天)
显示 更早的评论
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
0 个评论
采纳的回答
Image Analyst
2011-11-7
One way is to just install the images in a known folder on the target computer. You can include other files in the deployment package or do it manually. You can use deploytool, or another package such as InstallShield.
0 个评论
更多回答(1 个)
Jan
2011-11-7
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 个评论
Jan
2011-11-7
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
2011-11-7
The installation folder can be accessed in the code with the variable called ctfroot.
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Introduction to Installation and Licensing 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!