The first challenge for us is to convert images into numerical feature vectors in order to train our k-means clustering model. In our case, we will be using grayscale MRI scans. A grayscale image in general can be thought of as a matrix of pixel-intensity values between 0 (black) and 1 (white), as illustrated in Figure 5.3:
The dimensions of the resulting matrix is equal to the height (m) and width (n) of the original image in pixels. The input into our k-means clustering model will therefore be (m x n) observations across one independent variable—the ...