matlab newbie - trying to create an ROI mask from an average value of multiple images
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
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:
NUM=0;
for i=1:13
img(:,:,i)=read_LUM2;
Lmask=mean(img,3);
Lmask(Lmask<415)=0;
Lmask(Lmask~=0)=1;
Lmask=logical(Lmask);
NUM=NUM+1;
L(NUM)=mean2(imgL(Lmask));
end
avgL=L(1:13)'
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?
0 comentarios
Respuestas (1)
Image Analyst
el 2 de Abr. de 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:
Lmask(Lmask<415)=0;
Lmask(Lmask~=0)=1;
Lmask=logical(Lmask);
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.
2 comentarios
Image Analyst
el 2 de Abr. de 2013
Of course you can condense those 3 lines into 1 like I showed you. Just try it and see. I did give you guidance to do one loop, then get the mean, then create the mask, and then another loop to mask the images. Are you saying that the mean image should include only pixels brighter than 415? These must be 16 bit images then since regular 8 bit images don't have values over 255.
So for each image you will create a mask, rather than sum the images and create the mask on that sum? Why?
Where did you post your images?
What operations are you going to perform on your second pass through when you "analyze the image using only the ROI created from the average mask"?
Ver también
Categorías
Más información sobre Computer Vision with Simulink en Help Center y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!