Is it possible to color the rows in a Power Query based on a formula?
I have tree conditional formats in my Excel sheet and would like them in a query
=$A2-TODAY()>13 (color green), =$A2-TODAY()<1 (color red), =$A2-TODDAY()<14 (color orange)
Related
I'm trying to modify the text for labels already plotted on the chart, but I'm not able to.
Example: in this Pivot script I want to change the black check mark symbol to a red X when price moves above the high of the Pivot Candle. Meaning that all Pivot Candles whose highs are lower than current price should be red Xs.
In this image the red circles represent what should be red Xs, while the green circles are right as they are.
Thank you in advance!
//#version=4
study("change labels in the past", overlay=true)
// Pivot definition
highPiv = pivothigh(high, 2, 2)
barcolor(highPiv ? color.blue : na, offset=-2)
// If price at the current time is higher than any High Pivot, change the Pivot Icon to a red X (oonly the ones currently under the price line)
HighVal = valuewhen(highPiv, high[2], 0)
priceOverHigh = close > HighVal
if highPiv
a=label.new(bar_index[2], close[2], text="✔️", style=label.style_label_down, color=color.new(color.black, 100), size=size.normal)
if priceOverHigh
label.set_text(id=a, text="❌")
Based on the code given by Image Analyst in the answer to “3d plot of an image“ question (http://www.mathworks.com/matlabcentral/answers/48532-3d-plot-of-an-image) I have a follow-up question:
I simplified the code and I would like to know is it possible to apply on it the jet colormap according to the gray scale intensity (Z axis) and also to fit it to the image dimensions (x,y) (e.g, in this image example the dimensions are 628x600 and therefore max x=628 and max y=600).
Thanks.
Code:
I = imread('E:\Temp\Canadian_maple_leaf_2.jpg'); % http://en.wikipedia.org/wiki/File:Canadian_maple_leaf_2.jpg
I=rgb2gray(I);
I = imcomplement(I);
[rows columns numberOfColorBands] = size(I);
surf(double(I));
If I understand the question correctly, changing the colormap and turning the edge colours off is what you are looking for
surf(double(I),'EdgeColor','none');
colormap jet
If you want to tighten the boundaries of the plot, you can use
axis([0 columns 0 rows min(double(I(:))) max(double(I(:)))])
Though I have found a lot of topics on color tint and temperature, but till now I have not seen any definite solution, which is the reason I am creating this post..My apologies for that.
I am interested in adjusting color temp and tint in images from RGB values, somewhat similar to the iPhoto application found in iOS where it can be adjusted with a slider bar from left to right.
Whatever I have found, temp and tint are orthogonal properties, where temp adjustment is along the blue (left; cool colors)--yellow(right; warm colors) and tint along the green (left) -- magenta (right) axis.
How do I adjust them using formulas from RGB values i.e., uderlying implementation of the color temp and tint slider bars.
I can convert them to HSV space and then I can rotate the hue wheel channel towards those (blue, yello, green, magenta) angles, but how to do them in a systematic fashion similar to the slider bar implementation by changing gradually from low level (middle of the slider bar) to high level (right/left ends of the slider bar).
Thanks!
You should try using HSL instead of HSV. HSL saturation separates itself from the hue and luminosity has very definitive range when it comes to mathematical calculation.
In HSL, to add tint you move the L factor between 50-100 and to add shade the L factor varies between 0-50. Also saturation for HSL controls the tone directly unlike HSV.
For temperature, you have to devise your own stratagy changing the color between red and blue but one golden hint that I can give you is "every pure RGB color has one of 3 color values as zero, second fixed to 255 and 3rd varies with the factor of 255/60.
Hope this helps-
Whereas color temparature is a physical value, its expression
in terms of RGB values
not
trivial. If all you need is a pair of orthogonal axes in the RGB colorspace for the visual adjustment of white balance, they can be defined with relative ease in such a way as to resemble the true color temperature and its derivative the tint.
Let us name our RGB temperature BY—for the balance between blue and yellow, and our RGB tint GR—for the balance balance between green and red. Now, these functions must satisfy the following obvious requirements:
They shall not depend on brightness, or be invariant to multiplication of all the RGB components by the same factor:
BY(r,g,b) = BY(kr, kg, kb),
GR(r,g,b) = GR(kr, kg, kb).
They shall be zero for neutral gray:
BY(0,0,0) = 0,
GR(0,0,0) = 0.
They shall belong the to same range, symmetrical around zero point. I will use [-1..+1]
Any combination of BY and GR shall define a valid color.
Now, one of the ways to define them could be:
BY = (r + g - 2b)/(r + g + 2b),
GR = (r - g )/(r + g) .
so that each pair of BY and GR determines a specific proportion
r:g:b = (1 + BY)(1 + GR)
(1 + BY)(1 - GR)
1 - BY
The following image shows the colors of maximum brightness on our BY-GR plane. BY is directed right, GR down, and the neutral point (0,0) is at the center:
Proper
adjustment of white balance consists of multiplication of the linear RGB values by individual factors:
r_new = wb_r * r_old
g_new = wb_g * g_old
b_new = wb_b * b_old
It happens to work on gamma-compressed RGB too, but not so well on sRGB, because of a
piece-wise
definition of its transfer function, but the distortion will be small and often unnoticeable. If you want a perfect adjustment, however, make sure to work in linear RGB.
Once a BY-GR pair is chosen and the corresponding RGB proportion calculated, only one degree of freedom remains—the overall multiplier (see req. 1). Choose it so that no pixels become clipped.
I am using the connected component labeling algorithm in Matlab. Is it possible to use different color for different labels when showing the output? (Even though the labels have the same intensity).
Clarification:
I used connected component labeling algorithm to label the connected components of a binary images. Now I got different labels. All the labels contains pixel of equal intensity. (All the labels have pixel intensity value of 1) and all the labels appear in the same color. I want to display the different labels using different colors so that I can eliminate the unwanted one easier.
That is easy - use the imagesc function:
p = imread('peppers.png'); %Read image
b = (p(:,:,2)>100); % Thresholding by some constant threshold
If you already have a binary image, just use this section of the code: (b is the image)
L = bwlabel(b); %Find components
figure(); %Create figure
imagesc(L); %Draw the components, each in its own color.
You can also change the colors by using the colormap command:
colormap(bone)
In order to customize the colors, define an nx3 matrix, and give it as input to colormap
cm = [1 0 0;
0 1 0;
0 0 1
0 1 1
1 1 0
];
colormap(cm)
I have a basket of flowers and I want them to tag and sort by their Color. Any ideas on how this can be done, will be very helpful.
Thanks much for your time.
The most obvious solution would seem to order by hue.
This would give you a stable sorting comparison operator that would sort your array in this order:
Note that some RGB colors are degenerate in the sense that they don't have a single HLS form. White is such an example. It's up to you how you're going to handle them.
You can do this using the concept of Lexicographic ordering.
Basically, given the HSL representations of 2 colors (say C1 = (H1, S1, L1) and C2 = (H2, S2, L2)), we can define C1 < C2 if and only if ((H1 < H2) || (H1 == H2 && S1 < S2) || (H1 == H2 && S1 == S2 && L1 < L2)), and C1 == C2 if and only if H1 == H2 && S1 == S2 && L1 == L2. Similarly for C1>C2.
This will order the colors first by hue; then by saturation to resolve hue conflicts; and finally by lightness to resolve hue and saturation conflicts.
I've used the precedence order H > S > L in this example, but you could just as easily use some other order according to your needs, or maybe even another color respresentation (e.g., RGB).
If you want to sort it by the actual color, not alphabetically by the name of the color, then the solution isn't very obvious. Sorting is normally done on entities where a clear "greater than" and "less than" semantic can be defined. Colors, though, don't have such a semantic because they're represented by 3 numbers generally (either RGB or HSV). You would have to arbitrarily define your own "ordering" and then sort using that.
you can compare colors in java see this
You could try taking the principal components of variance, then projecting on that axis. (So if all the colours are shades of red, red is non-zero, green and blue are both zero, and the algorithm would say the axis is 1.0, 0.0, 0.0. It then sorts on red. If they are all shades of yellow, then that axis is root(0.5), root(0.5), 0.0, it averages the red and green, and sorts on that).
It won't work well if the colours form three or more distinct "clouds".