필터 지우기
필터 지우기

check intensity of the pixel last 10 pixel values of an image

조회 수: 2 (최근 30일)
michael bowen
michael bowen 2021년 12월 17일
편집: DGM 2021년 12월 17일
Hi, im trying to check intensity of the pixel last 10 pixel values of an image to compare to another image. If the intensity of the pixel changes either brighter or darker by a set threshold, and flag this pixel as a foreground pixel.
  댓글 수: 4
Jan
Jan 2021년 12월 17일
The question concerns a video, not an image. Then "10 last pixels" is easier to understand.
How can we help you now? I recommend to ask a specific question concerning Matlab. Focus on one problem after the other. Post the code you have written so far.
Did you import the video already? Do you know how to find the "intensity" of a pixel?
Rik
Rik 2021년 12월 17일
Clarification posted as new question by @michael bowen:
hi i was wondering how to put a group of 10 images that are 1920 x 1080 into a matrix that is size 1920x1080x10. Im doing this to keep track of values for each pixel.
i have tried
for i = 1:10
outputFileName = sprintf('bwImage%d.jpg', i);
imdata =imread(outputFileName);
allImages{i} = imread(outputFileName);
end
but this creates and matrix size 1 x 10.
This matrix will be used to calculate the average value at each pixel location

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

답변 (1개)

DGM
DGM 2021년 12월 17일
편집: DGM 2021년 12월 17일
This could be a start. It would probably be faster to do it with cell arrays, but the text suggests doing it with a simple stack on dim3.
This example uses a built-in set of microscopy images. Since there are only 10 frames in the entire set, I'm using a smaller window size for averaging.
totalframes = 10; % number of images in entire frame set
avgframes = 3; % number of frames to use for averaging
fnamept = 'AT3_1m4_%02d.tif';
threshold = 20;
% preallocate (assumes data is uint8, 1 sample per pixel)
S = imfinfo(sprintf(fnamept,1));
priorframes = zeros(S.Height,S.Width,avgframes,'uint8');
% fill queue
for k = 1:avgframes
priorframes(:,:,k) = imread(sprintf(fnamept, k));
end
% preallocate mask
fgmask = false(size(priorframes,1),size(priorframes,2),totalframes-avgframes);
% build mask set
for k = avgframes+1:totalframes
av = uint8(mean(priorframes,3));
priorframes = circshift(priorframes,[0 0 -1]);
priorframes(:,:,end) = imread(sprintf(fnamept, k));
fgmask(:,:,k-avgframes) = abs(priorframes(:,:,end)-av) > threshold;
end
montage(fgmask) % show the masks
The result is a stack of logical masks representing the FG content of each tested frame. Note that there are necessarily fewer mask frames (7) than there are total input frames (10). If you wanted the mask array to be front-padded to keep the indices matching, you can just adjust the following lines:
fgmask = false(size(priorframes,1),size(priorframes,2),totalframes);
and
fgmask(:,:,k) = abs(priorframes(:,:,end)-av) > threshold;
What you do with these masks is up to you. The text suggests to convert them to uint8, but if they're to be used for image composition, then doing so would be counterproductive.

카테고리

Help CenterFile Exchange에서 Computer Vision with Simulink에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by