Be the first to rate this file! 120 downloads (last 30 days) File Size: 1.69 KB File ID: #8719

Unround

by John D'Errico

 

13 Oct 2005 (Updated 14 Oct 2005)

Code covered by BSD License  

Unrounds points on a curve to produce the smoothest curve which is consistent with rounding.

Download Now | Watch this File

File Information
Description

Inverse interpolation using a rounded curve can fail if the rounding operation produces flat spots. In this event, even simple linear interpolation will not result in a unique inverse interpolant.

Unround attempts to find the smoothest possible
curve that will reproduce the original curve after rounding all points to the nearest integer.

Unround finds use in image processing operations,
where shapers (1-d lookup tables) have been
rounded.

Example usage 1:

x = linspace(0,2*pi,20);
vec = round(x);
newvec = unround(vec);
plot(x,vec,'bo',x,newvec,'r-')

Example usage 2:
x = 0:.01:1;
vec = round(10*x.^2);
newvec = unround(vec);
plot(x,vec,'bo',x,newvec,'r-')

If there are requests, I can easily modify the code to allow bound constraints on the unrounding
process. This would allow the user to specify lower or upper bounds on the smoothly unrounded curve.

Required Products Optimization Toolbox
MATLAB release MATLAB 7.0.1 (R14SP1)
Other requirements Because unround solves a quadratic programming problem, vectors of length 10000 or more may take a few seconds to solve.
Tags for This File  
Everyone's Tags
Tags I've Applied
Add New Tags Please login to tag files.
Please login to add a comment or rating.
Tag Activity for this File
Tag Applied By Date/Time
approximation John D'Errico 22 Oct 2008 08:02:50
interpolation John D'Errico 22 Oct 2008 08:02:50
image processing John D'Errico 22 Oct 2008 08:02:50
rounding John D'Errico 22 Oct 2008 08:02:50
shapers John D'Errico 22 Oct 2008 08:02:50
lookup table John D'Errico 22 Oct 2008 08:02:50
 

MATLAB Central Terms of Use

NOTICE: Any content you submit to MATLAB Central, including personal information, is not subject to the protections which may be afforded information collected under other sections of The MathWorks, Inc. Web site. You are entirely responsible for all content that you upload, post, e-mail, transmit or otherwise make available via MATLAB Central. The MathWorks does not control the content posted by visitors to MATLAB Central and, does not guarantee the accuracy, integrity, or quality of such content. Under no circumstances will The MathWorks be liable in any way for any content not authored by The MathWorks, or any loss or damage of any kind incurred as a result of the use of any content posted, e-mailed, transmitted or otherwise made available via MATLAB Central. Read the complete Terms prior to use.

Contact us at files@mathworks.com