Home › Forums › FLIR developer community › General discussion › thermal value calculation based on x and y val not at center any where on screen
Tagged: FLIR One, frame, general, pixels, renderimage, thermal pixels, thermal value
This topic contains 9 replies, has 4 voices, and was last updated by Allison 1 year, 10 months ago.
Viewing 10 posts  1 through 10 (of 10 total)

Author
Posts

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, 10 months ago by surendra.
ParticipantDo 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?
ParticipantI 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, 10 months ago by Devrim.
ParticipantI 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 simpleminded formula should work. I will use it instead for understandability.
 This reply was modified 1 year, 10 months ago by Charles.
Participantsample 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
ParticipantThat 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 ninepoint 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.
ParticipantYou do not have to average 9 pixels in the 8neighborhood. 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.
Participanti am not sure i just got it from sample app
Participanthi Devrim
can we monitor particular block of frame with x and y values and width and height of block?
ModeratorHi Surendra and anyone looking for the answer to this followup 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/monitoringablockofframewithxandyvaluesandwidthandheightofblock/#post7380 if you are looking for the answer or have additional information or details to add.
Thank you,
Allison Torchia 
Author
Posts
Viewing 10 posts  1 through 10 (of 10 total)
You must be logged in to reply to this topic.