Converting an rgb image to hsv?

In general systems deal with images in RGB - if you're converting to HSV to do some processing in HSV space then what you want to do is convert the pixels to HSV, do your processing, convert BACK to RGB and save the final RGB values Converting an image from RGB to HSV without changing it at all would IMHO be fairly useless (you just end up with exactly the same image).

In general systems deal with images in RGB - if you're converting to HSV to do some processing in HSV space then what you want to do is convert the pixels to HSV, do your processing, convert BACK to RGB and save the final RGB values. Converting an image from RGB to HSV without changing it at all would IMHO be fairly useless (you just end up with exactly the same image).

Visit OpenCV documentation and take a close look inside cvCvtColor function. There you will see the "tricks" used in OpenCV to store HSV values. For example, to store 8 bits images: V gets 255 * V, S gets 255 * S and H gets H/2.

– Can Doralp Nov 7 '09 at 16:52 If I'm understanding your problem, that depends of the image representation on memory. For example, OpenCV can use three 2D arrays, one per channel. So, for pixel at row 10, column 20, you have something like: V1020 = max(R1020, G1020, B1020), according the color conversion equation for V.

The image representation on memory depends of the library you are using. – TH. Nov 7 '09 at 17:09 1 This could help you: thsant.blogspot.

Com/search/label/opencv. Keep in your mind the following: monitors and (probably) the graphic environment of your system are able to show RGB images (because the monitor is a RGB device). Suppose you applied the color space transformation.

Your image has values for the 1st channel, for the 2nd channel and for the 3rd channel. The system probably don't know if these channels are RGB, HSV or YCrCb channels. Most of systems will try to display the image as a RGB one, producing curious "wrong coloured" images.

– TH. Nov 7 '09 at 17:23.

If you're interested in reusing the HSV values every time you need to process the image, you could write a binary file that holds them. That involves however duplication of your image in some form, but it may be useful if you've got multiple processes that need those values and due to a large image size, would like to avoid the conversion step. In general, however, you read the RGB values, convert them to HSV, process them, convert them back to RGB, and save the processed image.

If you want to store your HSV values in your image file and be able to display it as a "map" of these channels, you can probably think of it in terms of mapping the HSV values onto the RGB interval. RGB values are in the 0-255 interval each, while in HSV, Hue is in 0 - 360, S and V in 0.0 - 0.1. This means that you could store the S and V values in G and B by multiplying them with 255: G = S * 255; B = V * 255; As for the H value, you must map it in the 0 - 255 space, so you multiply it with (255 / 360) and store it in the R component.So there it is, the last piece: R = H * 255 / 360.

I'm reading the RGB values and converting them to HSV but I want to save the image as it's HSV form. How can I do that? For example if we consider the example I gave in the first post, where should I assign these values in order to get the image as it's HSV form?

– Can Doralp Nov 7 '09 at 2:42 The question you should be asking is if there is an image format that stores its pixel values as HSV triples - I personally have never heard of such a format. Perhaps you can tell me what image format do you use? Is it PNG, JPEG, GIF?

If you use a common image format like these and many others, chances are you won't be able to store your HSV values directly in the image without you corrupting it and making it unreadable for any other program that expects it to be RGB . – luvieere Nov 7 '09 at 6:30 In fact, I've an hw to do and what's expected from me is loading an rgb image to the 1st picture box and select one of the color space conversion options(rgb -> hsv and hsv -> rgb is included) and show the converted image in the 2nd picture box. I' ve done all of them except rgb -> hsv and hsv -> rgb but if it isn't possible to save the image as HSV like you said why my instructor has added this option to the hw?

I'm really confused now... – Can Doralp Nov 7 '09 at 14:45 Could you paste here the exact words of your assignment? I think it'll help me understand what your instructor meant and what approach you could take. – luvieere Nov 7 '09 at 14:57 Here is my hw bit.Ly/48e3U5 – Can Doralp Nov 7 '09 at 16:39.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions