Is there any rule for the pronunciation of 닫히다 as tachida not tathida as in the picture below?
This is called 구개음화 (palatalization), and it's one of several assimilation rules in Korean. It occurs when ㄷ or ㅌ is in the 받침, and is followed by a syllable beginning with 이:
같- + 이 = 같이 [가치]
굳- + 이 = 굳이 [구지]
In the example you've given, the ㄷ + ㅎ combination produce [ㅌ] sound, but since it is followed by the 이 sound, palatalization occurs, resulting in [치] pronunciation.
(Note that this rule only applies when the ㄷ/ㅌ is in the 받침 (and thus ending the morpheme). Historically, this sound change occurred across the board, but where it occurred in the middle of the word, the orthography was updated:
텬디 -> 천지
Now, exceptions like 디디다 remain; this should be pronounced as [디디다], without palatalization, because the ㄷ is not in the 받침).