matlab newbie - trying to create an ROI mask from an average value of multiple images
4 views (last 30 days)
I am trying to create an ROI mask that will read in multiple image files that were taken over time, average all those files into a single array, create an ROI mask from the average image, then use that mask to go back to each individual image and analyze the image using only the ROI created from the average mask. Here is what I have so far:
The problem is that I can't figure out how to get Lmask to wait until all files have been read to average, and then still use Lmask in each iteration. Any suggestions?
Image Analyst on 2 Apr 2013
But your "average" mask is only up through image #i, not over all 13. Why is that? Also I don't know how read_LUM2 gives you a different image each time but I guess I'll just assume it does (like maybe there are persistent variables inside the function that remember that last value). Since the average image is only up to and including image #i, I'm not sure why you threshold each "average" image at 415. And these three lines:
could be done with one single line
LMask = LMask >= 415;
Next, imgL(Lmask) is not a 2D matrix. It's a 1D list of all the pixels in the mask, so you can use mean() instead of mean2().
Finally, you don't need NUM at all. Just use i everywhere you use NUM.
But to do what you say, you need two loops. The first one to go over all the images and find the mean image. Then create the mask. Then have another loop to process all the images with the mask.