-1

I have an image that I converted to a vector and plotted:

img = imread(image.png');
grayImage = rgb2gray(img);
grayImage(2:2:end,:)=fliplr(grayImage(2:2:end,:));

B = rot90(grayImage);
C = flipud(B);

[x,y]=size(C);
vector = reshape(C ,1,x*y);
plot(vector);

The problem is that although I can visually see a wave pattern, there is a lot of noise that occurs. By noise I mean the signals rapidly go up and down eventually forming a sinusoidal wave but I want to be able to just connect the crest of each spike to one another in order to create a continuous wave pattern. If anyone understands what I am trying to do, help would be appreciated.

Thank you in advance.

Nick K
  • 35
  • 1
  • 8

2 Answers2

0

Not 100% sure about what you're asking, but the medfilt1 median filter function might be what you're looking for, it's a 1D smoothing filter. Example usage would be:

vector_filt = medfilt1(vector);

Check out the documentation and example at http://www.mathworks.com/help/signal/ref/medfilt1.html.

DavidS
  • 2,344
  • 1
  • 17
  • 18
0

I think performing a gaussian convolution on the vector should solve your problem. Here is a link to a stack overflow question that has a very nice answer on how to do a gaussian convolution in matlab: Gaussian Filter on a vector in Matlab

Community
  • 1
  • 1
Haider
  • 341
  • 3
  • 18