How to overlay an image with a 10 by 10 grid?

7 ビュー (過去 30 日間)
Yash Khandelwal
Yash Khandelwal 2022 年 7 月 13 日
コメント済み: Yash Khandelwal 2022 年 7 月 13 日
I have a folder with 30 images and I want to overlay each image with a 10x10 grid. The image resolution is 1280x720. How to do this?

採用された回答

Anay Aggarwal
Anay Aggarwal 2022 年 7 月 13 日
Hi Yash
I have an understanding that you want to overlay an image with a 10x10 grid.
The function plot is able to plot multiple line at once if you provide a 2D matrix as argument. So you can plot your image and then plot each line of your grid above your image.:
% Load your image
I = imread("peppers.png");
% Get image size
s = size(I);
% Choose your grid size
n = 10;
% Construct the line's coordinates of your grid
% vertical line horizontal line
% ↑ ↑
x = [repmat(linspace(0,s(2),n),2,1) repmat([0,s(2)].',1,n)];
y = [repmat([0,s(1)].',1,n) repmat(linspace(0,s(1),n),2,1)];
% Plot the image and the grid.
imshow(I)
hold on
plot(x,y,'g')
And we obtain:
Hope this helps
Regards
  1 件のコメント
Yash Khandelwal
Yash Khandelwal 2022 年 7 月 13 日
Thanks a lot man

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeImages についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by