Phụ lục
317
blue = double(a(:,:,3));
[u,s,v] = svds(red, singvals);
imred = (u * s * transpose(v));
[u,s,v] = svds(green, singvals);
imgreen = (u * s * transpose(v));
[u,s,v] = svds(blue, singvals);
imblue = (u * s * transpose(v));
im(:,:,1) = imred;
im(:,:,2) = imgreen;
im(:,:,3) = imblue;
imwrite(im, outfile);
figure('Name','Output image');
imshow(im);
return;
end
end
if isgray(a)
dvalue=double(a);
[u,s,v] = svds(dvalue, singvals);
if isa(a,'uint8')
im = uint8(u * s * transpose(v));
end
if isa(a,'uint16')
im = uint16(u * s * transpose(v));
end
if isa(a,'double')
im = (u * s * transpose(v));
end
imwrite(im, outfile);
figure('Name','Output image');
imshow(im);
return;
end