Why running same code on the same image gives different result every time?

조회 수: 2 (최근 30일)
Tian Tian
Tian Tian 2017년 8월 30일
댓글: Steven Lord 2017년 8월 30일
Hi, I am running a watershed segmentation on one image, but I found it gave me different result every time when I ran the same code on the same image. Can anyone help me? Thank you.

답변 (1개)

John D'Errico
John D'Errico 2017년 8월 30일
Whenever this happens, it means that some piece of the algorithm involved probably required starting values, usually for a search of some kind. In that case, a random starting point is probably generated, ergo you will get potentially a slightly different result based on where the search originated. Not all such searches will always end in the same solution, if multiple solutions exist. Or the solution might be subtly different, but still within tolerances that were deemed acceptable.
While I don't claim to have looked up the specifics of the algorithm involved, I have no doubt that a varying result is due to a random start somewhere inside that algorithm.
  댓글 수: 5
Adam
Adam 2017년 8월 30일
편집: Adam 2017년 8월 30일
rand('seed',0)
is not a syntax I can see documented for my Matlab (R2017a). I assume it is old syntax prior to the 'rng' function. However, it does appear to cause random numbers to be produced from the same seed each time. What happens after that though I have no idea because the code is unreadable.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Image Segmentation and Analysis에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by