Specify the type of the output of a Calculator filter - paraview

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.

Related

Coloring by an unsigned char array

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."

Exchange phase of 2 image's fft and reconstruct [duplicate]

I'm using MATLAB for image processing and I came across a code with the instruction:
imshow(pixel_labels,[]);
when executed it give a binary image.
I have check the manual of the function on Mathworks.com, the most similar used mode is
imshow(I,[low,high]);
but they don't say a thing about the case where that array is empty ([])
I tried to remove it:
imshow(pixel_labels);
but all I see is a white board. I would like to know what is happening in the first use case (imshow(pixel_labels,[])), I hope from there I will understand why I get a white board in the last use case.
If I type help imshow in MATLAB, the first paragraph reads:
IMSHOW(I,[LOW HIGH]) displays the grayscale image I, specifying the
display
range for I in [LOW HIGH]. The value LOW (and any value less than LOW)
displays as black, the value HIGH (and any value greater than HIGH) displays
as white. Values in between are displayed as intermediate shades of gray,
using the default number of gray levels. If you use an empty matrix ([]) for
[LOW HIGH], IMSHOW uses [min(I(:)) max(I(:))]; that is, the minimum value in
I is displayed as black, and the maximum value is displayed as white.
so [] is simply shorthand for [min(pixel_labels(:)) max(pixel_labels(:))].

matlab: variable horizontal alignment of text

Text objects in MATLAB contain a horizontal alignment property, which can be assigned a value of left, center, or right. Attempts to assign this property by a vector of alignments of equal length to the vectors of strings and coordinates fails to give the intended behavior.
For instance, a statement of the form :
text([1,1,1]/4,[1,2,3]/4,{'ABC';'BCD';'CDE'})
displays the contents of a length-3 cell array of char objects at the X- and Y-coordinates specified by length-3 double arrays. However, attempting to introduce a length-3 cell array of char objects for independent specification of the horizontal alignment of each text element is syntactically invalid;
e.g.,
text([1,1,1]/4,[1,2,3]/4,{'ABC';'BCD';'CDE'},'HorizontalAlignment',{'left';'center';'right'})
My question concerns whether it is possible to specify the HorizontalAlignment property of MATLAB text objects in a variable manner without resorting to constructs explicitly involving loops and conditionals.
You can't assign multiple property values upon creation, but once you have a vector of handles, you can use the many-to-many form of set() like so:
h = text([1,1,1]/4, [1,2,3]/4, {'ABC';'BCD';'CDE'});
set(h, {'HorizontalAlignment'}, {'left';'center';'right'});
The value array has one row per object, one column per property.

When I write the image it appears black

I have a program that returns a grayscale image. But, when I try to write the image, it appears totally black. Why is that? How can I write the image and get the expected result?
Thanks.
First check on the type of your data. You can cast the type of the data by example double() or uint16() etc. (Check the help for typecasting).
Here is an example how you rescale your values to the intensity-range of uint16, unsigned integers with ~65k possible different values. The casting of course leads to less precision of the intensity values.
new_img(:,:) = uint16((new_img(:,:)./max(max(new_img(:,:),[],1)))*65536);
Afterwards you should be able to write the data to your file.
Make sure that your grayscaled image is of the right class. Furthermore check the values in the generated image. If they're simply too low all will appear black. If you can provide more specific information it might be possible to give a more elaborate answer.
if you're working on a binary image(before being converted to gray) and you about to convert it to gray-scale, then you suddenly change the range of pixels from [0, 1] to [0, 255]. so the value '1' in binary image is totally white but in gray-scale image is almost black.
try this:
img = imread('image_name.jpg');
imshow(img*50)
it make you sure that you image is black or just its pixel-values aren't appropriate.

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