from read_pdz import extract_jpg
Extracting image data from pdz files
Good to know where we took the measurement…
The newest Bruker Tracer XRF spectrometers are equipped with a simple RGB camera that can be used to record the location of the spectral measurement. These RGB images are then encoded as jpg binary data that are stored within a single specific block (type 137) in the pdz file. If a pdz file actually contains one or more sets of image data you can use the extract_jpg()
function to get them out.
= '/home/frank/Work/DATA/read-pdz-demodata/00081-Precious Metals 2.pdz' # contains jpg image
pdz_file = extract_jpg(pdz_file, save_file=True) ims
Saving image file: '/home/frank/Work/DATA/read-pdz-demodata/00081-Precious Metals 2-0.jpg'
Let’s take a look at the image. Can anyone tell what we see here?
Code
import matplotlib.pyplot as plt
Code
= plt.subplots()
fig, ax 0]); ax.imshow(ims[
Some pdz files contain multiple images. Let’s see how they look like.
= '/home/frank/Work/DATA/read-pdz-demodata/with-three-images.pdz'
pdz_file = extract_jpg(pdz_file, save_file=True) ims
Saving image file: '/home/frank/Work/DATA/read-pdz-demodata/with-three-images-0.jpg'
Saving image file: '/home/frank/Work/DATA/read-pdz-demodata/with-three-images-1.jpg'
Saving image file: '/home/frank/Work/DATA/read-pdz-demodata/with-three-images-2.jpg'
Code
import matplotlib.pyplot as plt
Code
= plt.subplots(ncols=3, figsize=[8, 3], squeeze=True)
fig, axs
for im, ax in zip(ims, axs):
ax.imshow(im)
FUNCTIONS
extract_jpg
extract_jpg (pdz_file, BLOCKTYPE=137, save_file=False)
*Extract and save jpg images from pdz_file
.
Returns a list of jpg images where ims = [ im0, im1, … ].*