How to show an image using the stored vector (matrix) as a variable in the report generator

2 ビュー (過去 30 日間)
Hello,
I'd like to show an image or picture using the image vactor (matrix) in a report. Lets assume that the image is already read by imread(picname) and stored in a variable. Now, having the variable, how can I display the sotred image? The code is similar to the following:
file1.m :
picname='picname.jpg';
myimage=imread(picname);
save('myimagefile','myimage');
Later on, I load the variable from file2.m which generates the report.
file2.m :
import mlreportgen.dom.*;
import mlreportgen.report.*;
load('myimagefile');
rep=Report('Myreport','pdf');
open(rep);
I know if I use Image() function deosn't work, because it reads the associated address to the variable, not the content of the varialbe.
The wrong code is:
imagetoshow=Image(myimage); %I know "myimage" should be an adderss not a variable
add(rep,imagetoshow);
close(rep);
Any help is appreciated.
Yasser
  2 件のコメント
Yasser Soltanpour
Yasser Soltanpour 2019 年 4 月 24 日
KSSV,
Thanks for your reply. However, it didn't work with add(rep,imagetoshow). Would you please provide me a code that I could use?
Thanks for your help.
Yasser

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

採用された回答

Sean de Wolski
Sean de Wolski 2019 年 4 月 24 日
編集済み: Sean de Wolski 2019 年 4 月 24 日
You could use:
imshow(loadedimage)
add(R, Figure())
In general I'd stick with Image even if though requires imwriting your image back to disk (perhaps to tempname from where it can be deleted)
  2 件のコメント
Yasser Soltanpour
Yasser Soltanpour 2019 年 4 月 24 日
Thanks Sean de Wolski,
The code you provided didn't produce a report, but only a plot. I really hoped that there was other way to embed an image in the reprot from a variable.
Thanks,
Yasser
Sean de Wolski
Sean de Wolski 2019 年 4 月 29 日
Hi Yasser,
I replied without a MATLAB around. You need to snapshot the image from the Figure and set its properties. See example here:

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

その他の回答 (0 件)

製品


リリース

R2017b

Community Treasure Hunt

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

Start Hunting!

Translated by