フィルターのクリア

Calculating maximum distance from 3 different points

3 ビュー (過去 30 日間)
Sara Foster
Sara Foster 2019 年 9 月 8 日
編集済み: Jyotish Kumar 2019 年 11 月 12 日
So I generate a test array and three points (Q) using command window:
pixels = zeros(1,3,3,'uint8');
pixels(:,:,1) = [54,50,45];
pixels(:,:,2) = [48,52,43];
pixels(:,:,3) = [50,41,47];
Q1 = [54,48,50];
Q2 = [50,52,41];
Q3 = [45,43,47];
I use my first function which calculates the median of pixels and this is put into an array e.g P=[54,55,76].
I use my second function to calculate the distance between pixels, which is:
[squaredDistance] = PixelDistance(P,Q)
However, I need to subtract Q1 from P as well as Q2 from P and Q3 from P using squared distance formula e.g
P=[54,55,76]
Q1 = [54,48,50]
[squaredDistance] = PixelDistance(P,Q1)
The question is how do I subtract Q1,Q2, and Q3 given that the function only works with Q?
  2 件のコメント
Image Analyst
Image Analyst 2019 年 9 月 8 日
How is 76 in P the median of any subset of numbers in pixels? It's outside the range of any of them. Also, why are you using a 3-D array for pixels (one row by 3 columns by 3 planes) instead of a normal 3 rows-by-3 columns matrix?
I don't know what PixelDistance() does, but to have it operate on all 3 Q, just pass in all three Q one at a time:
[squaredDistance1] = PixelDistance(P,Q1)
[squaredDistance2] = PixelDistance(P,Q2)
[squaredDistance3] = PixelDistance(P,Q3)
Sara Foster
Sara Foster 2019 年 9 月 8 日
They were just randomly generated numbers, and I could pass all three in, but I was wondering if there was a shorter way?

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

回答 (1 件)

Jyotish Kumar
Jyotish Kumar 2019 年 11 月 12 日
編集済み: Jyotish Kumar 2019 年 11 月 12 日
Hi,
If the code is vectorizable, PixelDistance(P, [Q1;Q2;Q3]) should give the desired output.
If not, to achieve a shorter way to compute the distances w.r.t all Qs at once, the code needs to be vectorized.

カテゴリ

Help Center および File ExchangeFeature Detection and Extraction についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by