FLIR One Developer / Blog / Topics / android, FLIR, FLIR One, Rendering image, Thermal pixles, Thermal values / monitoring a block of frame with x and y values and width and height of block?

monitoring a block of frame with x and y values and width and height of block?

Home Forums FLIR developer community General discussion monitoring a block of frame with x and y values and width and height of block?

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

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

  • Author

    Posts

  • #7367

    Profile photo of surendra
    surendra

    Participant

    can we get average temperature of particular block in frame with x and y values and width and height of block using android ?

    int width = renderedImage.width();
    int height = renderedImage.height();
    int centerPixelIndex = width * (height / 2) + (width / 2);
    int[] centerPixelIndexes = new int[]{
    centerPixelIndex, centerPixelIndex – 1, centerPixelIndex + 1,
    centerPixelIndex – width,
    centerPixelIndex – width – 1,
    centerPixelIndex – width + 1,
    centerPixelIndex + width,
    centerPixelIndex + width – 1,
    centerPixelIndex + width + 1&
    };
    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;

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

    #7380

    Profile photo of Allison
    Allison

    Moderator

    Hi Surendra,

    If I understand your question correctly, it’s related to your follow up question on this post: https://developer.flir.com/forums/topic/thermal-value-calculation-based-on-x-and-y-val-not-at-center-any-where-on-screen/

    You can get pixel values from a block within the frame and then average them or store them as you see fit. The thermalPixelValues() method returns an array of integers representing all the pixels thermal data. if (x,y) is the top left corner of your block to find that pixel’s index it would be x + (y * width of image). So thermalPixels[x + (y * width of image)] gives you the top left corner of the block. To get the top right corner it would be x + (y*width of image) + width of block. To get the bottom left corner of the block: x + (y * width of image * height of block) and the bottom right corner would be x + (y * width of image * height of block) + width of block.

    Hopefully, that helps you get started on how to find the values of the block within the thermalPixels array. If you want to average the entire block you will need to get each of the pixels values within the block. If this is still confusing let me know and I will walk you through getting the pixel indexes more in-depth.

    As stated in the post linked above, there may be special cases to handle such as if you chose a (x,y) where the block goes off the end of the screen in some way.

    Thank you,
    Allison Torchia

    #7382

    Profile photo of surendra
    surendra

    Participant

    Hi Allison,

    Thank you for the reply.

    i am still confused calculating index point from with (x,y). Let me explain a scenario if a rectangle is drawn on any part of frame how can we calculate average temperature of the rectangle(Go through (https://www.mediafire.com/file/qqgiezdzydsrkxu/pastedImage.png) for a flir tools screen shot). And the other thing is resolution consiudered for calculating index point. This piece of code was in sample app where spot meter at center of screen shows temperature (int centerPixelIndex = width * (height / 2) + (width / 2)), do i also need to do something like this (int PixelIndex = (width * (y / 2)) + (x/ 2) as frame i get is in 480*640 resolution.

    • 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.
    • This reply was modified 1 year, 3 months ago by Profile photo of surendra surendra.

    #7398

    Profile photo of surendra
    surendra

    Participant

    hello Allison,

    can you please reply to my question ?

    #7405

    Profile photo of Allison
    Allison

    Moderator

    Hi Surendra,

    I apologize for the delay.

    You bring up a good point considering the resolution. However, I believe in int centerPixelIndex = width * (height / 2) + (width / 2), height and width are dived by 2 to find the center of the image, not due to resolution.

    As for handling resolution, the thermalPixelValues() method returns an array of length 307,200. Which is equivalent to all the pixels in a 480*640 image. This is because the thermal image is scaled up to match the visual image resolution.

    If you want to just use the interpolated pixels, you can use the above way of getting values. Point (x,y) can be found using thermalPixels[x + (y * width of image)]. This should work, as it’s how the example application treats the thermal pixel array.

    If for some reason you are not getting an array of length 307,200. Please let me know and I will be happy to help figure out how to get the correct coordinates from your array length.

    Thank you,
    Allison Torchia

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

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

You must be logged in to reply to this topic.