Star formation and dust extinction in nearby star-forming and starburst galaxies