Dr. Besigye walked out of a Kampala courthouse Monday after a Ugandan High Court judge , John Bosco Katutsi , ruled his detention by the military was illegal .