Coloring by an unsigned char array - paraview

I have a data set with some points+vertices and an unsigned char array named "Colors" (on the Cell Data) where every tuple is (255,0,0) (i.e. indicating that all of the vertices should be red). In the Information tab, it looks as expected:
However, in the Properties tab, when I set Coloring to "Colors", I have to choose between Magnitude, X, Y, and Z, none of which are what I want. Instead, I want to use the actual vector to provide the RGB coloring.
Can anyone explain how to specify that these are actually colors and should be used directly?

After coming across this post, I learned that you have to uncheck "Map Scalars" in the Advanced section of Properties.
"Clicking the gear icon next to the search bar will show all properties
for the current source/representation and the map scalars/interpolate
scalars should be among them."

Related

Specify the type of the output of a Calculator filter

It seems as though the result of a Calculator filter is always a double array. Is there a way to change this type? For example, if I create a Sphere Source, then use a Calculator filter with the following:
1*iHat + 2*jHat + 0*kHat
I get an array that could theoretically be used to color the points (i.e. it is interpretable as RGB 3-vectors), but it is of type 'double' so Paraview cannot use it for coloring (without color mapping).
As of ParaView 5.1.2, and perhaps earlier versions, you can actually interpret 3-tuple arrays of doubles as colors the way you describe. Color values are specified in the range [0, 1] for double and float arrays instead of [0, 255] for unsigned char arrays.
To show these Calculator-defined colors without color mapping, color by the Calculator output array, then uncheck the option Map Scalars in the Properties panel.

Way to get a color while transitioning

I thought about the whole transition thing, and also saw while a text's color is being transitioned - it crosses through other tints of colors.
I had a lot of situations when I saw a beautiful color which I wanted, but it was a part of the transition process, and I eventually couldn't accomplish it.
For example, this code:
HTML:
<div id="transition">
ultra super califragilisticexpialidocious
</div>
CSS:
#transition {
color:black;
transition: 1s color;
}
#transition:hover {
color:#f00;
}
A demo: JsBin
You could see the transition shows a maroon color while text is transitioned, and my meaning is, how can I get this special tint of maroon?
Generally, my question is, how can I get a color while it is transitioned? There's a way to pick it?
Thanks in advance
Well, the things we think we like most are often those that are hard to get ;-)
But it's not so hard in this case. The question is whether picking the transitioning color is the best way to get what you want. Wouldn't it be simpler to change the color by hand until it looks best?
This is how to easily change a displayed font color with the Firebug plugin of Firefox:
Open the page with the transition and open the Firebug window.
Select the HTML tab, and then the Style tab of the side panel (if the side panel is closed, open it by clicking on the small arrow in the top right corner).
Click on the button with the mouse pointer in the top left corner of the Firebug window, then click on the div with the transition, thus selecting it.
You may want to disable the transition in the style, by clicking to the left of it.
You may want to display colors in RGB instead of hex (you can toggle back and forth when you want), by clicking on the dropdown button in the Style tab and selecting the mode you want.
You can click on the color value to edit it. Instead of rewriting it, you can click again on a single component (works in hex mode too), and then use the up and down arrow keys. It's almost like having a slider for each component. If you have the whole value selected, the arrow keys change all three components simultaneously.
Chrome is almost identical in operation. You open the Developer Tools with Ctrl-Shift-I, select an element with the magnifier button, and edit its style. You can toggle between hex colors and RGB colors by clicking on the gear-wheel within the Styles window. The difference with Firebug is that you can only modify the single RGB values with the up and down arrow keys when in RGB mode, in hex mode the arrow keys can only change the hex value as whole (i.e., starting from the B channel).
Knowing the numerical values of the endpoint colors of the transition, you can guess the numerical values of the "transition color" you want. The numerical value of each RGB (red, green, blue) component will be an intermediate value between its endpoints, more or less close to one of the two endpoint values.
The browser is free to interpolate by using the algorithm it prefers. The easiest algorithm moves colors along a straight line in the three-dimensional RGB space. Interpolated colors in this case (called linear interpolation in RGB space) are integer approximations of
R = R[0] * (1 - t) + R[1] * t
G = G[0] * (1 - t) + G[1] * t
B = B[0] * (1 - t) + B[1] * t
for t varying from 0 to 1. For t = 0.5 you get the color which is linearly (in RGB) halfway between the two endpoints. The parameter t may be any function of time (in the simplest case it is a linear function, which means that the color moves at constant speed in RGB space between the two endpoints).
As I said, the browser is free to interpolate in a more complicated way, in order to achieve a better visual result. If you really need to see what the browser does, you can slow it down to snail speed (e.g., by editing the transition-duration with Firebug), then grab the screen (e.g., by pressing the "Print Scrn" key), open your favorite image editor, paste the printed screen (often by pressing Ctrl-V), and finally select a fully colored pixel to get the RGB values of your long craved color.
BTW, your test case is particularly easy, because the endpoints are (0,0,0) and (255,0,0), so that the maroon color you are after is almost certainly nothing but a dark red of the kind (x,0,0). You only have one parameter to vary, you can even do it by trial and error with an editor!

Controlling the color of text in an array based on a predefined condition

I am trying to display a matrix M of size 50x8 with a plot using text([x,y],M). All the entries in matrix are at present of the same color. I would like more control on the display, and would like that all matrix entries satisfying a particular condition should be of different color.
One of the possible ways to do is to specify the position for each of the elements of the matrix M individually in text(x,y,M_ij). But I am only specifying the position for the first element, and other positions are being assigned automatically. How can I get those positions, or control them? This will allow me to control the colors as well.
The resulting text graphics object is only one object, so you can't adjust the color through handle graphics without affecting all of the rows. But if it's possible for you, you can specify the color directly in the strings. To do this, you'll probably need to represent your strings as a cell array instead, so they can have different colors.
M = {'\color{red}Line 1';'\color{blue}Line 2';'\color[rgb]{.6 .8 .2}Line 3'};
text(1, 1, M);
The reference for other inline string markup is found on this doc page, in the 'String' property: http://www.mathworks.com/help/matlab/ref/text_props.html

excluding all documents that have indexed in a particular field elements that are not part of a given set

In my Lucene search I want to exclude all documents that have indexed in a particular field elements that are not part of a given set.
For example, lets say my document represents a drawing. and has a color field. In the color field I index all the colors that are used in a drawing. Now say I have access to say five colors. red, blue, green, purple, and brown. I want to only retrieve drawings that use these colors and any drawing that has a color not in the colors mentioned above should be excluded. If I want all drawings that use all these colors and nothing but all these colors, I can add a new field to my document for 'number of colors' and then build my Boolean query by adding MUST term queries for each of the colors and also adding a MUST Boolean query with the count as the number of colors. But I want to also retrieve all documents that have any combination of the 5 colors mentioned above. So a drawing that is done entirely with brown would also be retrieved.
Please note that I have thousands of colors. So creating a field for each color and then doing a MUST_NOT for everyone other than my 5 colors would also not be an option.
Many thanks!
I don't think there are built-in ways of doing that. Instead, you want to store the set of colors (that a particular drawing contains) somewhere. Then, as you go through each search result at search-time, you load the color set, check if it contains any of the "other" colors, and filter the result accordingly.
That somewhere can be any of at least two places:
Stored field: For example, you can store the color set as a comma-delimited list of color names as a String.
Term vector: If you index the color field with term vectors, then at search-time, you can call IndexReader.getTermFreqVector(int, String) to get the term vector information of that document/field. The resulting TermFreqVector object gives you a list (actually a set) of terms (i.e. colors in your case) in that field.

Matlab: Adding symbols to figure

Below is the user interface I have created to simulate LDPC coding and decoding
The code sequence is decoded iteratively by passing values between the left and right nodes through the connections.
The first thing it would be good to add in order to improve visualization is to add arrows to the connections in the direction of passing values. The alternative is to draw a bigger arrow at the top of the connection showing the direction.
Another thing I would like to do is displaying the current mathematical operation below the connection (in this example c * H'). What I don't know how to do is displaying special characters and mathematical symbols and other kinds of text such as subscript and superscript in the figure (for example sum sign and subscript "T" instead of sign ="'" to indicate transposed matrix).
I would be very thankful if anyone could point to any useful resources for the questions above or show the solution.
Thank you.
To add arrows, you can either use the built-in QUIVER, or, for more options, ARROW from the file exchange. Both of these have to be plotted into axes, so if you want a big arrow on the top, you have to create an additional set of axes above the main axes.
As far as I know, you cannot use TeX or LaTeX symbols in text uicontrols. However, you can use them in axes labels. Thus, I suggest that you add an XLabel to the axes, for example
xlabel('\sigma c*H_T')
or (note the $-signs required for LaTeX)
xlabel('$\sum c*H_T$','interpreter','latex')
EDIT
I hadn't mentioned the use of text (as suggested by #gnovice and #YYC) because I thought it wasn't possible to place text outside of the axes. It turns out that I was wrong. text(0.5,-0.2,'\Sigma etc.') should work fine as well. I guess the only advantage of using 'xlabel' would be that you can easily add and position the axes label during GUI creation.
In regards to the 1st question, annotation (http://www.mathworks.com/access/helpdesk/help/techdoc/ref/annotation.html) might be an alternative solution.
In regards to the 2nd question, try text property in Matlab Help.
Search "Character Sequence" for the special characters; search "Specifying Subscript and Superscript Characters" for the subscript and superscript.
For drawing the arrow, I would go Jonas' suggestion arrow.m by Erik Johnson on the MathWorks File Exchange. It's the easiest way I've found to create arrows in figures.
For creating text with symbols, you can use the function TEXT. It lets you place text at a given point in an axes, and you can use the 'tex' (default) or 'latex' options for the 'Interpreter' property to get access to different symbols. For example, this places the text you want at the point (0,0) using 'latex' as the interpreter:
hText = text(0,0,'$\sum c*H_T$','Interpreter','latex');
The variable hText is a handle to the text object created, which you can then use with the SET command to change the properties of the object (string, position, etc.).