I have been trying to create a random black and white mask like the following in Inkscape without success:
My nearest try has been to use black as initial color for the clones, 100% of change of color lightness for each column and alternate the sign of color changes. The result is this chessboard-like mask
The randomize option does not work because it randomizes the color property and not the "index" of the clone whose color is to be switched.
Note: Although my first approach was through the user interface, solutions using the scripting capabilities of Inskcape are also welcome.
I tried the following approach:
Make an original tile with undefined color (shown as ?)
Make a row of tiled clones, with initial color black, and 100% random light component. This will result in a row of random gray levels.
Group all the tiles together and select the group.
Apply the extension Color->Black & White to turn those grays into either black or white.
Related
I am trying to use color information of detection of rectangles. Some of my rectangles are overlapping and with multicolor. I found a solution to detect these rectangles using Hue values. I am checking inRange with Hue values of colors
Orange 0-22
Yellow 22- 38
Green 38-75
Blue 75-130
Violet 130-160
Red 160-179
, but I do not know what exact color is going to be. For example, in one image rectangles can be orange, red, blue and in another image, it can be other colors.
I tried to look histogram, but I would have a background which is not only white or black. So, the histogram is confusing.
If you give me some ideas about how to handle this problem, I will appreciate it.
You can try a brute force approach, where you try all the color ranges, then use findcontours (example) to see if you can find a contour that is possibly a rectangle. If the background is very noisy you can use a minimum size for the contour
(contourArea). You could also check the solidity by dividing the contour area by the area of the minAreaRect, the result for a rectangle (that has good detection) should approach 1.
Whether this could possibly work depends on several factors, and overlapping rectangles will quickly break it.
So if I understand correctly, you have a variety of images, each of which contain multiple rectangles which can be a variety of different colors, and the background of the image is non uniform, and you're trying to segment out the rectangles using a histogram?
Using histograms for image segmentation works best with grey scale images with a uniform background, so that upon seeing the peeks in your histogram you know the primary intensities of the objects you are trying to segment out. This method is not going to translate well to your application because the shapes you are attempting to segment are non uniform in shade, without seeing example images I would probably say this isn't going to work, however you might be able to get away with it if the shade variation of the rectangles is relatively similar... basically if you have rectangles that are 15-30 you might be alright, but if they vary from 20-100 you're going to be out of luck, same goes with variation of the background.
If the background and the rectangles have very clearly defined borders, and the background colors transition VERY smoothly, you may be able to get away with some sort of region growing on the background in order to get a list of all the background pixels and then just set those to black or something in order to allow better analysis of the rectangles in the foreground, but I can only speculate so much with the information you've given in your post
I'm trying to create an image where I'd like to include part of a jpg image in the following way: I'd like to have the "outer" part of the jpg at the fringes, so that it is opaque on the edges and transparent in the middle (where the main part of my image is). I've tried the following:
1. Adding a radial opacity gradient to the jpg itself as if it were a vector-based object.
2. Creating an Inkscape object with an analagous gradient and then doing a Clip>Set with the jpg.
Neither of these worked (obviously). Is there a way to do this in Inkscape? all of my attempts have either done nothing, or have only succeeded in changing the opacity of the image uniformly (without a gradient).
The feature you want is called Masking, you can find it right below Clip in the menu in Inkscape.
The darker or more transparent the mask object is, the more it hides from what is below. So you need a gradient that goes from black in the center to white at the outer perimeter.
The rest works just like clipping.
I am re-asking this question because my first attempt was erroneously marked as a duplicate, and I still have hope that someone might have an answer for me.
I am having to write my own mouse-over code for a particular control in a C++/VCL application. The question is, given ANY combination of foreground and background colors, how do you calculate a highlight color to indicate that the mouse is over that control?
I am NOT asking how to choose a font/text color based on the background color. That question has certainly been answered. What I need to do is choose a third color to use to highlight the item when the mouse is over it.
I was thinking I probably want to do something like take the background color, find its opposite on the color wheel (and I have no idea how to do that). If that color is too close (however you determine that) to the text color, make it lighter or darker.
Does anyone have an algorithm they are willing to share?
Thanks!
If you want to find the complementary color (opposite on the color wheel), you can convert the foreground color to HSV space (or any of a number of other color spaces such as Y'CbCr, Y'IQ, etc.), rotate the hue component 180° and convert back to RGB.
As you suspect, this might not work if the background color is too close to the resulting color. That gives you some options, though. If you convert both colors (fg & bg) to HSV, you can find 2 colors with hues that are exactly between the foreground and background colors. Just find the angle midway between the 2 input colors' hues to get the first possible color, and then add 180° to that to get the other possible color.
But the bigger question is why you're trying to set the selection color at all? You should be using the system highlight color unless you have a really good reason not to.
My aim is to determine the color of object. And make a classification, for example some blue, little bit dark blue or light blue can be classified to one type - Blue. I have some template objects images. There are many of them. What I want is to group this images manually. For example some objects have blue colored text, but some areas of yellow etc. By some algorithm at first I group them manually, and then each group should be analyzed by computer to make some feature extraction. And then while getting from camera as video or image of the random selected object, I want to identify it's group correctly. How can I do it? Which features should be extracted and how can they be compared? I was thinking of histogram of a Hue plane in HSV. But don't know what features to get from that histogram and then to compare it with another(from template images)
EDIT 1: Example of images that should be classified, later will post more if neccessary.
image example
It is always good to use the LAB color space in order to mimic human perception.
http://en.wikipedia.org/wiki/Lab_color_space
That is because the Euclidean metric in this color space represents the perceptual distance between colors, that is, how close they are.
You should cluster by A,B and ignore L value which is the brightness.
HSV can be tricky to use in varying light situations. This is especially true outside, where shadows are a lot bluer than sunlight areas.
Ideally, you can use the hue and saturation components and ignore the value component. This would make the distance between a light blue and a dark blue very small:
dist = sqrt((h1 - h2)^2 + (s1 - s2)^2
The gotcha is that hue is actually a continuous scale (like an angle). The difference between 255 and 0 should only be 1.
I have a WTL C++ application and I want the user to be able to select different colours for some of the UI elements and apply a gradient fill using the GradientFill API call. However, instead of letting the user pick the start and end colours for the gradient, I'd like them to be able to select a 'base' colour and for my application to calculate suitable start/end colours automatically. I want to end up with a fill that is similar to the one Windows uses for various themed elements. The base colour could be the 'middle' colour of the gradient with my application somehow computing a slightly lighter colour for the gradient start and a slightly darker colour for the gradient end. Alternatively I could use the base as the start colour and compute the end or vice-versa.
I'm sure this would be relatively easy with some RGB macro magic but I really don't know where to start. Any ideas would be welcome.
The RGB color space is not suitable for this. Use HSL or HSV: it is easy to auto-generate a good looking gradient by varying an individual component. Converting from HSL/V to an RGB triplet you can use in the API is simple.