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

조회 수: 7 (최근 30일)
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 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.:
% Get image size
s = size(I);
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이전 댓글 -1개 표시이전 댓글 -1개 숨기기
Yash Khandelwal 2022년 7월 13일
Thanks a lot man

댓글을 달려면 로그인하십시오.

### 카테고리

Help CenterFile Exchange에서 Image Arithmetic에 대해 자세히 알아보기

### Community Treasure Hunt

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

Start Hunting!

Translated by