How do I create a Filter that takes out irrelevant data?

조회 수: 16(최근 30일)
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

채택된 답변

Teja Muppirala
Teja Muppirala 2011년 5월 24일

The curve fitting toolbox can help you deal with irregular data. Here I make a noisy surface, approximate it using polynomials, subtract the two, and then display the noise. There is a neat surface fitting GUI tool called "sftool" as well.

x = rand(65000,1);
y = rand(65000,1);
z0 = log(1+x).*sin(3*y);
z = z0 + 0.05*randn(size(z0));
hold on;
F = fit([x y],z,'poly55');
alpha 0.5;
plot3(x,y,F(x,y) - z,'.','markersize',1);
plot(F(x,y) - z);
  댓글 수: 1
Ian Wood
Ian Wood 2011년 5월 24일
This is exactly what I was looking for. Modifying this code a little for my code, I come up with the profile roughness I need to extrapolate. Thanks Teja, and thanks to you too Ben.

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

추가 답변(2개)

Ben Mitch
Ben Mitch 2011년 5월 22일
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.
  댓글 수: 1
Ian Wood
Ian Wood 2011년 5월 23일
Hi Mitch,
Thanks for the reply. What you said in the first paragraph is the idea yes. I will see what I can come up with using your suggestion and let you know how it goes.

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

Ian Wood
Ian Wood 2011년 5월 24일
Ok so if I'm reading this correctly the pre-defined function interp2 requires a monotonic matrix, and unfortunately that's not what i have. I will provide more information:
So it's a ~65000 by 3 matrix, that holds x, y, and z plot points to approximate a surface. The problem is it's a surface and not a 2-D roughness curve, which i need to calculate certain parameters, but that code is already done. I just need to know the best method to get this roughness curve.
It should look like a zig-zag pattern. The useful part of the filtering is eliminating the data that represents the surface. Once I have this curve I can take the difference between the two plots (original and filtered), and this will give me the variables i need to implement in my equations.
  댓글 수: 2
Ian Wood
Ian Wood 2011년 5월 24일
It's terminology for a surface's actual profile at a microscopic level. The heights deviating from the average profile are usually very small (micrometres).

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

Community Treasure Hunt

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

Start Hunting!

Translated by