Filter löschen
Filter löschen

Post-Processing Video for Thermal Analysis

1 Ansicht (letzte 30 Tage)
Bryan Manning
Bryan Manning am 18 Nov. 2015
Hello all,
I have a question with regards to post-processing a video of thermal values. I have two questions:
1) I converted a video from WMV to AVI to grayscale. How do I correlate the grayscale values to temperature values? I have a scale from the program I am using to correlate it, but I assume the video doesn't have these values.
2) I have code (borrowed from here: http://www.mathworks.com/help/images/examples/detecting-cars-in-a-video-of-traffic.html) that finds the maximum temperature area. How can I tell MATLAB to grab values from this area for each frame and put them in an array?
My code, thus far, is as follows:
file = 'Test.avi';
reader = VideoReader(file); get(reader); implay(file);
nframes = reader.NumberOfFrames; %Use 'CurrentTime' in future releases
background = 6; darkCar = rgb2gray(read(reader,nframes*.5)); noDarkCar = imextendedmax(darkCar, background); imshow(darkCar) figure, imshow(noDarkCar)
sedisk = strel('disk',2); noSmallStructures = imopen(noDarkCar, sedisk); imshow(noSmallStructures)
%nframes = reader.NumberOfFrames; I = read(reader, 1); taggedCars = zeros([size(I,1) size(I,2) 3 nframes], class(I));
for k = 1 : nframes singleFrame = read(reader, k);
% Convert to grayscale to do morphological processing.
I = rgb2gray(singleFrame);
% Remove dark cars.
noDarkCars = imextendedmax(I, background);
% Remove lane markings and other non-disk shaped structures.
noSmallStructures = imopen(noDarkCars, sedisk);
% Remove small structures.
noSmallStructures = bwareaopen(noSmallStructures, 150);
% Get the area and centroid of each remaining object in the frame. The
% object with the largest area is the light-colored car. Create a copy
% of the original frame and tag the car by changing the centroid pixel
% value to red.
taggedCars(:,:,:,k) = singleFrame;
stats = regionprops(noSmallStructures, {'Centroid','Area'});
if ~isempty([stats.Area])
areaArray = [stats.Area];
[junk,idx] = max(areaArray);
c = stats(idx).Centroid;
c = floor(fliplr(c));
width = 2;
row = c(1)-width:c(1)+width;
col = c(2)-width:c(2)+width;
taggedCars(row,col,1,k) = 0;
taggedCars(row,col,2,k) = 145;
taggedCars(row,col,3,k) = 25;
end
end
%% Step 5: Visualize Results % Get the frame rate of the original video and use it to % see taggedCars in implay.
frameRate = reader.FrameRate; implay(taggedCars,frameRate);

Antworten (0)

Kategorien

Mehr zu Manage Products finden Sie in Help Center und File Exchange

Produkte

Community Treasure Hunt

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

Start Hunting!

Translated by