getting pixel value at x,y

Hi list,

I wonder if noone else came to this problem, or if I just do not see the
answer to a rather simple problem.

Radiance comes with pvalue to extract pixel values of images. This is
fine, as long as images are small - just redirect to a file, and the
values can be read according to the coordinates written at the beginning
of the lines.

Now, for large images, this becomes a pain. E.g. if I want to get the
values of 64pixels, with known coordinates, I cannot read out these with
pvalue, but first must transform the complete image to a pvalue
formatted text file. These files can become hundreds of MB in size with
higher resolutions.

Is there an easier and more efficient way to go? E.g. cropping the image
first to the pixels wanted? I guess the only way to do so is pcomb,
right?

Lars.

1 Like

I was interested about this as well.. !!

Lucio

.Hi list,
.
.I wonder if noone else came to this problem, or if I just do not see the
.answer to a rather simple problem.
.
.Radiance comes with pvalue to extract pixel values of images. This is
.fine, as long as images are small - just redirect to a file, and the
.values can be read according to the coordinates written at the beginning
.of the lines.
.
.Now, for large images, this becomes a pain. E.g. if I want to get the
.values of 64pixels, with known coordinates, I cannot read out these with
.pvalue, but first must transform the complete image to a pvalue
.formatted text file. These files can become hundreds of MB in size with
.higher resolutions.
.
.Is there an easier and more efficient way to go? E.g. cropping the image
.first to the pixels wanted? I guess the only way to do so is pcomb,
.right?
.
.Lars.
.
.
._______________________________________________
.Radiance-general mailing list
[email protected]
.http://www.radiance-online.org/mailman/listinfo/radiance-general
.

.. Caminante no hay
camino, solo se hace
camino al andar ..

          --- o
meglio ---

.. Caminante el
destino no es al
final de el viaje,
pero en todo el
andar ..

Hi Lars and Lucio,

I can think of three possible ways to do this.

1) pfilt

    You can use pfilt to reduce the size of the image to something more
    manageable. I am not sure (this means see what others weigh in on
    this) but I think for some applications this may actually result in
    better overall values in the image as surrounding pixels are being
    averaged together by the reduction.

2) pcompos

    You can use pcompos to crop out an area of interest. You will have
    to read the man page carefully to figure this out but it is
    certainly doable.

3) script

    You can either write a script (perl for example) that will read the
    stdout from pvalue and only write values within a given XY pixel
    range or you can use radiance arcana as such:

        pvalue -h -H +d <name_of_image.pic> | rcalc -f
        <path_to_lib/rayinit.cal> -e 'boundp(a, x, b) = if(a-x, 0,
        if(x-b, 0, 1)); xyboundp(xa, x, xb, ya, y, yb) = and(boundp(xa,
        x, xb), boundp(ya, y, yb)); cond = xyboundp( <xstart>, $1,
        <xend>, <ystart>, $2, <yend>); $1 = $1; $2 = $2; $3 = $3; $4 =
        $4; $5 = $5;'

        This should work presuming I transcribed into my mail client
        correctly....

        where you need to input:

            <name_of_image.pic>
            <path_to_lib/rayinit.cal>
            <xstart>
            <xend>
            <ystart>
            <yend>

I hope this helps.

Best,

-Jack de Valpine

Lars O. Grobe wrote:

···

Hi list,

I wonder if noone else came to this problem, or if I just do not see the
answer to a rather simple problem.

Radiance comes with pvalue to extract pixel values of images. This is
fine, as long as images are small - just redirect to a file, and the
values can be read according to the coordinates written at the beginning
of the lines.

Now, for large images, this becomes a pain. E.g. if I want to get the
values of 64pixels, with known coordinates, I cannot read out these with
pvalue, but first must transform the complete image to a pvalue
formatted text file. These files can become hundreds of MB in size with
higher resolutions.

Is there an easier and more efficient way to go? E.g. cropping the image
first to the pixels wanted? I guess the only way to do so is pcomb,
right?

Lars.

_______________________________________________
Radiance-general mailing list
[email protected]
http://www.radiance-online.org/mailman/listinfo/radiance-general

--
# Jack de Valpine
# president
#
# visarc incorporated
# http://www.visarc.com
#
# channeling technology for superior design and construction

Just adding my two cents to this...

The pfilt option (1) Jack suggests is a good one, and may be combined with the others as well. The pcompos option (2) is a little more risky, as this program ignores/removes whatever exposure changes were made to the picture, so if it isn't straight out of rpict, you may get different values than you expect. The scripting option (3) is very well-done, but I don't think you need to include the rayinit.cal file on the command line, as Jack has transcribed and modified the relevant functions into the -e arguments.

One other comment is if you only want a few pixels out of an image, vwrays connected to rtrace is much simpler and faster. Rather than generating a whole picture, just use:

vwrays -i -vf view.vf -x ${xres} -y ${yres} | rtrace [options] octree

Then, on the input to vwrays, type (or redirect) the desired x and y pixel coordinates; vwrays will produce the corresponding ray sample, which rtrace will compute for you.

Finally, no one mentioned that ximage (and Photosphere and others) can query individual values interactively. I don't know if this will work in your application.

Cheers,
-Greg

···

From: Jack de Valpine <[email protected]>
Date: May 29, 2008 7:25:58 AM PDT

Hi Lars and Lucio,

I can think of three possible ways to do this.

1) pfilt
You can use pfilt to reduce the size of the image to something more manageable. I am not sure (this means see what others weigh in on this) but I think for some applications this may actually result in better overall values in the image as surrounding pixels are being averaged together by the reduction.
2) pcompos
You can use pcompos to crop out an area of interest. You will have to read the man page carefully to figure this out but it is certainly doable.
3) script
You can either write a script (perl for example) that will read the stdout from pvalue and only write values within a given XY pixel range or you can use radiance arcana as such:
pvalue -h -H +d <name_of_image.pic> | rcalc -f <path_to_lib/rayinit.cal> -e 'boundp(a, x, b) = if(a-x, 0, if(x-b, 0, 1)); xyboundp(xa, x, xb, ya, y, yb) = and(boundp(xa, x, xb), boundp(ya, y, yb)); cond = xyboundp( <xstart>, $1, <xend>, <ystart>, $2, <yend>); $1 = $1; $2 = $2; $3 = $3; $4 = $4; $5 = $5;'

This should work presuming I transcribed into my mail client correctly....

where you need to input:
<name_of_image.pic>
<path_to_lib/rayinit.cal>
<xstart>
<xend>
<ystart>
<yend>
I hope this helps.

Best,

-Jack de Valpine

Lars O. Grobe wrote:

Hi list, I wonder if noone else came to this problem, or if I just do not see the answer to a rather simple problem. Radiance comes with pvalue to extract pixel values of images. This is fine, as long as images are small - just redirect to a file, and the values can be read according to the coordinates written at the beginning of the lines. Now, for large images, this becomes a pain. E.g. if I want to get the values of 64pixels, with known coordinates, I cannot read out these with pvalue, but first must transform the complete image to a pvalue formatted text file. These files can become hundreds of MB in size with higher resolutions. Is there an easier and more efficient way to go? E.g. cropping the image first to the pixels wanted? I guess the only way to do so is pcomb, right? Lars.

I don't know what was Lars looking for, but what I was looking for was something like ximage do, but controlled by a script. I mean, as ximage is able to comunicate a value starting from mouse position and then by x,y coordinates, is it possible to do the same thing giving a numeric input instead of a mouse one (and getting a numeric output as well?

At the time I 'needed' it I skipped the problem with rtrace as suggested, but I am still curious to know if there was a simpler solution (as the one described above)

Thank you for interesting replies anyway.

Lucio

.Just adding my two cents to this...
.
.The pfilt option (1) Jack suggests is a good one, and may be combined
.with the others as well. The pcompos option (2) is a little more
.risky, as this program ignores/removes whatever exposure changes were
.made to the picture, so if it isn't straight out of rpict, you may
.get different values than you expect. The scripting option (3) is
.very well-done, but I don't think you need to include the rayinit.cal
.file on the command line, as Jack has transcribed and modified the
.relevant functions into the -e arguments.
.
.One other comment is if you only want a few pixels out of an image,
.vwrays connected to rtrace is much simpler and faster. Rather than
.generating a whole picture, just use:
.
.vwrays -i -vf view.vf -x ${xres} -y ${yres} | rtrace [options] octree
.
.Then, on the input to vwrays, type (or redirect) the desired x and y
.pixel coordinates; vwrays will produce the corresponding ray sample,
.which rtrace will compute for you.
.
.Finally, no one mentioned that ximage (and Photosphere and others)
.can query individual values interactively. I don't know if this will
.work in your application.
.
.Cheers,
.-Greg
.
.> From: Jack de Valpine <[email protected]>
.> Date: May 29, 2008 7:25:58 AM PDT
.>
.> Hi Lars and Lucio,
.>
.> I can think of three possible ways to do this.
.>
.> 1) pfilt
.> You can use pfilt to reduce the size of the image to something more
.> manageable. I am not sure (this means see what others weigh in on
.> this) but I think for some applications this may actually result in
.> better overall values in the image as surrounding pixels are being
.> averaged together by the reduction.
.> 2) pcompos
.> You can use pcompos to crop out an area of interest. You will have
.> to read the man page carefully to figure this out but it is
.> certainly doable.
.> 3) script
.> You can either write a script (perl for example) that will read the
.> stdout from pvalue and only write values within a given XY pixel
.> range or you can use radiance arcana as such:
.> pvalue -h -H +d <name_of_image.pic> | rcalc -f <path_to_lib/
.> rayinit.cal> -e 'boundp(a, x, b) = if(a-x, 0, if(x-b, 0, 1));
.> xyboundp(xa, x, xb, ya, y, yb) = and(boundp(xa, x, xb), boundp(ya,
.> y, yb)); cond = xyboundp( <xstart>, $1, <xend>, <ystart>, $2,
.> <yend>); $1 = $1; $2 = $2; $3 = $3; $4 = $4; $5 = $5;'
.>
.> This should work presuming I transcribed into my mail client
.> correctly....
.>
.> where you need to input:
.> <name_of_image.pic>
.> <path_to_lib/rayinit.cal>
.> <xstart>
.> <xend>
.> <ystart>
.> <yend>
.> I hope this helps.
.>
.> Best,
.>
.> -Jack de Valpine
.>
.> Lars O. Grobe wrote:
.>>
.>> Hi list, I wonder if noone else came to this problem, or if I just
.>> do not see the answer to a rather simple problem. Radiance comes
.>> with pvalue to extract pixel values of images. This is fine, as
.>> long as images are small - just redirect to a file, and the values
.>> can be read according to the coordinates written at the beginning
.>> of the lines. Now, for large images, this becomes a pain. E.g. if
.>> I want to get the values of 64pixels, with known coordinates, I
.>> cannot read out these with pvalue, but first must transform the
.>> complete image to a pvalue formatted text file. These files can
.>> become hundreds of MB in size with higher resolutions. Is there an
.>> easier and more efficient way to go? E.g. cropping the image first
.>> to the pixels wanted? I guess the only way to do so is pcomb,
.>> right? Lars.
.
._______________________________________________
.Radiance-general mailing list
[email protected]
.http://www.radiance-online.org/mailman/listinfo/radiance-general
.

.. Caminante no hay
camino, solo se hace
camino al andar ..

          --- o
meglio ---

.. Caminante el
destino no es al
final de el viaje,
pero en todo el
andar ..

First thanks for the replies and suggestions. What I actually want to
do, is to sample pixel values over an area and get the average. This is
done for a HDR image assembled of photographs, so I cannot use vwrays.
Pfilt also does not work, as I need the samples to hit a light source in
a black (dark) surrounding. What I did now is writing a script in perl
which filters the output of pvalue, but still, as these files are large
and I am working on batches of such images, it is not that comfortable
to do so (it takes time). I am taking these values into my script
anyway, so writing this was not the problem, it is more about the
unnecessary lookups of all those pixels that are just not that interesting.

CU Lars.

Hi Lars,

So, this is why being specific about your problem helps -- we avoid a lot of spurious suggestions that don't apply.

The best/fastest solution for rectangular areas is pcompos piped into pvalue and total, like so:

  pcomb -o captured.pic \
    > pcompos -x ${box_width} -y ${box_height} - -${left} -${lower} \
    > pvalue -h -H -df | total -if3 -m

The initial pcomb command is necessary to apply the exposure values correctly. If you want luminance (rather than radiance) output, use:

  pcomb -s 179 -o captured.pic \
    > pcompos -x ${box_width} -y ${box_height} - -${left} -${lower} \
    > pvalue -h -H -b -df | total -if -m

Either of these commands will be very fast compared to any script you might concoct.

-Greg

···

From: "Lars O. Grobe" <[email protected]>
Date: May 29, 2008 8:52:51 AM PDT

First thanks for the replies and suggestions. What I actually want to
do, is to sample pixel values over an area and get the average. This is
done for a HDR image assembled of photographs, so I cannot use vwrays.
Pfilt also does not work, as I need the samples to hit a light source in
a black (dark) surrounding. What I did now is writing a script in perl
which filters the output of pvalue, but still, as these files are large
and I am working on batches of such images, it is not that comfortable
to do so (it takes time). I am taking these values into my script
anyway, so writing this was not the problem, it is more about the
unnecessary lookups of all those pixels that are just not that interesting.

CU Lars.

The best/fastest solution for rectangular areas is pcompos piped into
pvalue and total, like so:

  pcomb -o captured.pic \
    > pcompos -x ${box_width} -y ${box_height} - -${left} -${lower} \
    > pvalue -h -H -df | total -if3 -m

Hm, ok, sorry, maybe this was obvious, if I only had not taken the -x -y
values as the new dimensions after scaling. So they actually crop the
box, which is just what I needed - thank you!!!

And one more question now - is there also a simple way to write pixel
values into a file like this? I wanted to put frames around some objects
in the image, but as I could not find a way to say AND in the
cal-expression pcomb expects, I do not know e.g. how to cut away the
inner part of a box.

TIA&CU Lars.

Hi Lars,

Lars O. Grobe wrote:

The best/fastest solution for rectangular areas is pcompos piped into pvalue and total, like so:

  pcomb -o captured.pic \
    > pcompos -x ${box_width} -y ${box_height} - -${left} -${lower} \
    > pvalue -h -H -df | total -if3 -m

Hm, ok, sorry, maybe this was obvious, if I only had not taken the -x -y
values as the new dimensions after scaling. So they actually crop the
box, which is just what I needed - thank you!!!
  

Just to be clear, this routine calculates the average of the values in the crop box. It will output a numeric value.

And one more question now - is there also a simple way to write pixel
values into a file like this? I wanted to put frames around some objects
in the image, but as I could not find a way to say AND in the
cal-expression pcomb expects, I do not know e.g. how to cut away the
inner part of a box.

It is not clear what you are asking here. Do you want to:

   1. write pixel values to a file for crop area - the script method
      that I pointed out should accomplish this for you
   2. put a frame around selected crop areas in the image - perhaps this
      would be easier to do with something like ImageMagick?
      Alternatively, you could use pcomb to lighten or darken the pixels
      within a given area to highlight the area of interest.

···

TIA&CU Lars.

_______________________________________________
Radiance-general mailing list
[email protected]
http://www.radiance-online.org/mailman/listinfo/radiance-general

--
# Jack de Valpine
# president
#
# visarc incorporated
# http://www.visarc.com
#
# channeling technology for superior design and construction

Hi Jack!

Just to be clear, this routine calculates the average of the values in
the crop box. It will output a numeric value.

Yes, I had just misunderstood the -x -y parameters of pcompos. The
pvalue-part was clear to me.

     1. put a frame around selected crop areas in the image - perhaps
        this would be easier to do with something like ImageMagick?

I guess that this is what I will do. While I still think that it could
be done using only pcompos, imagemagick is easier here. I wanted to draw
markers such as rectangular frames around known areas, e.g. mark the
area in an image that has been read out by pvalue.

Thank you! Lars.

  pcomb -o captured.pic \
    > pcompos -x ${box_width} -y ${box_height} - -${left} -${lower} \
    > pvalue -h -H -df | total -if3 -m

The initial pcomb command is necessary to apply the exposure values
correctly. If you want luminance (rather than radiance) output, use:

I actually thought that I could use the -o option calling pvalue
instead. What is the difference between pcomb -o my.pic | pvalue and
pvalue -o my.pic?

Thank You again, Lars.

Hi Lars,

The "-o" option of pvalue would usually do the trick, but pcompos gobbles up the EXPOSURE= lines in the input, not passing them to subsequent programs. This is why the exposure needs to be "undone" before passing the picture through pcompos.

The reason pcompos behaves thus is that it's designed to take multiple input images and the combined result won't necessarily have the same exposure. I should have some more intelligent code in there for combining the exposure values in case they're all the same, I suppose....

-Greg

···

From: "Lars O. Grobe" <[email protected]>
Date: June 4, 2008 11:30:34 PM PDT

  pcomb -o captured.pic \
    > pcompos -x ${box_width} -y ${box_height} - -${left} -${lower} \
    > pvalue -h -H -df | total -if3 -m

The initial pcomb command is necessary to apply the exposure values
correctly. If you want luminance (rather than radiance) output, use:

I actually thought that I could use the -o option calling pvalue
instead. What is the difference between pcomb -o my.pic | pvalue and
pvalue -o my.pic?

Thank You again, Lars.