フィルターのクリア

unifrnd, matrix

2 ビュー (過去 30 日間)
PChoppala
PChoppala 2011 年 10 月 16 日
Hi friends, can you help me out with this
I have a matrix(or a frame(image) in my case) called 'z', say its a 3x3 frame.
x = [1.2, 0.45, 0.2, 0.25, 20]';
n=3;
m=3;
blur = 0.7;
a = 3.*randn(n,m);
for i=1:n
for j=1:m
if i-x(1) < 3 && j-x(3) <3
h(i,j) = x(5)/(2 * pi * (blur^2)) * exp(-((i-x(1))^2 + (j-x(3))^2)/ (2* (blur^2)))
else
h(i,j) = 0
end
end
end
z = a + h;
So, 'z' will be a 3x3 frame having certain values for the 9 pixels.
'x' is a state vector having are [position along x-axis, velocity along x-axis, position along y-axis, velocity along y-axis, Intensity].
So the pixels in frame 'z' that fall in the vicinity of the position given by 'x' in x-y direction ie x(1) & x(3) will have higher values(Intensity than others)
now, what I want is, the position of the particles should be initialized from the distribution q(x,y | z) is a uniform density over those regions in 'z' for which z(i,j) > T
T = threshold = 2
I need to draw values from that distribution.
Can you help me out with this?
  4 件のコメント
PChoppala
PChoppala 2011 年 10 月 16 日
z =
0.8097 -0.2496 0.0621
5.8031 -2.2792 -0.1705
3.5348 11.1277 -3.6788
I have a better way of asking, my friend!
Consider the above matrix.
I want to find the indices of the rows in which atleast one element is greater than 2
Similarly, I want to find the indices of the columns in which atleast one element is greater than 2
Please help
Image Analyst
Image Analyst 2011 年 10 月 16 日
Well I didn't see it because x(1) = 1.2 and x(3) = 0.2 and you can't have a z value at the (1.2th, 0.2th) location, unless you make another array that is interpolated to give values there. But whatever...see my answer below, which answers your last question and thankfully doesn't depend on understanding the first part.

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

回答 (1 件)

Image Analyst
Image Analyst 2011 年 10 月 16 日
Just do
[rows columns] = find(z>2);
The find() function is usually one of the first ones people learn (along with min, max, mean, and sum). You'll also need sum if you want to find which rows or columns have more than 2 elements above the threshold. It's a really really easy one-liner. Write back if you can't figure it out.
  3 件のコメント
PChoppala
PChoppala 2011 年 10 月 16 日
n=rows=3
m=columns=3
Image Analyst
Image Analyst 2011 年 10 月 16 日
Not sure what all that was. This is what I was thinking:
columnsWithMoreThan2 = sum(z>2, 1);
rowsWithMoreThan2 = sum(z>2, 2);

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

カテゴリ

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

Community Treasure Hunt

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

Start Hunting!

Translated by