-1

I'm very new to python and scikit image processing and I've searched a lot, but did't find the answer to my question.

I need to extract the gray scale of the blue channel from the images I use for further threshold.

I've tried the rgb2gray, but I can't figure it out how to specify only the blue channel for the gray scale conversion.

Is there any other way to do this?

I'm clueless.

1 Answers1

2

Images in scikit-image are just NumPy arrays. Color images are of shape (M, N, 3) — with the last dimension being red, green, and blue. So, using standard NumPy slicing syntax, you can grab the third band (index 2) as follows:

from skimage import io
image = io.imread('my_file.jpg')
blue_channel = image[..., 2]
Stefan van der Walt
  • 7,165
  • 1
  • 32
  • 41