Borrar filtros
Borrar filtros

How to obtain piecewise polynomial from the acquired piecewise data?

1 visualización (últimos 30 días)
I am using the following code to obtain the piecewise polynomial :
clc
close all
clear all
%Step 1 : Read Image
X=imread('cameramannn.tif');
figure,imshow(X);
[r c noc]=size(X);
% Step 2 : Gray Scale Conveersion
if noc > 1
Xn=rgb2gray(X);
else
Xn=X;
end
% Step 3 : Extracting Histogram from image
figure,imhist(Xn);
[counts, centers] = imhist(Xn);
bar(centers, counts, 'hist');
histpatch = findobj(gca, 'type', 'patch');
edgemat = get(histpatch, 'XData');
countmat = get(histpatch, 'YData');
counts = countmat(2,:);
centers = mean(edgemat(2,3,:))
% Step 4 : Extracting break points for polynomial
a=1;
while a<=4
for b=1:r*c
y=edgemat(a,b);
%round(y);
disp(y);
end
a=a+1;
end
breaks=[1.5000 2.5000 3.5000 4.5000 5.5000 6.5000 7.5000 8.5000 9.5000 10.5000 11.5000 12.5000 13.5000 14.5000 15.5000 16.5000 17.5000]; % manually taken from step 4
% Step 5 : Acquiring Piecewise Polynomial from the extracted data
pp=mkpp(breaks,Xn);
coefs = pp.coefs ;
breaks = pp.breaks ;
peices = pp.pieces ;
order = pp.order ;
dim = pp.dim ;
disp(pp);
% Step 6 : Obtaining Piecewise Polynomial from the acquired data
a=polyval(breaks,pp);
My Piecewise Output is :
form: 'pp'
breaks: [1x17 double]
coefs: [16x16 uint8]
pieces: 16
order: 16
dim: 1
But when MATLAB is compiling the polyval() I get the following error :
Undefined function 'isfinite' for input arguments of type 'struct'.
Error in polyval (line 54)
if isscalar(x) && (nargin < 3) && nc>0 && isfinite(x) && all(isfinite(p(:)))
Error in extracting_polynomial_try0 (line 50)
a=polyval(breaks,pp);
Please help me in resolving this issue.

Respuestas (0)

Categorías

Más información sobre Polynomials en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by