Pixel detectors and their applications in x-ray and high energy physics