简体   繁体   English

在Matlab中复制图像的问题

[英]Trouble with Copying Image in Matlab

I have written Matlab code to perform the following steps: 我已经编写了Matlab代码来执行以下步骤:

  1. Read the original cottage picture. 阅读原始的小屋图片。
  2. Obtain its sizes. 获得其大小。
  3. Show the x values for the curve fitting. 显示曲线拟合的x值。
  4. Make a copy of the original picture. 复印原始图片。
  5. Iterate through top 70 rows where the sky is. 遍历天空的前70行。 Use functions polyfit and . 使用函数polyfit和。
  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. 显示旧图像。

I have tested and debugged it and it appears that the part of the code that copies the input image is not working. 我已经对其进行了测试和调试,看来复制输入图像的部分代码无法正常工作。 Here is the code: 这是代码:

function (imageName) 

inputImage = imread(imageName);
[sizeX,sizeY,~] = size(inputImage);
copyImage = ones(sizeX,sizeY,3);
for i=1:sizeX
    for j=1:sizeY
        for d=1:3
            copyImage(i,j,d)= inputImage(i,j,d);
        end
    end
end   
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  

Can anyone tell me what is wrong with how I am copying the input image? 谁能告诉我我复制输入图像的方式出了什么问题? Thanks. 谢谢。

这是数字格式的问题,在显示之前将其更改为uint8:

imshow(uint8(copyImage));

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM