POV-Ray : Newsgroups : povray.binaries.images : An experiment in monochrome : Re: An experiment in monochrome Server Time
2 Aug 2021 18:13:37 EDT (-0400)
  Re: An experiment in monochrome  
From: m@b
Date: 9 Jun 2021 05:09:23
Message: <60c08543@news.povray.org>
Here is the script:

// author:  Matthew Bradwell
// date:    2021
//--------------------------------------------------------------------------
#version 3.7;
global_settings{ assumed_gamma 1.0 }
#default{ finish{ ambient 0.1 diffuse 0.9 }}
// camera ------------------------------------------------------------------
camera {perspective
     angle 28
     location  <0,5,-30>
     look_at   <0,5,0>
     right x*image_width/image_height}

#background{rgb<0.5,0.5,1>*1.5}

//---------------------------------------------------------------------------
//---------------------------- objects in scene ----------------------------
//---------------------------------------------------------------------------


// Input fie name and dimensions

//#declare In_Image = "Face 1a.jpg";  #declare In_Height = 1575; 
#declare In_Width  = 1587;
#declare In_Image = "RGBColors 3.jpg";  #declare In_Height = 811; 
#declare In_Width  = 925;

#declare In_Ratio  = In_Width/In_Height;

// Reference image bottom right
box{<0,0,0>,<1,1,0.01> pigment{image_map {In_Image map_type 0}} scale 
<In_Ratio,1,1>*2 translate<5,0,-1> finish{emission 1}}

#declare MyTesti = function    // In order to get the HF_ macros to read
{ pigment                      // imported pictures they have to be
   { image_map                  // declared this way.
     { In_Image  map_type 0 // <----
       once
     }
   } 

}

#declare TestR = function {MyTesti(x,y,z).red}      // Extract colours
#declare TestG = function {MyTesti(x,y,z).green}
#declare TestB = function {MyTesti(x,y,z).blue}
#declare TestK = function {MyTesti(x,y,z).grey}


#declare Resolution = 0.015;        // Spacing between the lines, 
remember image maps are 1 x 1
#declare Gain = 1.3;                // Line thickness
#declare Bias = 0.07;               // To increase the output if very 
light areas are not drawing
#declare Grey_threshold = 0.003;    // Greyness is detected if R, G & B 
are equal, this sets the acceptance level


#for(X, 0, 1, Resolution) 
         // Scan the functions
     #for(Y, 0, 1, Resolution)

         #declare Brightness =  Bias+(Gain*(1-TestK(X,Y,0)));

         #declare GreyTest = 0.001 + abs(TestK(X,Y,0) - 
abs((TestR(X,Y,0)+TestG(X,Y,0)-TestB(X,Y,0))));

         #if(GreyTest < Grey_threshold) 
          // Decide the line angle
             #declare Angle = 0; 
          // Grey (Incuding black and white)
         #else
             #if(TestR(X,Y,0) > TestG(X,Y,0) & TestR(X,Y,0) > TestB(X,Y,0))
                 #declare Angle = 45; #declare Brightness = 
Brightness*0.8;      // Red
             #else
                 #if(TestG(X,Y,0) > TestB(X,Y,0))
                     #declare Angle = 90; 
          // Green
                 #else
                     #declare Angle = -45; #declare Brightness = 
Brightness*0.8; // Blue
                 #end
             #end
         #end
         // Draw the line segment
         sphere{<0,0,0>,0.04 pigment{rgb <0,0,0.5>} 
scale<8,Brightness,0.1> rotate<0,0,Angle> translate<X-0.5,Y,0>*10 
finish{emission 1} scale<In_Ratio,1,1>}

     #end
#end


Post a reply to this message

Copyright 2003-2021 Persistence of Vision Raytracer Pty. Ltd.