FLIR One Developer / Blog / Topics / FLIR One, frame, general, pixels, renderimage, thermal pixels, thermal value / thermal value calculation based on x and y val not at center any where on screen

thermal value calculation based on x and y val not at center any where on screen

Home Forums FLIR One developer community General discussion thermal value calculation based on x and y val not at center any where on screen

This topic contains 9 replies, has 4 voices, and was last updated by Profile photo of Allison Allison 1 year, 3 months ago.

Viewing 10 posts - 1 through 10 (of 10 total)

  • Author

    Posts

  • #7335

    Profile photo of surendra
    surendra

    Participant

    can we get thermal value of a particular point on screen by passing x and y values and how to calculate?

    for now i am doing like this

    int[] centerPixelIndexes = new int[]{x, y};

    double averageTemp = 0;

    for (int i = 0; i < centerPixelIndexes.length; i++) {
    // Remember: all primitives are signed, we want the unsigned value,
    // we’ve used renderedImage.thermalPixelValues() to get unsigned values
    int pixelValue = (thermalPixels[centerPixelIndexes[i]]);
    averageTemp += (((double) pixelValue) – averageTemp) / ((double) i + 1);
    }
    double averageC = (averageTemp / 100) – 273.15;
    NumberFormat numberFormat = NumberFormat.getInstance();
    numberFormat.setMaximumFractionDigits(2);
    numberFormat.setMinimumFractionDigits(2);

    • This topic was modified 1 year, 3 months ago by Profile photo of surendra surendra.

    #7339

    Profile photo of Charles
    Charles

    Participant

    Do you understand this line of code?

    averageTemp += (((double) pixelValue) – averageTemp) / ((double) i + 1);

    If so, could you enlighten me? It is not a simple average. Is there a trick that I don’t understand?

    #7341

    Profile photo of Devrim
    Devrim

    Participant

    I could not find a trick. I think its only another mathematical way that yields the same result with the code block you proposed (which is below).</p>
    <p> for (int i = 0; i < centerPixelIndexes.length; i++){<br />
    int pixelValue = (thermalPixels[centerPixelIndexes[i]]);<br />
    averageTemp += (double)pixelValue;<br />
    }<br />
    averageTemp /= centerPixelIndexes.length;

    • This reply was modified 1 year, 3 months ago by Profile photo of Devrim Devrim.

    #7345

    Profile photo of Charles
    Charles

    Participant

    I think the two formulas are mathematically different. The one from FLIR seems to reduce the weights of other pixels as the index (the order of the central pixels) grows greater. This doesn’t quite make sense to me because the pixels below the spot center gets less weights than those above it (or the other way around) based on the ordering. So I was wondering if I missed anything.

    If all the thermal pixels are equivalent, I think the simple-minded formula should work. I will use it instead for understandability.

    • This reply was modified 1 year, 3 months ago by Profile photo of Charles Charles.

    #7346

    Profile photo of surendra
    surendra

    Participant

    sample app has a code forming int array </p><br />
    <p>int width = renderedImage.width();<br /><br />
    int height = renderedImage.height();<br /><br />
    int centerPixelIndex = width * (height / 2) + (width / 2);<br /><br />
    int[] centerPixelIndexes = new int[]{<br /><br />
    centerPixelIndex, centerPixelIndex – 1, centerPixelIndex + 1,<br /><br />
    centerPixelIndex – width,<br /><br />
    centerPixelIndex – width – 1,<br /><br />
    centerPixelIndex – width + 1,<br /><br />
    centerPixelIndex + width,<br /><br />
    centerPixelIndex + width – 1,<br /><br />
    centerPixelIndex + width + 1<br /><br />
    };</p><br />
    <p> double averageTemp = 0;</p><br />
    <p> for (int i = 0; i < centerPixelIndexes.length; i++) {<br /><br />
    // Remember: all primitives are signed, we want the unsigned value,<br /><br />
    // we’ve used renderedImage.thermalPixelValues() to get unsigned values<br /><br />
    int pixelValue = (thermalPixels[centerPixelIndexes[i]]);<br /><br />
    averageTemp += (((double) pixelValue) – averageTemp) / ((double) i + 1);<br /><br />
    }<br /><br />
    double averageC = (averageTemp / 100) – 273.15;</p><br />
    <p>

    but here i want to get temperature of touch point on screen

    • This reply was modified 1 year, 3 months ago by Profile photo of surendra surendra.
    • This reply was modified 1 year, 3 months ago by Profile photo of surendra surendra.

    #7351

    Profile photo of Charles
    Charles

    Participant

    That is easy to do. All you need to do is to figure out the position of the touch point (x, y) in the thermal pixel array (which is one dimensional). This goes like:

    int indexOfTouchPoint = x + y * width;

    Then you just need to copy the code for computing the average of the nine-point stencil. Note that you may need to treat the special situations if (x, y) is exactly on the edge of the screen (not likely).

    I raised the question about the calculation of the average in your post, however.

    #7352

    Profile photo of Devrim
    Devrim

    Participant

    You do not have to average 9 pixels in the 8-neighborhood. You could only get the thermal value at the touch point. However, calculating the average around may generate proper value if thermal noise is present.

    #7353

    Profile photo of surendra
    surendra

    Participant

    i am not sure i just got it from sample app

    #7366

    Profile photo of surendra
    surendra

    Participant

    hi Devrim

    can we monitor particular block of frame with x and y values and width and height of block?

    #7381

    Profile photo of Allison
    Allison

    Moderator

    Hi Surendra and anyone looking for the answer to this follow-up question,

    I’ve posted a reply on the forum post Surendra created to address it specifically. You can find that post here: https://developer.flir.com/forums/topic/monitoring-a-block-of-frame-with-x-and-y-values-and-width-and-height-of-block/#post-7380 if you are looking for the answer or have additional information or details to add.

    Thank you,
    Allison Torchia

Viewing 10 posts - 1 through 10 (of 10 total)

You must be logged in to reply to this topic.