【发布时间】:2014-03-28 19:22:54
【问题描述】:
我只是想知道如何在 matlab 图像处理中使用 randseed 而不是 randn。
我想稍后使用 x,y 的质心来映射对象随时间的位置。
另外,我可以使用什么函数使生成的值能够这样做?
clear all
% Define image size
N = 300;
%define Initial object point
X = 150;
Y = 150;
%Number of frames
duration = 10;
for T=1:duration
% Set up rand image. Process and measurement noise
Image = 0.4*rand(N); %distabunce
% Define object position & size
X = X+10*randn;
Y = Y+10*randn;
Size_radius = 5;
filter = BuildFilter(Size_radius);
for i = 1:N
for j = 1:N
if (sqrt((i-X).^2+(j-Y).^2) < Size_radius)
Image(i,j) = 1;
end
end
end
figure(1)
%subplot(2,2,1)
title('Caption1')
imagesc(Image);
colormap(gray);
axis image;
pause(0.1);
end
【问题讨论】:
-
你想通过替换 randn 来达到什么目的?
-
是的,所以我可以在模拟程序时使用相同的随机数,有人告诉我 randseed 是最好的选择