Can anyone change this script without using CV toolbox?

1 回表示 (過去 30 日間)
Michael Kogan
Michael Kogan 2020 年 8 月 3 日
コメント済み: Michael Kogan 2020 年 8 月 10 日
Hi All,
I'm trying to store mergerd image (imfuse) which include two lines (yellow and blue) - see script below.
Does anyone has an idea how to store this image without using "insertShape" function from CV toolbox?
Thank you,
Miki
for i=1:len
background = imread(FileList(i).name);
[name,~] = strsplit(FileList(i).name, '.');
original_gray = read(vid, str2num(char(name(1))));
original_gray = imrotate(original_gray,90);
original_gray = rgb2gray(original_gray);
pair = imfuse(original_gray, background, 'blend');
output1 = insertShape(pair,'Line',[g_lx_vec(i),g_ly_vec(i),nozzle_l(1),nozzle_l(2)],'Color', {'Yellow'},'LineWidth',5);
output2 = insertShape(output1,'Line',[g_rx_vec(i),g_ry_vec(i),nozzle_r(1),nozzle_r(2)],'Color', {'Blue'},'LineWidth',5);
imwrite(output2, fullfile(dest_folder, sprintf('%01d.jpg', i+9000)));
end

採用された回答

Raunak Gupta
Raunak Gupta 2020 年 8 月 7 日
Hi,
Instead of using insertShape you can show the current image on a figure using imshow and then can use plot to draw the lines on same figure. Also, for saving the current figure with only image as output you can use imwrite and getframe. You may find code with changes mentioned useful.
pair = imfuse(original_gray, background, 'blend');
figure,imshow(pair);
hold on
plot([g_lx_vec(i),nozzle_l(1)],[g_ly_vec(i),nozzle_l(2)],'Color','yellow','LineWidth',5);
plot([g_rx_vec(i),nozzle_r(1)],[g_ry_vec(i),nozzle_r(2)],'Color','blue','LineWidth',5);
imwrite(getframe(gcf).cdata, fullfile(dest_folder, sprintf('%01d.jpg', i+9000)));
close(gcf);
  1 件のコメント
Michael Kogan
Michael Kogan 2020 年 8 月 10 日
Thank you very much Mr. Gupta!

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeComputer Vision Toolbox についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by