Creating Mask to eliminate background in ROI from threshold for IR image

12 ビュー (過去 30 日間)
Kegan
Kegan 2023 年 5 月 30 日
コメント済み: Kegan 2023 年 6 月 9 日
I am using the following script to identify ROI's within a sequence of images. I have the script set up to promp for each image and then store the data I would like in a matrix. However, out of the 10 ROI's I need to create, 6 need to subtract background data. For example, the thermal image is of a worm with a cool background. For this specific part of the code I need to take the ROI with the worm and turn all the background pixels below a specific threshold to 0. The threshold to remove background is variable but I solved this by creating a threshold ROI and calculating the median value, then was going to use this median value plus 2-3 standard deviations as my threshold.
In a perfect world, I select the threshold ROI of the background to obtain values and then set worm ROI. I need a code here to remove the background above or below the threshold ROI median value (plus 2-3 stdev). The background will be cooler (blue) while the worm is warmer (orange, yellow, green, red ish).
I attached my script and a sample file we are using. Any help would be greatly appreciated as I am new to matlab and am still learning. Eventually I need to have this run on all images in the sequence (keeping the ROI's set in frame 1 and storing the data with frame and time) but wanted to get the script working correctly on the first frame before worrying about that part.
Thank you so much in advance for your time and any assistance!
  1 件のコメント
Matt J
Matt J 2023 年 5 月 30 日
Please run your code here for us, so we can see images and the issues with them.

サインインしてコメントする。

採用された回答

Image Analyst
Image Analyst 2023 年 5 月 31 日
You forgot to attach screenshots, but I can imagine. I imagine you have a pseudocolor image of a thermal scene. I guess the worm is hotter than the background. To get a mask of just the worm (or background), it would be best if you could "undo" the colormap and get the actual temperature image in degrees. Then you can simply threshold and use morphological functions like bwareafilt() to get the worm alone.
wormMask = temperatureImage > someTemperature;
props = regionprops(wormmask, temperatureImage, 'MeanIntensity');
averageWormTemperature = props.MeanIntensity
It might be possible to use the Color Thresholder to get the background as long as the background and worm didn't share a lot of colors, but then all you'd have is the mask. You couln't get the temperature of anything, onlyu shape parameters like area, etc.
To convert the pseudocolored image into a temperature image, see my demo:
  3 件のコメント
Image Analyst
Image Analyst 2023 年 5 月 31 日
Did you get the temperature image? I'm not seeing where that was done in your code. Where did you actually create the temperature image from the index/pseudocolored image? Is first_frame already in units of temperature rather than gray scale?
Kegan
Kegan 2023 年 6 月 9 日
Yes the first frame is in temp units I believe. I’m able to get everything except I try to overlay the ROIs on a montage of every 10th frame in order to ensure the object hasn’t moved outside the user set ROI. When I do this the resulting image is grayscale tho so I may need to separate by channel?

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeExplore and Edit Images with Image Viewer App についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by