Multifrequency studies of galaxies and groups - I. Environmental effect on galaxy stellar mass and morphology