in reply to A data selection problem(in3D).

Hi,

Do you have to select or can you generate?

My idea is use the color picker tool to pick the 5 colors from the image you like, and then generate the colors inbetween, with total amount of steps that adds up to 256,

like this "black body" colormap used is for photoshop fire effect

code

sub BlackBody { ColormapHtml( BlackBodyMap() ); ColormapHtml( GreyscaleMap() ); } sub ColormapHtml { my $blackbody = shift; print "<table>"; while(@$blackbody){ print "<tr>"; #~ for(1..8){ #~ for(1..16){ for(1..32){ my $color = shift @$blackbody; #~ my $hex = join '', map { pack 'H*', $_ } @$color; my $hex = rgb2hex( @$color ); #~ print qq[<td bgcolor="#$hex"><font color="#$hex">$hex</ +font></td>]; print qq[<td bgcolor="#$hex"><font color="#$hex">_</font>< +/td>]; } print "</tr>"; } print "</table>"; } sub rgb2hex { #~ my( $r, $g, $b ) = @_; sprintf '%02x%02x%02x', @_; } sub BlackBodyMap { my $one = [ 255, 0, 0 ] ; my $two = [ 255, 255, 0 ]; my @colormap = ( YuckFoo( 85, [0,0,0] => $one ), YuckFoo( 85, $one => $two ), YuckFoo( 86, $two => [255,255,255] ), ); return \@colormap; } sub GreyscaleMap { return [ YuckFoo(256, [0,0,0] => [255,255,255] ) ]; } sub YuckFoo { my( $steps, $beg, $end) = @_; # RGB rate of change from beginning to ending color my @delta = ( ($$end[0] - $$beg[0]) / ($steps-1), ($$end[1] - $$beg[1]) / ($steps-1), ($$end[2] - $$beg[2]) / ($steps-1), ); # Calculate colors using beginning color and rate of change my $i = 0; my @gradient; while($i < $steps) { my $color = [ $$beg[0] + $i * $delta[0], $$beg[1] + $i * $delta[1], $$beg[2] + $i * $delta[2] ]; push @gradient, $color; $i++; } return @gradient; }
________________________________
________________________________
________________________________
________________________________
________________________________
________________________________
________________________________
________________________________
________________________________
________________________________
________________________________
________________________________
________________________________
________________________________
________________________________
________________________________

Replies are listed 'Best First'.
Re^2: A data selection problem(in3D).
by BrowserUk (Patriarch) on Apr 06, 2017 at 11:29 UTC
    Do you have to select or can you generate?

    No, I don't have to select -- that image was essentially chosen at random (with some aesthetic judgement applied) from an image search for 'gold'; so its data is far from sacrosanct -- but I have tried generating a gold-scale and found it very difficult to do. My attempts so far have produced gradients with either distinct banding, or limited range (too much near black at the bottom and bright yellow near the top), or too strong a tint towards red or yellow throughout the gradient.

    Then I tried finding an image that contained a smooth transition from lowlite to hilite from which I could crop a smooth gradient; but they are either too short, resulting in banding when applied to a CG image; or they contain waves and distortions (due to surface irregularities or secondary reflections) that show up as non-linear transitions in CGs.

    That's when I hit on the idea of sampling an image (like the source image in the root node) and subsetting it 'somehow'.

    The problem (I think) is that, whether subsetting or generating, I need to transition through the relevant hsv space in 3 dimensions rather than 2; and probably not in a straight line either to boot.

    To explain: if you look at this image which shows 3 views of the same dataset.

    • The top-left image is all the datapoints overlain in the hsv-H dimension; but drawn pre-ordered by their hsv-H values so that the left-hand end of the original H-frames view is 'deepest' in the Z-axis, which means only a few of the blacks in the top left corner come from the early frames and the whites in the bottom left come from the right-hand frames.
    • The lower left view overlays the hsv-V values.
    • And the upper right overlays the hsv-S values.

    What I think those views show is that I need to select or generate a path through that subset of the hsv gamut, traversing in a kind of S-shape. But an S-shape in all 3 dimensions!

    That is, starting at the lower left of the top-left view, proceeding mostly right for the first (say) 10% then somewhat steeper than 45 degrees across the middle, and then at a shallow angle for the last 10% or so into the top-right corner.

    But also, tracing a similarly shallow S-shape (diagonally) in both other dimensions at the same time. bottom-left to top-right in the bottom left view; and bottom-right to top-left in the upper-right view.

    But once again, I'm stuck for a good way to do that?


    With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
    Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
    "Science is about questioning the status quo. Questioning authority". The enemy of (IT) success is complexity.
    In the absence of evidence, opinion is indistinguishable from prejudice.