Unity built in colour picker - unity3d

I am using Unity 2017 and I noticed that when I open the colour picker the color values appears in HSV values and not RGB.
On my second PC, the colour values are on RGB.
I have tried to look online how to change it, but Google doesn't seems to understand me and all the results are how to convert HSV to RGB in code.
All I want to do is set the built-in colour picker values to RGB
Thanks in advance

Inside the Image component just above the colour sliders there is a small icon showing 3 colour bars (a coloured one, and two black/white bars), clicking on this will swap between HSV/RGB values
It looks like this
In Unity 2019(alpha) they made it way clearer. If you click on the colour picker there will be a dropdown menu (located inbetween the colour wheel and colour sliders) with three options: HSV, RGB (0 - 1.0) and RGB (0 - 255)

Related

HTML5 Color Picker - color not changed

I've noticed a strange behavior with the color picker. When I pick any color from the basic colors (predefined colors), the button's color (the one of the html input element) is changed accordingly.
However, when picking any other color from the the gradient color picker, the button's color won't change. It will stay white. (Note: Don't pick a basic color first or refresh the jsbin page first if you're going to test it)
But... when I first pick a basic color and press OK and then pick a color from the gradient color picker, the button's color will change.
(Tested with Chrome 69)
Video (gif):
https://giphy.com/gifs/8vCEY7uyz8m17N0bkz
Test it:
http://output.jsbin.com/ivAhORu/1
var i = 0;
var inp=document.createElement("input");
inp.type = 'color';
inp.id = 'colo_'+i;
inp.value = '#ffffff';
inp.className = 'datafield';
document.body.appendChild(inp);
It's not actually an error, when you set a color picker to pure white or pure black the luminosity is adjusted to give you the desired color. When you pick a swatch the luminosity is changed to that swatch so it seems like it wasn't working before, but in fact it was working and if you adjusted the luminosity you'd see the color change correctly. You might want to consider a different starting color other than pure black or pure white.

Changes Brightness in color replacement

I am working on replacing certain color in image by User's selected color. I am using OpenCV for color replacement.
Here in short I have described from where I took help and what I got.
How to change a particular color in an image?
I have followed the step or taken basic idea from answer of above link. In correct answer of that link that guy told you only need to change hue for colour replacement.
after that I run into the issue similar like
color replacement in image for iphone application (i.e. It's good code for color replacement for those who are completely beginners)
from that issue I got the idea that I also need to change "Saturation" also.
Now I am running into issues like
"When my source image is too light(i.e. with high brightness) and I am replacing colour with some dark colour then colours looks light in replaced image instead of dark due to that it seems like Replaced colour does not match with colour using that we done replacement"
This happens because I am not considering the brightness in replacement. Here I am stuck what is the formula or idea to change brightness?
Suppose I am replacing the brightness of image with brightness of destination colour then It would look like flat replacemnt and image will lose it's actual shadow or edges.
Edit:
When I am considering the brightness of source(i.e. the pixel to be processed) in replacment then I am facing one issue. let me explain as per scenario of my application.
for example I am changing the colour of car(like whiteAngl explain) after that I am erasing few portion of the newly coloured car. Again I am doing recolour on erased portion but now what happended is colour done after erase and colour before erase doesn't match because both time I am getting different lightness because both time my pixel of to be processed is changed and due to that lightness of colour changed in output. How to overcome this issue
Any help will be appreciated
Without seeing the code you have tried, it's not easy to guess what you have done wrong. To show you with a concrete example how this is done let's change the ugly blue color of this car:
This short python script shows how we can change the color using the HSV color space:
import cv2
orig = cv2.imread("original.jpg")
hsv = cv2.cvtColor(orig, cv2.COLOR_BGR2HSV)
hsv[:,:,0] += 100
bgr = cv2.cvtColor(hsv, cv2.COLOR_HSV2BGR)
cv2.imwrite('changed.jpg', bgr)
and you get:
On wikipedia you see the hue is between 0 to 360 degrees but for the values in OpenCV see the documentation. You see I added 100 to hue of every pixel in the image. I guess you want to change the color of a portion of your image, but probably you get the idea from the above script.
Here is how to get the requested dark red car. First we get the red one:
The dark red one that I tried to keep the metallic feeling in it:
As I said, the equation you use to shift the light of the color depends on the material you want to have for the object. Here I came up with a quick and dirty equation to keep the metallic material of the car. This script produces the above dark red car image from the first light blue car image:
import cv2
orig = cv2.imread("original.jpg")
hls = cv2.cvtColor(orig, cv2.COLOR_BGR2HLS)
hls[:,:,0] += 80 # change color from blue to red, hue
for i in range(1,50): # 50 times reduce lightness
# select indices where lightness is greater than 0 (black) and less than very bright
# 220-i*2 is there to reduce lightness of bright pixel fewer number of times (than 50 times),
# so in the first iteration we don't reduce lightness of pixels which have lightness >= 200, in the second iteration we don't touch pixels with lightness >= 198 and so on
ind = (hls[:,:,1] > 0) & (hls[:,:,1] < (220-i*2))
# from the lightness of the selected pixels we subtract 1, using trick true=1 false=0
# so the selected pixels get darker
hls[:,:,1] -= ind
bgr = cv2.cvtColor(hls, cv2.COLOR_HLS2BGR)
cv2.imwrite('changed.jpg', bgr)
You are right : changing only the hue will not change the brightness at all (or very weakly due to some perceptual effects), and what you want is to change the brightness as well. And as you mentioned, setting the brightness to the target brightness will loose all pixel values (you will only see changes in saturation). So what's next ?
What you can do is to change the pixel's hue plus try to match the average lightness. To do that, just compute the average brightness B of all your pixels to be processed, and then multiply all your brightness values by Bt/B where Bt is the brightness of your target color.
Doing that will both match the hue (due to the first step) and the brightness due to the second step, while preserving the edges (because you only modified the average brightness).
This is a special case of histogram matching, where here, your target histogram has a single value (the target color) so only the mean can be matched in a reasonable way.
And if you're looking for a "credible source" as stated in your bounty request, I am a postdoc at Harvard and will be presenting a paper on color histogram matching at Siggraph this year ;) .

iPhone iOS how to instantiate a black and white CGColorSpaceRef?

I'm working with this excellent example of converting an image to grayscale: Convert Image to B&W problem CGContext - iPhone Dev
However, for my purposes, I would like to have only pure black and pure white left in the image.
It appears that to do so, I need to pass a black and white color space to the recolor method using a call:
CGColorSpaceRef colorSpace = CGColorSpaceCreateWithName(/*black and white name*/);
However, I was unable to find the proper iOS color space names. What I found was from Mac, and the "color space names" referenced from the iOS docs does not point anywhere.
How can I properly create a black and white CGColorSpaceRef?
Thank you!
I am not familiar with a black and white only color space but what you can do is calculate the total average RGB value from all the pixels (lets call it totalAvg) and use it as a threshold. Meaning for each pixel if its rgb average is greater than the calculated totalAvg than set it to pure white, otherwise set it to pure black.
I agree it is a bit of more work but thats whay I can think of unless you find the colorspace you are looking for.
You might try creating a gray color space, then creating an indexed color space with two colors (black and white, obviously) and using that.

How to get RGB components of a custom color in ios

I would like to set custom color programmatically using the method
[UIColor colorWithRed:(CGFloat)red green:(CGFloat)green blue:(CGFloat)blue alpha:(CGFloat)alpha];
For which i need to know the value of RBG components.
I would like to know is there any way by which i can get the RBG components of a custom color so that i can use them in the above mentioned method.
You can use the DigitalColor Meter.app included with every Mac OS X install. You can find it in ~/Applications/Utilities/DigitalColor Meter.app. Use it to inspect the RGB values of any pixel you mouse over. Once you have the values, you just need to divide them by 255.0 because +colorWithRed:green:blue:alpha: is expecting a floating point value between 0 and 1.
[UIColor colorWithRed:83.0f/255.0f green:217.0f/255.0f blue:58.0f/255.0f alpha:1.0f];
You can use Xcode itself to get RGB value of custom color:
Click the arrow for the Color box and in the resulting dialog box choose others.
And then you can use RGB Slider option to get RGB values
To match a color exactly, there is a great utility called "DigitalColor Meter" located in Applications/Utilities/ that can get the RGB for anything on your screen. Take a screen shot of the color you want to replicate, then use this tool to get the information.
Actually there is no need for using DigitalColor Meter instead we can use the small Search Icon on color picker in the Interface Builder with which we can exactly adjust the color that we like.It is also possible to look up the color values using RBG scales available in it.

How to convert a black and white photo that was originally colored, back to its original color?

I've converted a colored photo to black and white, and bolded the edges. Now i need to convert it back to its original color with the bolded edges. Is there any function in matlab which allows me to do so?
Once you remove the colour from an image, there is no possible way to automatically put it back. You're basically reducing a set of 16,777,216 colours to a set of 256 - on average each shade of grey has 65,536 equivalent colours, and without the original image there's no way to guess which it could be.
Now, if you were to take the bolded lines from your black-and-white image and paint them on top of the original coloured image, that might end up producing what you're looking for.
If what you are trying to do is to use some filter over the B/W image and then use that with the original color. I suggest you convert your image to a color space with Lightness channel that suits your needs (for example L*a*b* if you need the ligtness to be uniformly distributed regarding human recognition of differences) and apply your filter only over the Lightness channel.