Color Combination - java

I have a grey image containing at least 20 different shades of gray. I would like to apply a certain color without changing it with the exception of the grey affecting the colors brightness slightly. I don't want a very drastic modification to color, only a hint. How would I go about doing this?
I'm using java, however I am more interested in the concept behind doing this.

How would I get the hsv values of a color in Java?
Don't know about HSV, but you could probably use HSL instead. Check out HSL Color for a class that does the conversion.

Related

What are other colors i can use in java? Are these the only colors?

This question probably sounds silly but I need a serious answer. I am trying to set the background color to a dark red or maroon color. The standard colors do not include the red I need.
I have tried crimson and maroon they do not work. I looked up the java standard colors and they do not include a dark red is there away to create a dark red.
this.gamePanel.setBackground(Color.RED);
The problem is not the code it works perfectly fine. I am in need of a way to get a darker Red for the back ground if possible.
You can create a Color object using any RGB value. So you could change it to
this.gamePanel.setBackground(new Color(128, 0, 0));
or whatever RGB value fits your need. You don't have to use the predefined color instances (like RED, CYAN, BLACK, or whatever).
There are docs for the Java 8 version of the class here that show a lot of options that are available for creating different color instances.

Getting alpha channel/opacity working for lighting

I have two pixel arrays, foreground and lighting. When I draw a white radial gradient (blurry circle) onto the lighting array, I want it to make the foreground visible - much like a torch in terraria/starbound. However, I also want to be able to mix different colors of lighting, rather than be stuck with black to white.
So how do I manipulate the pixel arrays so that they 'multiply' (I believe it's called)? Or is there an easier way using RGBA which I have not been able to get to work (flickering black on white or image getting ever more posterized)?
So far most responses regarding alpha channels / opacity have been using libraries from java which for this project I want to refrain from using.
Any help much appreciated!
If you want to know how the blending modes (such as "multiply") work in image editing programs on the pixel-value level, read this: How does photoshop blend two images together?.
Note that if you want to make the image lighter, you need a mode like "screen", because "multiply" makes it darker.

Detect only red pixels in Java

I need to detect all the red pixels in an image using Java. What 's the best way to do this?
Only supposing a pixel is red when the Red RGB-value is > 200 isn't good enough (see this table).
So is there a better way to do this? Or is there some red-color-rgb algorithm?
Take a look at YCrCb color space.
Simple algorithm: convert your RGB image to YCrCb, extract red channel and make a threshold.
Convert RGB to HSL, and threshold the hue (H) component.
As you suggested, you probably want to do some comparison in HSB space. You'll probably want to define an appropriate rage for all three values based on what your expectations are.
You can use Color.RGBtoHSB to get the values from a given color.
http://docs.oracle.com/javase/7/docs/api/java/awt/Color.html#RGBtoHSB%28int%2C%20int%2C%20int%2C%20float%5B%5D%29

Generate color combination from one color

I need to generate a color combination (monochromatic, triad, analogous, split, etc) from one color in Java. Just like they do in kuler, only I want to present it in a JSP page). How can I get the RGB value of the colors in the color combination? Is there a formula or API to do this?
I don't know what all those terms mean, but you might find that using HSL Color values may make it easier to find related colors.

How to replace color of an image?

I want to replace color of an image. For example turn all blue colors to red without any distortion on shape. When i try this i can swap the colors by iterating every pixel, however the shape of the swapped area turns into a flat shape.
example1 input : http://www.tutorialwiz.com/tutorials/changing_color/images/original.jpg
example1 output: http://www.tutorialwiz.com/tutorials/changing_color/images/3.jpg
example2: input output together : http://www.digital-photography-school.com/wp-content/uploads/2009/07/before-after.jpg
The usual way to do this is to use an RGBImageFilter. See the docs for FilteredImageSource for how to use such a filter.
The problem with the issue that you are asking is that a strict color replacement will modify the shape of the image. What you need to do is get a little information on what the shape is. I.e. Find boundaries and shading along the boundaries. My suggestion to you is:
Use edge detection to separate out blobs
Find a blob that fits your demands: i.e. Has a tolerant likelihood for [color]ish.
Identify blobs and filters applied
Recolor the blob and reshade.
IMO: That is the only way you're going to get the result you're looking for.
Some notes: Finding a blob may require some testing to determine how much tolerance you have for blobs and shapes. [Connected Regions].
Another thing: The shading and relative coloring will require you to have a devience for the color you want.
I'm not fully understand the question.
But from the example given, i see that the process of changing blue into red was fail. instead of becoming red, it becomes gray. does color gray is what you mean by flat?
If that so, it looks like color channel error.
to change blue to red, we have to change (0,255,0) to (255,0,0).
I'm not sure if it is the problem, maybe code snippet could help for evaluation. to make sure what is the real problem.

Categories

Resources