Answer the question
In order to leave comments, you need to log in
Why doesn't cmap argument work in mathplotlib?
Hello. Faced such a problem.
There is a task "The code in the next cell loads a photo of a kitten as a Numpy array."
I wrote the code and it seems to work correctly, but the image does not turn gray as in this photo
. I get something like this
Please help)
def slicing(kitten):
img1 = [[[y[0], 0, 0] for y in x] for x in kitten]
img2 = [[[0, y[0], 0] for y in x] for x in kitten]
img3 = [[[0, 0, y[0]] for y in x] for x in kitten]
fig, (img1_, img2_, img3_) = plt.subplots(
nrows=3, ncols=1,
figsize = (9,12),
sharex=True)
img1_.set_title("R")
img1_.imshow(img1, cmap = 'gray')
img2_.set_title("G")
img2_.imshow(img2, cmap = 'gray')
img3_.set_title("B")
img3_.imshow(img3, cmap = 'gray')
plt.show()
slicing(kitten)
Answer the question
In order to leave comments, you need to log in
Because slice it wrong, IMHO. It is necessary not to leave only one color component, but to replace two other components with it: [RGB] -> [RRR], [GGG], [BBB], and not [R00], [0G0], [00B].
Well, try something like this: https://stackoverflow.com/questions/25625952/matpl...
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question