Curve fitting through fonts
3 views (last 30 days)
Show older comments
Hi,
I am trying to fit a curve through several fonts. I am doing this to generate a reference trajectory for a control system. The target is that a text is entered in Matlab and a path will come out of it. For this i want to use a windows font and try to fit a curve through this with image processing. (Other ideas are welcome aswell off course!) I have tried this on 2 different ways: - using imbinarize and bwmorph (method is 'thin') and finding the indices which are 1 or 0 and using this as samples. This gives the following result:

However, how good the quality of the image is, this is always pixelated. I tried using interp1 function with method pchip and spline, but with these methods the image does not look like the letter D anymore. Also using the "smooth" function with a moving average filter does not give good quality images. Code snippet of this script:
BW = imbinarize(I,'adaptive','Sensitivity',0.7);
BW = imcomplement(BW)
skele = bwmorph(bwmorph(BW,'thin',Inf),'clean');
[row,col] = find(skele);
-houghlines: I am still experimenting with this way, but I do not think this will be the solution. This gives the following result:

The houghlines code i am using:
[H,T,R] = hough(BW);
imshow(H,[],'XData',T,'YData',R,...
'InitialMagnification','fit');
xlabel('\theta'), ylabel('\rho');
axis on, axis normal, hold on;
P = houghpeaks(H,5,'threshold',ceil(0.3*max(H(:))));
x = T(P(:,2)); y = R(P(:,1));
plot(x,y,'s','color','white');
lines = houghlines(BW,T,R,P,'FillGap',3,'MinLength',50); end
0 Comments
Answers (0)
See Also
Categories
Find more on Smoothing 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!