How to move an image inside a computational grid?

2 ビュー (過去 30 日間)
S
S 2021 年 3 月 19 日
コメント済み: S 2021 年 3 月 22 日
Hello everyone,
I wish to move an image along a particular direction inside a bigger computational grid (the intensity values of the bigger computational grid is zero except of image region). Size of computational grid is ((X, Y) = (256 , 128)) and an image is place inside this computational grid at (216:266, 44:47).
So how can move the image along the x-direction (e.g. 216 --> 100 with step size , so the position of the image will become (116:166, 44:47)) place inside the bigger computational.
Suggestion/Help please.
Thank you.

採用された回答

darova
darova 2021 年 3 月 21 日
Try this
clc,clear
[x,y] = meshgrid(0:10); % main grid
[x1,y1] = meshgrid([4 6]); % small rectangle
surf(x,y,x*0,'facecolor','b');
dx = rand(1,10);
dy = rand(1,10);
h = surface(x1,y1,x1*0+0.1,'facecolor','r');
for i = 1:length(dx)
set(h,'xdata',x1)
set(h,'ydata',y1)
pause(0.5)
x1 = x1 + dx(i);
y1 = y1 + dy(i);
end
  4 件のコメント
darova
darova 2021 年 3 月 21 日
  • Could you please help me understand (x1*0 + 0.1) ??
Its Z coordinate. BIg mesh is Z=0, so the small rectangle should be on top, i made z=0.1
S
S 2021 年 3 月 22 日
Thank you.

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

その他の回答 (1 件)

KSSV
KSSV 2021 年 3 月 19 日
I = imread('peppers.png') ;
[X,Y] = meshgrid(1:100,1:100) ;
plot(X,Y,'r') ;
hold on
plot(X',Y','r') ;
image([20 50],[20 50],I)
set(gca, 'YDir','reverse')
  1 件のコメント
S
S 2021 年 3 月 19 日
Thank you very much for the help. But the my situation is different then what you have considered.
Its like I want to move a set of point (about 20-25) that is inside the red box (which i call as an image) and while we move the in upward direction I dont wish to change the intensity value .. just the position of the points along the x-axis.

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

カテゴリ

Help Center および File ExchangeConvert Image Type についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by