I have an array of average RGB pixel values from a ROI out of 611 images (dimensions 3×611). The images are taken over 64 seconds. I interpret avergae values of each color stream as a signal with time and plot it in Matlab. I also plot the power spectrum using fft(). In this power spectrum I am getting a huge values in the low frequency ranges. I want to remove these values and so want a high pass filter with cutoff at 0.2 Hz. Also I want this filter to be very sharp and totally dampen the power of frequencies less than 0.2 Hz and maintain the power of frequencies greater than 0.2 Hz. Please suggest a way to do this.
Code till I get power spectrum of green stream
imageFiles = dir('*.png');
noFiles = length(imageFiles); % Number of files found
avgVals = zeros(noFiles,3);
noise = 0; %Boolean for noise: if 1, then ROI moves randomly
noiseV = 0;
noiseH = 0;
for i=1:noFiles
curFileName = imageFiles(i).name;
curImage = imread(curFileName);
temp1 = curImage(175:215 , 290:385, 1);
avgVals(i,1) = (sum(sum(temp1)'))/3936;
temp2 = curImage(175:215 , 290:385, 2);
avgVals(i,2) = (sum(sum(temp2)'))/3936;
temp3 = curImage(175:215 , 290:385, 3);
avgVals(i,3) = (sum(sum(temp3)'))/3936;
end
Rstream = avgVals(:,1);
Gstream = avgVals(:,2);
Bstream = avgVals(:,3);
%plot actual signal with respect to time
xAxis = (0:64/610:64);
plot(xAxis,Rstream,'r');
hold on;
plot(xAxis,Gstream,'g');
hold on;
plot(xAxis,Bstream,'b');
nfft = 1024;
R = fft(Rstream,nfft);
R = R(1:nfft/2);
mR = abs(R);
G = fft(Gstream,nfft);
G = G(1:nfft/2);
mG = abs(G);
B = fft(Bstream,nfft);
B = B(1:nfft/2);
mB = abs(B);
f=(0:nfft/2-1)*(611/64)/nfft;
figure(2);
plot(f,mG,'g');
Thanks. Any help would be appreciated.
If you’re not familiar with Matlab filters you can use the filterbuilder GUI by typing
filterbuilderin the console.Once you made your settings you’ll get a filter object that you can use in combination with the
filterfunction.http://www.mathworks.de/de/help/signal/ref/filterbuilder.html
http://www.mathworks.de/de/help/matlab/ref/filter.html
If you are working on what I think you’re doing you can also do a simple detrending using
detrend, in order to get rid of the “DC” part of you signal.