Average pixel values of several ROIs
11 次查看(过去 30 天)
显示 更早的评论
I need to know how to calculate the average pixel value of a region of interest in an image (some images have several ROIs and I need to calculate the value for each of those ROI within an image). I used the Image Batch Processor from the Image Processing Toolbox (Matlab 2015a) to obtain masks containing my ROIs. I understand binary images to be the input image with 1s inside the ROI object h and 0s everywhere else, but I do not know how to use this information. I can use the Image Region Analyzer to access ROI properties, i.e. area, perimeter, etc., from the mask, but I do not know if this information is relevant to calculating the average pixel values of the ROI.
I know there is documentation online about how to do this for freehand ROIs, etc., but Matlab is brand new to me (without the Image Processing Toolbox, I would not have been able to detect my ROIs or to create the mask), so I am having trouble following the documentation, especially because I have a folder of binary images (the output of using the Image Batch Processor) and I am not defining my ROIs individually. Any help is greatly, greatly appreciated!
0 个评论
采纳的回答
Guillaume
2015-3-30
It's not clear whether your ROIs are in memory or just images on disk, but given a binary ROI image, and an input image of the same size, the mean of the pixels within the ROI is simply:
m = mean2(inputimage(logical(ROIimage)))
The logical(ROIimage) makes sure that the 0 and 1 of your ROI images are interpreted as logical (true / false). When you index an array (the inputimage here) with an array of logical it returns only the values of the original arrays for which the logicals are true (1). Hence, you only get the pixels within your ROI. mean2 is a function provided by the image processing toolbox and is just a shortcut to mean(A(:))
0 个评论
更多回答(1 个)
Image Analyst
2015-3-30
I don't know about that batch utility you're usingn, but it's certainly possible if you write your own program as illustrated in my Image Segmentation Tutorial http://www.mathworks.com/matlabcentral/fileexchange/?term=authorid%3A31862 which uses regionprops() to get the areas of all the ROI's at one time.
4 个评论
Image Analyst
2015-4-2
编辑:Image Analyst
2015-4-3
Attached is a new one. Evidently the handle graphics in R2015a don't like me using set() like that. I changed it to use the line() function instead of the stem() function and everything works fine now.
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Image Segmentation and Analysis 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!