Measure the average intensity of pixels in a specified area repeatedly in the same image
12 次查看(过去 30 天)
显示 更早的评论
Hi
I'm trying to measure average intensity within specified locations repeatedly in the same image, and then iterate to do this over multiple images. I'm finding MATLAB can only handle so many cropped images at a time. There must be an easier way to do this. Here is what I have so far.
A = cat(2,B,Th); %Concatenate ROI array in form [X,Y,dX,dY] to create specified regions (1285x4x6) -> many regions
%Use ROI array to determine mean intensities of sensors
for j = 1:numframes
for a = 1:1285 %number of ROI per image -> can only be cut down by about 1/3 for future
c(:,:,a,j) = imcrop(z(:,:,j),A(a,:,j));
m = mean(mean(c(:,:,a,j)));
end
end
Is there another way to do this than with imcrop. It seems very inefficient. It is struggling with the first 6 images right now and I have to do this for 600 so I need a more efficient way.
Thanks
0 个评论
回答(3 个)
Image Analyst
2017-3-3
Do the ROI overlap or are they all separate? If they're all separate, you can do it once to make up a binary image with all the masks, then call regionprops() to get the mean of all regions at once.
And you don't need to store all your c arrays. You can simply overwrite it each time:
thisSubImage = imcrop(z(:,:,j),A(a,:,j));
m(a) = mean2(thisSubImage); % Compute the mean for this 2-D channel of z.
0 个评论
Tim Sanborn
2017-3-8
1 个评论
Image Analyst
2017-3-8
There is no way a centroid can be outside the edges of the image. It might be outside of a blob, like the centroid of a fat C shape is in the center outside the C itself, but you can't have a centroid be outside the entire image itself.
另请参阅
类别
在 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!