problem in ycbcr color space

3 visualizaciones (últimos 30 días)
Ashmil Mohammed
Ashmil Mohammed el 27 de Jun. de 2015
Respondida: Walter Roberson el 29 de Jun. de 2015
I am facing some problems in using the ycbcr color space. For a certain purpose this model is the most suitable. But conversion from RGB to ycbcr yields me some negatives values too... Please help. Why does this happen? Are there any ways to solve this?
  1 comentario
Star Strider
Star Strider el 27 de Jun. de 2015
It will help if you posted (or attached) your code, and attached your image.

Iniciar sesión para comentar.

Respuesta aceptada

Walter Roberson
Walter Roberson el 29 de Jun. de 2015
My speculation would be that you started with a uint8() image, used double() on that, and asked to use rgb2ycbcr() on the result. That could result in negative values, as the datatype of what you ask to convert (uint8 or double) determines which range of values are expected (0 to 255, or 0.0 to 1.0).
Always remember: the result of applying double() to a uint8 image is not an image! If you want your image represented in double precision then use im2double() not just double()

Más respuestas (2)

Image Analyst
Image Analyst el 28 de Jun. de 2015
I'm not that familiar with that particular color space. What conversion are you using? I see from https://en.wikipedia.org/wiki/YCbCr that there is a minus sign in the formulas so perhaps they can go negative. I assume you're using rgb2ycbcr(). What colors are you getting negative values for?
  2 comentarios
Ashmil Mohammed
Ashmil Mohammed el 28 de Jun. de 2015
Yes that is the function I use to change . But I am getting negative values in 2nd channel.
Image Analyst
Image Analyst el 28 de Jun. de 2015
If you answer my questions, maybe I can answer yours . OK, if you won't tell me the colors, then maybe you could upload the image. Uploading your m-file, or at least a snippet, would make me more likely to try it, and sooner, than if I had to write it myself.

Iniciar sesión para comentar.


Thorsten
Thorsten el 28 de Jun. de 2015
You have some error in your formula. RGB values in the range 0, 255 or R'G'B' values in the range 0..1 map to non-negative YCbCr values. See https://en.wikipedia.org/wiki/YCbCr
  5 comentarios
Image Analyst
Image Analyst el 29 de Jun. de 2015
Walter, the answer is 16. Ashmil, it's probably best you switched to HSV color space, though I was wondering what situation you had that made you original think "For a certain purpose this model is the most suitable". I think for most situations that I know of, conversion to HSV is fine. The only time I switch to LAB is if I need to compute a color difference because the Delta E formula in LAB space is much, much simpler than it is in HSV color space.
Walter Roberson
Walter Roberson el 29 de Jun. de 2015
16 is the answer to be expected from the description of YCbCr in Wikipedia.

Iniciar sesión para comentar.

Categorías

Más información sobre Convert Image Type en Help Center y File Exchange.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by