Can you help me how can i change HSV to RGB ?
-
Average out the HSV of pixel and slider, adding them could give a value out of range. Also, post some code. – pointerless May 18 '17 at 13:20
-
Yeah, I will write some code, but I need an algorithm what my code should do :( – hidell May 18 '17 at 13:22
-
Ok, look [here](http://amin-ahmadi.com/2016/06/05/change-hue-image-qt/) and maybe [here](http://stackoverflow.com/questions/9936021/shifting-the-hue-of-a-qimage-qpixmap) – pointerless May 18 '17 at 13:23
-
:O thanks a lot, I will try it – hidell May 18 '17 at 13:24
-
Unfortunatelly it doesn't work with my image load as QImage – hidell May 18 '17 at 13:35
-
Please check my answer :) Thanks – hidell May 18 '17 at 14:15
-
What have you googled up? – n. m. could be an AI May 18 '17 at 16:46
-
That: http://stackoverflow.com/questions/44053541/how-can-i-change-hue-saturation-and-value-of-image – hidell May 18 '17 at 16:50
2 Answers
Your color object is probably has setters for the HSV members....
So you need to define the 3 slider to play with the H,S and V values..
remember:
Hue : the color type (red, blue, or yellow) Ranges from 0 to 360°
Saturation : the intensity of the color. Ranges from 0 to 100%
Brightness (or Value) : the brightness of the color. Ranges from 0 to 100%
QImage myImage = ....
QColor myColor = myImage.pixelColor(...);
myColor.setHsv(....);

- 47,427
- 17
- 69
- 97
-
Yeah I have 3 sliders: H - with range 0-360 , S - with range 0-100 , V - with range 0-100 – hidell May 18 '17 at 13:32
-
-
1QImage myImage = .... QColor myColor = myImage.pixelColor(...); myColor.setHsv(....); – ΦXocę 웃 Пepeúpa ツ May 18 '17 at 13:38
-
Convert the QRgb values given by imagevar.pixel(pixx, pixy) to HSV, average them with your slider values, revert those values to QRgb variable, use imagevar.setPixe(pixx,pixy, newQRgb) to change those values. *Edit* exactly as @ΦXocę웃Пepeúpaツ says – pointerless May 18 '17 at 13:40
-
You mean you want to shift HS and V over the whole image by a value? Easy enough, centre your sliders at 0 and allow hue to go from -2PI to 2PI, and s and v to go from -1.0 to 1.0. Hue can't go out of range, it wraps to +/- PI or whatever convention you use. S and V are clamped to 0 - 1, (or 0 - 255 if you use bytes instead of floats).
You will need HSVtoRGB and RGBtoHSV, which is readily available on the web.

- 6,258
- 1
- 17
- 18