The Higgs and Hahn algebras from a Howe duality perspective