Add clouds to cloudless remote sensing images

A=0.9                          %大气光
for m = 1:261
    a = imread(sprintf('%s%d%s','H:\数据集\自制数据集\分解tif\',m-1,'.png'));
    b = imread(sprintf('%s%d%s','H:\数据集\不同地形(青岛\test\分解\',m-1,'.png'));

    a1=a(:,:,1);
    a2=a(:,:,2);
    a3=a(:,:,3);
    b1=b(:,:,1);
    b2=b(:,:,2);
    b3=b(:,:,3);

    for i=1:512
        for j=1:512
            if a1(i,j)<5
                a1(i,j)=0;
            end
        end
    end
    for i=1:512
        for j=1:512
            if a2(i,j)<5
                a2(i,j)=0;
            end
        end
    end
    for i=1:512
        for j=1:512
            if a3(i,j)<5
                a3(i,j)=0;
            end
        end
    end
    a1=double(a1)/255;
    a2=double(a2)/255;
    a3=double(a3)/255;
    b11=double(b1)/255;
    b22=double(b2)/255;
    b33=double(b3)/255;

    b11=b11.*(1-a1)+A.*a1;
    b22=b22.*(1-a2)+A.*a2;
    b33=b33.*(1-a3)+A.*a3;

    b11=uint8(b11*255);
    b22=uint8(b22*255);
    b33=uint8(b33*255);

    c(:,:,1)=b11;
    c(:,:,2)=b22;
    c(:,:,3)=b33;
    imwrite(c,sprintf('%s%d%s','H:\数据集\不同地形(青岛\test\合成\',m-1,'.png'));
end

All are three-channel images. The cloud image is the area with the sea surface in the background.

Guess you like

Origin blog.csdn.net/qq_41872271/article/details/108704677