I have written Matlab code to perform the following steps:
1) Read the original cottage picture.
2) Obtain its sizes.
3) Show the x values for the curve fitting.
4) Make a copy of the original picture.
5) Iterate through top 70 rows where the sky is. Use functions polyfit and .
6) Iterate through each color individually.
7) The polynomial approximation needs each row as a double vector.
8) Compute a synthetic row.
9) Put the row into the new sky.
10) End the loops
11) Show the new image.
12) Show the old image.
Here is the code:
function imageManip(imageName)
inputImage = imread(imageName);
[sizeX,sizeY,~] = size(inputImage);
copyImage = inputImage;
for r = 1:70
for co = 1:3
var1 = 1:sizeY;
var2 = copyImage(r,:,co);
P = polyfit(var1,var2,2);
Y = polyval(P,var1);
copyImage(r,:,co) = Y;
end
end
imshow(copyImage);
end
When I run the code, the following errors appear:
Error using polyfit (line 68)
MTIMES (*) is not fully supported for integer classes. At least one argument must be
scalar.
Error in project2_1 (line 10)
P = polyfit(var1,var2,2);
Can someone explain how I can fix this? Thanks.