Intensity
In this chapter, we will work with a hand radiograph from a 2017 Radiological Society of North America competition. X-ray absorption is highest in dense tissue such as bone, so the resulting intensities should be high. Consequently, images like this can be used to predict "bone age" in children.
To start, let's load the image and check its intensity range.
The image datatype determines the range of possible intensities: e.g., 8-bit unsigned integers (uint8
) can take values in the range of 0 to 255. A colorbar can be helpful for connecting these values to the visualized image.
All exercises in this chapter have the following imports:
import imageio
import numpy as np
import matplotlib.pyplot as plt
This exercise is part of the course
Biomedical Image Analysis in Python
Exercise instructions
- Load the image "hand-xray.jpg" using
imageio
. - Print the image's data type (
dtype
), minimum (min()
) and maximum intensity (max()
). - Plot the image using
plt.imshow()
. Explicitly set the colormap's minimum (0
) and maximum (255
) values using thevmin
andvmax
arguments. - Add a colorbar using
plt.colorbar()
, then render the plot using the custom functionformat_and_render_plot()
. This has been done for you.
Hands-on interactive exercise
Have a go at this exercise by completing this sample code.
# Load the hand radiograph
im = ____
print('Data type:', ____)
print('Min. value:', ____)
print('Max value:', ____)
# Plot the grayscale image
____
plt.colorbar()
format_and_render_plot()