How to draw horizontal lines on set of images

9 ビュー (過去 30 日間)
Tomer
Tomer 2019 年 8 月 31 日
コメント済み: Walter Roberson 2019 年 8 月 31 日
Hi, I am new to MATLAB and need some help. I have 2000 TIF images (located in a folder with names F_001, F_002,.....F_2000) and I want to draw four horizontal lines on all the images. The given coordinates are in image system.
Position of line 1: [x1,x2]=[0,1024] and [y1,y2]=[760,760]. I want to write text "predator location" on top of this line
Position of line 2: [x1,x2]=[0,1024] and [y1,y2]=[500,500]. I want to write text "safe distance" on top of this line.
so are the lines 3 and 4.
How can I do this in a loop using MATLAB. Also, I want to have control over the type of line and the color. Can someone please, help me with this.
  3 件のコメント
Tomer
Tomer 2019 年 8 月 31 日
編集済み: Tomer 2019 年 8 月 31 日
How to apply this using a "for loop" on all the images? The code will be helpful for me.

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

採用された回答

KALYAN ACHARJYA
KALYAN ACHARJYA 2019 年 8 月 31 日
編集済み: KALYAN ACHARJYA 2019 年 8 月 31 日
Images=dir('C:\complate_path\folder_name\*.tif');
outDirectory='C:\complate_path\folder_name_to_save\';
for i=1:length(Images)
ImgName=strcat('C:\complate_path\folder_name\',Images(i).name);
image_test=imread(ImgName);
imshow(image_test);
line([0 760],[1024 760],'linewidth',3);
line([0 500],[1024 500],'r','linewidth',3);
% so are the lines 3 and 4........
fig=gcf
imwrite(fig,strcat(outDirectory,Images(i).name));
end
I want to have control over the type of line and the color. Can someone please, help me with this.
For this read the commnet by @Walter Roberson
  5 件のコメント
Tomer
Tomer 2019 年 8 月 31 日
I don't know much about MATLAB. I used your code and got this error.
Error using imwrite (line 427)
Expected DATA to be one of these types:
numeric, logical
Instead its type was matlab.ui.Figure.
Walter Roberson
Walter Roberson 2019 年 8 月 31 日
imwrite(result_image, ....)

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

その他の回答 (0 件)

Community Treasure Hunt

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

Start Hunting!

Translated by