How to determine median pixel intensity for each pixel from x number of pictures

조회 수: 12 (최근 30일)
I am trying to do image processing and have a baseline composed of x number of images with the same dimensions.
I would like to create a single baseline image composed of the median pixel intensity of my baseline images.
I am relatively new to matlab and believe there must be a relatively easy way to do this operation. right now I am considering using a for loop to add pixel (1,1) for each individual picture append it to a list, find the median, add it to a new matrix and move on to pixel (1,2) this is obviously ineffecient and crude.
I would like an efficient script to determine the median pixel value of my each pixel pictures and create a new image composed.
Is there a way to compare the pixel intensity of each pixel for all of the images directly, doing the entire operation in one move?

채택된 답변

Jon
Jon 2020년 10월 15일
Suppose your images are each in a mRow by nCol array and you have numImages total number of images. If you put all of the images into an mRow by nCol by numImages array, lets call it X then the baseline image would be given by
xBase = median(X,3)
  댓글 수: 2
John Doe
John Doe 2020년 10월 19일
Thank you.
It took some time for me to work out since being new to matlab I didn't know about arrays, but this seems to have done the trick.
for n = 1:900
filename = sprintf('%s%03i%s', prefix, n, suffix);
pic_img = imread(filename); %load stimulation frame no n
img_array(:,:,n) = pic_img;
end
Median_pic = median(img_array,3);
imshow(Median_pic)
Jon
Jon 2020년 10월 26일
Hi, Looks good. I'm glad you were able to move ahead with this and are able to start figuring out how to do things in MATLAB. If you haven't done it already a good way to get a quick immersion in MATLAB is the MATLAB On Ramp https://www.mathworks.com/learn/tutorials/matlab-onramp.html

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Image Data Workflows에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by