Activity 14: Logistic Regression

🕑10:15, 7 Nov 2019

For this activity [1], I used the banana dataset from [2] which has 273 images of bananas separated by underripe, midripe, yellowish-green, and overripe labels.

Feature extraction: RGB

For the training set I decided to take only images of underripe (green) and ripe (yellow) bananas and assign them class numbers 0 and 1, respectively. The feature vector extracted from the images consist only of the mean of each color channel (whose values are normalized to 1), without any further preprocessing or segmentation. I simply reused my code from the previous activity, with minor modifications. The feature space in RGB is shown in Fig. 1.

RGB extract

Figure 1: Feature space of ripe (1) and unripe (0) bananas in RGB.

After training all the ripe/unripe images, I then fed in the midripe images and plotted their activations. We can see from Fig. 2 that the predictions appear biased toward the upper half, which subjectively does not agree with the corresponding images. Preferably, the predictions are nicely distributed about the center. To this end, I try another approach.

RGB predictions

Figure 2: Final activations of the midripe banana images in RGB.

Feature extraction:

In order to be able to plot the decision contours as well as reduce the computational complexity, I decided to convert the images to color space and feed only the features. Also, I decided to feed in overripe bananas as class 1 in order to be able to include ripe and overripe predictions. Figure 2a shows the feature space in , and we can see that the two classes are easily separable. Plotting the midripe activations in Fig. 2b now shows that the predictions are nicely distributed around the activation region. In Fig. 2c, we show the decision contours on the feature plane. In this view, we can see the sigmoid activation as a contour map―with blue being 0 and red being 1―and our training set falls in the extremes, save for a few outliers. In Fig. 2d, we show representative images for varying activation levels. We can confirm that an activation corresponds to unripe (green) bananas, an activation corresponds to overripe (yellow-brown) bananas while the regime which is approximately linear may correspond to midripe/ripe bananas. Specifically, the range 0.2-0.4 corresponds to the midripe (yellowish-green) bananas, while the range 0.6-0.8 corresponds to the ripe (dominantly yellow) bananas.

Feature space of overripe (1) and unripe (0) bananas in L*a*b*.
(a) Feature space of overripe (1) and unripe (0) bananas in L*a*b*.
Final activations of the midripe banana images in L*a*b*.
(b) Final activations of the midripe banana images in L*a*b*.
Decision contours of overripe (1) and unripe (0) bananas in L*a*b* feature space.
(c) Decision contours of overripe (1) and unripe (0) bananas in L*a*b* feature space.
Images of bananas of varying ripeness corresponding to their activation levels.
(d) Images of bananas of varying ripeness corresponding to their activation levels.

Figure 2:

References

  1. M. N. Soriano, A14 - Logistic regression (2019).
  2. F. Mazen, and A. Nashat, Ripeness classification of bananas using an artificial neural network. Arabian Journal for Science and Engineering (2019).

Keywords

image processing
computer vision
feature extraction
logistic regression