How do I create a Filter that takes out irrelevant data?
Show older comments
Hey everyone,
So I have a large amount of data stored in a matrix that displays the surface of an object when plotted. The only problem is that this contains the whole surface, and not just the roughness curve that I need from it. How can I create a filter (i'm guessing of a gaussian type) that controls the data being output? I don't need code to be provided, just simple direction would be nice.
I had an idea for where to start but I'm not sure if it's right.
A = imread('file_name.txt'); H = fspecial('gaussian',hsize,std)
The thing about this fspecial function is that I do not know what size to specify in the argument. The documentation does not cover this unfortunately.
Thanks, Ian
Accepted Answer
More Answers (2)
Ben Mitch
on 22 May 2011
0 votes
Hi Ian
There's some information missing from your question, but it sounds like you're looking to interpolate a large amount of data to summarize its form with a small data set.
If so, you might get some mileage out of interp2() and filter2(), if that's the case (interp() and filter() if your "surface" is 1-D). Use interp2() to get the value of your function on a high-resolution regular grid, then use filter2() to smooth it as much as you like (use a matrix of ones as "b" in filter2()), then use interp2() again (or simply decimate) to obtain a smoothed surface on a low-resolution regular grid.
If you need more control over the curvature of the summary surface, you could try instead polynomial estimation. Denote your input data [x, y] as X, and your output data [z] as Y, and use polyfit() to fit an nth-degree polynomial of your choice, then use polyval() to provide a summary data set on a regular grid.
Cheers
Ian Wood
on 24 May 2011
0 votes
Categories
Find more on Get Started with Curve Fitting Toolbox in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!