0

I need convert an image from BGR to YCbCr in Python using OpenCV. I have an image with size/resolution 512x512, but when the image is opened, the size is 128x128.

I'm doing:

image = cv2.imread(imageName, cv2.COLOR_BGR2YCR_CB)

Could anyone help me?

1
  • Could you try rephrasing this question? I am not sure about what you need help with. Commented Jul 9, 2018 at 2:08

1 Answer 1

1

The problem:

If you look at the docs for imread, the function takes an integer flag called imreadmodes. This flag seems to accept information about resizing the image, rather than changing color spaces.

The solution:

I believe you are looking for the cv2.cvtColor function which uses a flag to determine the source and destination colorspaces.

Both flags are simple integer enumerations. I assume the imread function is simply doing the best it can with the wrong type of flag.

You probably want to do something like:

BGRImage = cv2.imread(imageName)
YCrCbImage = cv2.cvtColor(BGRImage, cv2.COLOR_BGR2YCR_CB)
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.