rect.hclust integer vector for "border" parameter - r

Clearly one can use an integer vector for the border parameter of rect.hclustL
x <- rect.hclust(foo, k=ncuts, which = c(2,7), border = 3:4)
So imagine I have ncuts and wish to have "pseudo"-unique coloring of each border cut:
x <- rect.hclust(foo, k=ncuts, which = c(2,7), border = 1:ncuts)
Clearly the border color list that is being selected is finite - but what are the actual colors?
I started looking through documentation and no leads there, I moved on to a cursory view of the source code - and nothing there either.
By observation I noticed the colors appear to be (limited to):
Black
Red
Green
Violet
Light Blue
Magenta
Yellow
White
But how are they defined - and more importantly say that I wanted to associate the cuts with the appropriate color later on - could I do it?
UPDATE:
The coloring of dendrogram borders when defined by a numerical color lists occurs strictly from Left to Right (Black, Red, Green3, Blue, Cyan, Magenta, Yellow Grey, Black, Red ...). The question then becomes - how can I associate / locate a cut's position within the dendrogram.

Related

How do I compute a color HEX so that if I would lighten/darken it, by x% (say 40%) it would give me a given HEX value

I want to create my own color theme in MS Word. I can choose a set of 7 colors, and then MS Word will compute shades and tints based on my selected colors.
However, the computed colors are bad - VERY bad. I would like to make my color be in the auto-computed '25% darker' category, so I need to select a color as my theme color that, when darkened by 25% would produce my original color.
For example, I should choose a color as "Accent 1" such that, when Word auto-computes the 25% darker shade, it would return #DC5900
I assume this is not necessarily word-related, but rather color calculation related.
I have tried 'guesstimating' colors based on how I noticed the darker/lighter shades were computed for other colors, but the math does not appear to be linear.
For example, for my #DC5900, the 50% lighter tint is #edac7f. However, after I set the color as theme color, the 50% darker version of #edac7f is #934714 and not my original color. And that was the same with the color-helping websites, if you click on a shade/tint color, none of the computed shades/tints go back to the original color value.
I've looked on websites such as https://www.color-hex.com or https://convertingcolors.com however, the color that was computed as 50% lighter, did not return the original hex color when I input the lighter value and asked it to calculate a shade 50% darker.
Is there a place where I can find an algorithm to compute the color 'backwards', so the unknown color would be the origin that determines that a shade X% darker/lighter is a given HEX value?
Of course, the ideal would be if you know such a tool that already does that, as I've spent so much time with this that it's become ridiculous.
Would appreciate any ideas, I'm stuck and stubborn and I just can't give up

How to build equal ranges of a green or brown tone in a color palette from dark to bright with RGB for images with R?

Does anyone know how I can search in many images for green tones and cluster them for a later characterisation of the images? The idea is to include all shades of green from the green palette and only leave out as few as possible, none would be great actually. I have thought of taking a photo with a lot of green tones, clustering it using R and then creating areas between the values of the cluster centres. However, since forming areas of RGB images is a three-dimensional space, I find it difficult to form areas that contain all the color tones in total, but only one color tone should occur in an area, so there are no overlaps. It is also difficult to find an image with all green shades for the clustering.
Does anyone have a tip for me?

N^2 diagram explanation

The N^2 diagram is color and shape coded.
Are the explanations of these included in the manual somewhere?
Some of them can be deduced more easily for example I assume orange one is implicit comp output. But there are combinations of black, gray circle square and surrounded square
To get some information, you can click on the 'Show legend' button (the sixth button starting from the right as for OpenMDAO 2.2.1). The legend is displayed at the bottom.

2-D alpha map examples for blending two overlayed images in MATLAB

I would like to blend two images, one is smaller and is completely enclosed by the larger one, Assume the both are rectangular. I would like to blend these two so that there is a smooth transition in a rectangular band around the smaller image. I am trying to do this in MATLAB.
For example here two images are shown on top of each other, orange and black mages:
I would like to create a transition band around the orange image such that at the very outward boundaries of the band the alpha map for the orange image has a value of 0 and for very inward boundaries have value of 1 and there is a smooth transition from 0 to one inside the gray band that is shown below:
I am looking for a map for the gray area probably a 2-D matrix that has values between 0 and 1. Is there any equation based or ready made such matrix?
I know I can create a simple linear transition for a vertical or horizontal band for example if the X shows the x-coordinate of the left most edge of the inner image and my blending width is W then I can use this:
alpha(x) = (x-X)/W for X<x<X+W
1 for x > X+W
But how to create such an alpha in 2-D?

How to combine two QColor objects with alpha channel?

I have objects where the border color has already been determined.
Now I want the user to be able to set at least the opacity of the fill pattern. E.g., the border is blue. The user sets the opacity to 128, so the fill pattern is also drawn in blue, but half-transparent.
The next step would be to allow the user to also slightly adjust the color of the pattern. E.g.: "Use the border color, but make it half-transparent (alpha=128) and a little bit yellow-ish.".
Is there a (useful) way to combine two colors where one does not have an alpha value set? Or would it make more sense to set an alpha value on the original color and combine it with an "overlay color" that also has an alpha value set?
And is there a function (or otherwise, can someone give a short code snippet) to combine the two QColor objects?
I would look at existing color pickers that are out there (Gimp, Photoshop, Paint, wwWidgets). Most of them deal with a few different ways of picking your color:
Saturation, Hue, Value, Brightness, Contrast, RGB, CMYK, HSV, Alpha/Opacity.
Qt handles a bunch of these right out of the box:
QColor
In order to combine two colors, I would probably average their different components together:
// Rough pseudocode
Color1 RGBA, Color 2 RGBA, Color 3 = combination
Color3.R = (Color1.R + Color2.R)/2
Color3.G = (Color1.G + Color2.G)/2
Color3.B = (Color1.B + Color2.B)/2
Color3.A = (Color1.A + Color2.A)/2
I hope that helps.
PS: Understanding Color Space can be helpful, too.

Resources