FLIR One Developer / Blog / Topics / / 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

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

• Author

Posts

• 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);

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?

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;

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.

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

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.

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.

i am not sure i just got it from sample app

hi Devrim

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

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.