フィルターのクリア

how to do the following?

1 回表示 (過去 30 日間)
Elysi Cochin
Elysi Cochin 2016 年 11 月 5 日
編集済み: Elysi Cochin 2016 年 11 月 5 日
If the color of v(x,y) is black and the colors of q(x,y) and r(x,y) are one white and one black, the white pixel is selected and set to black with the probability of 1/2. What does probability of 1/2 mean?

採用された回答

Guillaume
Guillaume 2016 年 11 月 5 日
This is really not complicated. So far you've only implemented one half of any statement. Maybe spend more time understanding the statement?
E.g., for the first one: If the color of v(x,y) is black and the colors of q(x,y) and r(x,y) are both white, one of q(x,y) and r(x,y) is selected with equal probability, and the selected pixel is set to black.
if V(x, y) == 0 && q(x, y) == 1 && r(x, y) == 1 %Implements: If the color of v(x,y) is black and the colors of q(x,y) and r(x,y)
if rand >0.5 %implements: one of q(x,y) and r(x,y) is selected with equal probability and set to black
q(x, y) = 0;
else
r(x, y) = 0;
end
end
  3 件のコメント
Elysi Cochin
Elysi Cochin 2016 年 11 月 5 日
編集済み: Elysi Cochin 2016 年 11 月 5 日
So what about in the other case when color of v(x,y) is black and the colors of q(x,y) is white
Walter Roberson
Walter Roberson 2016 年 11 月 5 日
The chance that rand() exactly equals 0.5 is one in (2^53-2)
You should be following the same structure that Guillaume and I gave: when you have the test against rand to decide which to set, then you should have an else that sets the other one.

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

その他の回答 (2 件)

Walter Roberson
Walter Roberson 2016 年 11 月 5 日
if rand() <= 0.5 %probability 1/2
set white pixel to black at this point
end
  1 件のコメント
Walter Roberson
Walter Roberson 2016 年 11 月 5 日
if V(x,y) == 0 && q(x,y) == 1 && r(x,y) == 1
if rand() <= 0.5
r(x,y) = 0;
else
q(x,y) = 0;
end
end

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


KSSV
KSSV 2016 年 11 月 5 日
You have two blacks v(x,y) and r(x,y); you have 50 - 50 chances to pick either v or r and set it to white. So the probability is 1/2.
  1 件のコメント
Elysi Cochin
Elysi Cochin 2016 年 11 月 5 日
編集済み: Elysi Cochin 2016 年 11 月 5 日
but how will it come in implementation side
if V(x,y) == 0 && q(x,y) == 1 && r(x,y) == 0
q(x,y) = 0;
end
i did like the above one, but what about the probability...

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

カテゴリ

Help Center および File ExchangeImage Processing Toolbox についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by