Is it possible to use imwrite function with standalone gui?

I have created a GUI which writes the result as an image in a directory using imwrite. My program is working good in Matlab compiler. Further, I have created a standalone application using Application compiler of Matlab for that GUI. BUt the standalone GUI is not responding whenever I am using the imwrite function with the given directory.

8 件のコメント

Geoff Hayes
Geoff Hayes 2018 年 8 月 26 日
Hossain - what is your code that is being used to call imwrite? Are you specifying the full path to the folder to write the file to?
Hossain Md Shakhawat
Hossain Md Shakhawat 2018 年 8 月 27 日
編集済み: Walter Roberson 2018 年 8 月 27 日
Not exactly, I used this
fr = getframe(handles.display_axes);
imwrite(fr.cdata, 'Output/result.tif');
However, I included the Output folder while producing the Standalone application
Image Analyst
Image Analyst 2018 年 8 月 27 日
You need to specify the whole full path, not a relative path. It will create that in some folder that you do not expect, NOT in a subfolder of where your executable is (unless you set the MCR_CACHE environment variable to be dot, but that's a long story).
Hossain Md Shakhawat
Hossain Md Shakhawat 2018 年 8 月 27 日
But the whole full path may vary depending on where the executable is placed. Right?
Walter Roberson
Walter Roberson 2018 年 8 月 27 日
If you want to write underneath where the executable expands, use ctfroot() as the top level directory, like
outdir = fullfile(ctfroot(), 'Output');
if ~exist(outdir, 'dir');
if ~mkdir(outdir)
error('Failed creating output directory "%s"', outdir);
end
end
...
imwrite(fr.cdata, fullfile(outdir, 'result.tif'));
Note that it is common for the executable to expand under a temporary directory, and so it is possible that some cleanup routine might prune out the stored information. You should typically be okay for any one run, but do not count on retaining files there between runs.
If you need to retain files between runs, then you should be choosing a different output location.
Hossain Md Shakhawat
Hossain Md Shakhawat 2018 年 8 月 27 日
編集済み: Hossain Md Shakhawat 2018 年 8 月 27 日
In details: I have created a gui that will upload an image (user will select the image). Then I have written the uploaded image to a folder called Input. Further, I have read the image from the input folder and performed some image processing using a separate Matlab program. The GUI then calls the program and display the output image produced by that program. Finally, the GUI also writes the output into the Output folder. I tried several procedures including the above one but can't write the input image(I guess). As the program cant read the image from the input folder. I have converted the GUI to standalone using the Matlab Application compiler. And tested the results using the test only files. **The GUI and program work fine in Matlab compiler (not standalone).
Hossain Md Shakhawat
Hossain Md Shakhawat 2018 年 9 月 9 日
Thanks. The problem is solved.

サインインしてコメントする。

回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeEnvironment and Settings についてさらに検索

質問済み:

2018 年 8 月 26 日

Community Treasure Hunt

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

Start Hunting!

Translated by