Generate Report - Using imshow

3 visualizaciones (últimos 30 días)
Raphael Pesch
Raphael Pesch el 1 de Jul. de 2019
Respondida: Maadhav Akula el 18 de Jul. de 2019
Hey guys,
I'm using Generate Report to creat a pdf-File. By using a surface plot it is possible to add the image to the pdf-file. I also want to add another rgb-image to this pdf-file, but I get the following error message:
Error using mlreportgen.report.Figure/createSnapshotFigure
Figure is invalid. Please use valid path of the figure file or valid figure handle
....
Error in test (line 58)
add(report,c1);
I use the following code:
%Import the DOM and Report API packages so you do not have to use long class names.
import mlreportgen.dom.*
import mlreportgen.report.*
%Create a container to hold the report content.
doctype = 'pdf'; %Also working with 'docx'
report = Report("Auswertung", doctype);
open(report);
%% Create title page
tp = TitlePage("Title", "Ergebnisse test", "Subtitle", "test");
add(report, tp);
%% Table of Contents
toc = TableOfContents;
add(report, toc);
%% Create a chapter with the title
c1 = Chapter("Title", "Ergebnisse");
c2 = Chapter("Title", "Nächstes Kapitel: ");
%% Data
s1 = Section("Messdaten");
p1 = Text("Aufnahme in [cd/m²]");
s2 = Section("Maske");
[name_gray, path_gray] = uigetfile('*.*', 'Select gray value image');
[name_rgb, path_rgb] = uigetfile('*.*', 'Select rgbe image');
picture_data = dlmread(fullfile(path_gray, name_gray)); %Example Path
groups_rgb = imread(fullfile(path_rgb, name_rgb)); %Example Path
%% Gray value image
figure();
ax = gca;
Fig1 = Figure(surf(ax, picture_data));
%Plot the measurement data as surf plot
axis equal
shading interp
colorbar
view(0,-90)
add(s1, p1);
add(s1,Fig1);
close(gcf);
%% RGB image
figure();
imshow(groups_rgb);
Fig2 = Figure();
add(s2,Fig2);
%% Create Report
add(c1, s1);
add(c1, s2);
add(report,c1);
add(report,c2);
close(report);
rptview(report);
I use a MacBook Pro (Mac OSX), Matlab Version R2019a. I tryed it in some different versions but its just not working. Maybe someone of you can help me. Thank you very much!
Best, Raphael

Respuesta aceptada

Maadhav Akula
Maadhav Akula el 18 de Jul. de 2019
That error is thrown by the mlreportgen as you have closed the Fig1(line 48: close(gcf);), you can remove the error by not closing the figure window or you can save Fig1 as a Document part as shown below:
%% Gray value image
figure();
ax = gca;
Fig1 = Figure(surf(ax, picture_data));
%Plot the measurement data as surf plot
axis equal
shading interp
colorbar
view(0,-90)
Fig1 = getImpl(Fig1,report);
add(s1, p1);
add(s1,Fig1);
Also while saving Fig2 please use the below format so that your figures aren’t overwritten while generating the report:
Fig2 = Figure(imshow(groups_rgb));

Más respuestas (0)

Categorías

Más información sobre MATLAB Report Generator en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by