Hi Holden,
I understand that you wish to create contours using your program and obtain the same outcomes as when you do not utilize the Savitzky filter.
Savitzky-Golay smoothing filters are typically used to smooth out a noisy signal whose frequency span (without noise) is large. It is more effective at preserving high frequency signal components but less successful at rejecting noise.
There are restrictions on the “sgolayfilt” function: that the polynomial order needs to be less than frame length, and the input's length needs to be greater than frame length.
The function has an upper limit on how large you may keep the frame length and, consequently, the polynomial order because the input length in your scenario is already fixed.
Also, one needs to consider that if the boundaries of the objects are very complex, a simple smoothing might not be sufficient and may need a more specialized approach to handle such complexity.
Here is a workaround that can be followed:
- In the function “sgolayfilt”, the second argument, with a value of 1, denotes a linear polynomial. This might be too simple to properly depict the data's contour. A higher polynomial order can produce a more refined shape.
- The frame length is the third parameter of the "sgolayfit" function, and it denotes how many points the function uses for each fit. If the frame length is too short, it might not smooth the noise very well. On the other hand, if it is too long, it could end up smoothing away some of the important details of the data. To get the desired results, try out a few different frame lengths and see what works best.
To learn more about the function “sgolayfilt”, following documentation can be followed:
I hope this helps! Thanks.