[Radiance-general] Falsecolor tricks

Axel Jacobs jacobs.axel at gmail.com
Tue Nov 12 13:27:31 PST 2013


Hi Michael,

the question of extracting certain regions of interest from an HDR 
occupied me a couple of years ago. The box filter approach that Greg is 
suggesting is certainly doable. However, if you want more than the 
neighbouring 8 pixel, you will have to think about how useful a 'box' is 
as opposed to all pixels within a certain radius, ie a 'circle'.

If you take this a little further (and out of your FC context), then you 
might wish to extract a number of shapes from an HDR image:
- circles, ellipses
- squares, rectangles
- points
- lines
- polygons
- masked areas (b/w HDR image)

The latter is easily doable, but all the other shapes are not, unless 
they are cast into a mask first. Well, I supposed arbitrary 'boxes' can 
be done, too.

Back then, I wrote a Python script that I named pextract. It never 
worked to my complete satisfaction, mostly because it was agonisingly 
slow. It took several minutes for a 3 or so megapixel HDR to be 
processed. Part of the reason might be that this was a pure Python HDR 
reader, and I did very little in terms of optimising the RGBE parser.

Help output is below to give you an idea of what it did:

$ pyray_pextract.py -h
Usage: pyray_pextract.py [options] file.hdr

Exactly one action is required.

Options:
   --version             show program's version number and exit
   -h, --help            show this help message and exit
   -f, --flip            The origin of an HDR image is at the bottom-left
                         corner. This switch inverts the row order, 
putting the
                         origin at the top-left. This is the convention for
                         most image processing software [default: False].
   -a, --all             Instead of dropping all pixels outside of the 
shape,
                         colour them black and output them, too. This can be
                         used for reverse-assembling a new HDR image, and is
                         useful for testing and debugging.
   -d, --data-only       Output data only, do not print x and y pixel 
position.

   Actions:
     -l x0,y0,x1,y1, --line=x0,y0,x1,y1
                         Extract values along a line.
     -r x0,y0,x1,y1, --rectangle=x0,y0,x1,y1
                         Extract values inside a rectangle.
     -e x0,y0,x1,y1, --ellipse=x0,y0,x1,y1
                         Extract values inside an ellipse.
     -p x0,y0,x1,y1,...,xn,yn, --polygon=x0,y0,x1,y1,...,xn,yn
                         Extract values inside a polygon.

What I am trying to say with all this is this: Yes, a box shaped extreme 
is doable, but I wonder how much use it would be for anything other than 
a VERY specific purpose. It is also easy enough to create a circular b/w 
mask with pcomb and link this mask into FC, but this would put all sorts 
of if and but statements into the FC code, and might quickly become 
ugly. In all likelihood, you will also wish to indicate the box/circle 
coordinates in the legend or a caption, since by just looking at the FC 
image, it would not be apparent how the label got there, and what it 
represents.

In that sense, I'd be inclined to say that the 'value at specific x,y' 
you mentioned in your earlier post would probably be more generally 
useful. As it happens, I am currently working at a project where exactly 
this functionality might be required. My quick-n-dirty approach would be 
to extract the value with pvalue, grep for the pixel, then stick the 
label onto the FC image (or even the LDR image--ImageMagick is pretty 
cool) afterwards. I might look into this as a new feature for FC if 
there is general interest.

Regards

Axel


On 12/11/13 20:10, Greg Ward wrote:
> Yes, it's possible.  You just need to hack falsecolor.
>
> Is that the answer you're looking for?
>
> More detailed:  Use pfilt to box-filter the image, then run pextrem on
> the output.  Upscale the positions it gives you and reinsert them in the
> appropriate place in the code.
>
> An option to do this could be added if it's of general interest.  Axel
> Jacobs is the maintainer of falsecolor.pl <http://falsecolor.pl> these days.
>
> Cheers,
> -Greg
>
>> *From: *Michael Martinez <michael at coolshadow.com
>> <mailto:michael at coolshadow.com>>
>>
>> *Date: *November 12, 2013 11:42:11 AM PST
>>
>> *
>> *
>>
>> Hi folks - one more question about falsecolor hacks.
>>
>> any chance one could make -e in falsecolor return not the extrema
>> pixels, but the extrema pixels averaged by their immediate neighbors
>> (8 surrounding pixels), or possibly an even larger radius or
>> neighboring pixels? in other words, i'd like to highlight the maximum
>> value on a set of images, but instead of a single point, a larger
>> 'extrema zone' on the image.
>>
>> Thanks for any ideas...
>>
>> MM
>>
>>
>>
>>
>> On Sep 24, 2013, at 3:21 PM, Greg Ward wrote:
>>
>>> Funny -- I guess I'm repeating myself!  I didn't think of using
>>> ra_xyze -o before, though, so maybe a slight improvement...
>>>
>>> -Greg
>>>
>>>> *From: *Christian Humann <chris at coolshadow.com
>>>> <mailto:chris at coolshadow.com>>
>>>> *Date: *September 24, 2013 2:54:04 PM PDT
>>>> *
>>>> *
>>>> Hi Michael,
>>>>
>>>> I had asked a similar question several years ago on how to extract a
>>>> value at a specific pixel location in the original HDR image. Greg
>>>> responded with the following (you'll have to pass the result to the
>>>> equivalent pixel location in the false color HDR using psign  piped
>>>> into pcompos *don't forget to add the pixel width of the false color
>>>> scale  to the x-location in the false color image);
>>>>
>>>> From Greg…….
>>>> If you haven't passed the picture through pfilt or otherwise
>>>> introduced an exposure change, then it would be much faster to use
>>>> pcompos to extract the value you're interested in.  E.g.:
>>>>
>>>> pcompos -x 1 -y 1 rendered_image.hdr -Xpos -Ypos | pvalue -h -H -d |
>>>> rcalc -e '$1=($1*0.265+$2*0.670+$3*0.065)*179'
>>>>
>>>> If getinfo shows one or more EXPOSURE= lines in the header, then the
>>>> above won't quite work and you'll need to use pvalue.  The syntax
>>>> for the command you want is:
>>>>
>>>> pvalue -o -h -H rendered_image.hdr | rcalc -e
>>>> 'eq(a,b):if(a-b+.5,b-a+.5,-1);and(a,b):if(a,b,a)' \
>>>> -e 'cond=and(eq($1,x_location),eq($2,y_location))' -e
>>>> '$1=$3;$2=$4;$3=$5'
>>>>
>>>> Nasty, eh?  It's also slow.  Use pcompos if you can.  A faster
>>>> alternative to the above is to use sed:
>>>>
>>>> pvalue -o -h -H rendered_image.hdr | sed -n 's/^ *x_location
>>>>  *y_location //p'
>>>>
>>>> EXAMPLE:
>>>> pvalue -o -h -H dec_cie_43-63tvis_dome_sit_west.hdr  | sed -n 's/^
>>>> *284  *248 //p' | rcalc -e \ '$1=($1*0.265+$2*0.670+$3*0.065)*179' >
>>>> value.txt
>>>> _________________________
>>>>
>>>> For the second part
>>>>
>>>> ex:
>>>> psign -cf 1 1 1 -cb 0 0 0 -h 16 the_value_from above  | pompos
>>>> falsecolor_image.hdr +t .5 - x_location y_location >     image_out.hdr
>>>>
>>>>
>>>>
>>>> Hope this helps,
>>>>
>>>> Chris
>>>> On Sep 24, 2013, at 1:25 PM, Michael Martinez
>>>> <michael at coolshadow.com <mailto:michael at coolshadow.com>> wrote:
>>>>
>>>>> Hi All -
>>>>>
>>>>> I'd like to make falsecolor stamp an image with a value for a
>>>>> single pixel of my choosing (say at 250, 300 in a 1000px x 700px
>>>>> image), similar to how -e works. This is to show irradiance levels
>>>>> changing at a given point in a sequential animation. Anybody have a
>>>>> trick to do this, or something like it?
>>>>>
>>>>> Thanks very much,
>>>>> Mike





More information about the Radiance-general mailing list