One of the people obligated in reciting Birkat Hagomel is someone who was released from prison. This is alluded to in Tehillim 107, upon which many of the laws of Birkat Hagomel are based. As to what exactly constitutes a prisoner, the Magen Avraham (O.H. 219:1) explains that it refers to someone who is imprisoned because of a capital crime, such as murder. In such a case, the prisoner is likely jailed for a very long time and in dangerous conditions. When it comes to lesser crimes, such as tax evasion for example, there is not such a concern for the welfare of the prisoner and therefore Birkat Hagomel would not be warranted. On the other hand, the HIDA (Birke Yosef, § 219), quotes Rabbi Yosef ibn Migash (Shu”t Ri Migash, § 90) who says that even one who was imprisoned for financial or monetary crimes would be required to recite Birkat Hagomel. Rav Hai Gaon concurs with this approach. Practically speaking, Rabbi Moshe Toledano (Shamayim Hadashim, § 66) rules that the Halacha does not follow the Magen Avraham’s opinion, and Birkat Hagomel would apply to those imprisoned for financial crimes.Regarding house-arrest, Rabbi Menahem Mendel Schneerson (Sha’are Halacha Uminhag, § 110) says that one would not recite Birkat Hagomel upon one’s release. His rationale is that the verse in Tehillim (ibid:10) refers to prisoners as prisoners of iron, meaning, a highly secure facility unlike a house. Nevertheless, he writes that it is not clear whether or not someone placed in house-arrest for murder would have to recite Hagomel.As for the amount of time in prison that would warrant Birkat Hagomel, the Biur Halacha (O.H. 219, s.v. “Havush”) states that it is three days. However, other rabbis explain that this would only apply to a holding cell or a police station jail, but that for an actual prison, even one day would be enough there to recite Hagomel due its inherent danger.
Summary: Birkat Hagomel should be recited for anyone who was imprisoned, whether for capital, monetary or other offences. One does not recite Hagomel for house-arrest. If one was imprisoned for at least a day, one would recite Hagomel, unless it was a police station jail, etc., in which case Hagomel can only be recite after three days.