Report Generator of overlayed Image

4 views (last 30 days)
idriss Moffo
idriss Moffo on 20 Feb 2018
Commented: Rahul Singhal on 15 May 2018
Hey Dear all, I am working on a Image Comparison project. I have a folder with PNG images which i want to compaire pairwise. for this i take the first and the second Image out and compare them.Then I want to overlay the Parts of the second Image where there is a difference comparing to the first. It works well. But now i am trying to do a PDF-Report-Genrator with the first Image and the Overlayed Image, but it doesn't work. So I have two question: 1) how can I Generate the report with the overlayed Image 2) If the report works, how can i run it in a Loop which allows me to save many Reports. please get a look on my Code and tell me what i am doing bad.
if true
clear all;
close all;
import mlreportgen.dom.*
% k = 1;
D = 'folder'
S = dir(fullfile(D,'*.png'));
for k=1:2:numel(S)
file1 = fullfile(D,S(k).name);
file2 = fullfile(D,S(k+1).name);
im1 = imread(file1);
im2 = imread(file2);
Bw1=rgb2gray(im1);
Bw2=rgb2gray(im2);
imwrite(im1,'last.png');
imwrite(im2,'new.png');
[ssimval,ssimmap] = ssim(Bw1,Bw2);
if (ssimval>=0.9)
Z=abs(imsubtract(Bw2,Bw1));
I=im2bw(Z,0.6);
se = strel('line',35,15);
bw3= imdilate(I,se);
Iregion =regionprops(bw3,'centroid');
[labeled, numObjects] = bwlabel(bw3,8);
stats = regionprops(labeled,'Eccentricity','Area','BoundingBox');
areas=[stats.Area];
eccentricities = [stats.Eccentricity];
idxOfkittles = find(eccentricities);
statsDefects = stats(idxOfkittles);
figure, new_1=imshow(im2);
hold on;
for idx = 1 : length(idxOfkittles)
h = rectangle('Position',statsDefects(idx).BoundingBox);
set(h, 'EdgeColor', [1 0 0]);
hold on;
end
imwrite(new_1,'overlay');
rpt_type='docx';
doc= Document('mydoc',rpt_type);
paraObj = Paragraph('Störszenario: Menüaenderung');
append(doc,paraObj);
imageObj = Image(which('last.png'));
append(doc,imageObj);
imageObj1 = Image(which('overlay'));
append(doc,imageObj1);
close(doc);
rptview(doc.OutputPath);
rptview('mydoc.docx','pdf');
end
  1 Comment
Rahul Singhal
Rahul Singhal on 15 May 2018
Hi Idriss,
I think I have already answered the part 2 of your question in the other thread.
Regarding including images in the generated report, if you are writing the new image in an image file, you can use mlreportgen.dom.Image class to include it in the report. If you use the Report API, you can also use mlreportgen.report.Figure class to include a snapshot from a figure handle.
Hope this helps.

Sign in to comment.

Answers (0)

Community Treasure Hunt

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

Start Hunting!