フィルターのクリア

curve fitting, basic fitting for irregular ,specific geometric shapes?

4 ビュー (過去 30 日間)
selim
selim 2012 年 7 月 29 日
i have a region. i want to detect this object with basic or curve fitting.
for example, i want to pass all the pixels on coordinate plane and do a fitting.
i tried basic fitting but i failed. i was expecting something like that :
(i made up)
because it happens correctly as seen in this application : http://uploadpic.org/v.php?img=NbFaNr7if5

採用された回答

Image Analyst
Image Analyst 2012 年 7 月 29 日
編集済み: Image Analyst 2012 年 7 月 30 日
Did you try polyfit() and polyval()? What was your code? What was the error message? I did it and it seemed to work perfectly well:
clc; % Clear the command window.
close all; % Close all figures (except those of imtool.)
clear; % Erase all existing variables.
workspace; % Make sure the workspace panel is showing.
fontSize = 16;
% Read in selim's demo image.
folder = 'C:\Users\selim\Documents';
baseFileName = 'C54DlekrK51DuexHIM4AXxiL.jpg';
% Get the full filename, with path prepended.
fullFileName = fullfile(folder, baseFileName);
% Check if file exists.
if ~exist(fullFileName, 'file')
% File doesn't exist -- didn't find it there. Check the search path for it.
fullFileName = baseFileName; % No path this time.
if ~exist(fullFileName, 'file')
% Still didn't find it. Alert user.
errorMessage = sprintf('Error: %s does not exist in the search path folders.', fullFileName);
uiwait(warndlg(errorMessage));
return;
end
end
rgbImage = imread(fullFileName);
subplot(2, 1, 1);
imshow(rgbImage, []);
axis on;
title('Original Color Image (already cropped)', 'FontSize', fontSize);
set(gcf, 'Position', get(0,'Screensize')); % Maximize figure.
% Get the magenta points. Subsample by a factor of 4.
redChannel = rgbImage(1:4:end,1:4:end, 1) > 128;
[rows columns] = size(redChannel);
subplot(2, 1, 2);
imshow(redChannel, []);
axis on;
title('Red Channel', 'FontSize', fontSize);
%-------------------------------------
% Main code starts here !!!!!
% Get all the x,y points
[y x] = find(redChannel);
% Plug into polyfit
orderOfPolynomial = 2;
coeffs = polyfit(x, y, orderOfPolynomial)
% Get the estimated fit and plot over the image.
xValues = 1 : columns;
fittedY = polyval(coeffs, xValues);
hold on;
plot(xValues, fittedY, 'b-', 'LineWidth', 3);
title('Red Channel with Fitted Curve', 'FontSize', fontSize);
  5 件のコメント
Image Analyst
Image Analyst 2012 年 7 月 31 日
So I guess the answer is no. If not, then tell me why I should put more effort into helping you some more considering what happened with my last attempt.
selim
selim 2012 年 8 月 1 日
編集済み: selim 2012 年 8 月 1 日
thank you sir for everything . but i think i made my problem more complex considering that i can solve this using basic fitting. i should not have thought that i must solve it by basic fitting.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeGet Started with Curve Fitting Toolbox についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by