Three dimensional image reconstruction in conventional and confocal microscopy