Labfans是一个针对大学生、工程师和科研工作者的技术社区。 | 论坛首页 | 联系我们(Contact Us) |
![]() |
|
![]() |
#1 |
高级会员
注册日期: 2019-11-21
帖子: 3,006
声望力: 66 ![]() |
![]()
A=imread('lena_color.jpg'); x1=2.1; b=A*x1; b=double(b); x1=double(x1); opts.UT = true; opts.TRANSA = false; A1 = linsolve(x1,b,opts); figure; imshow(A1); 这给出:
error >>??? Error using ==> linsolve First and second arguments must be single or double. Error in ==> test at 9 A1= linsolve(b,x1,opts); 请帮助解决此问题。 还有其他方法可以解决等式形式为Eq1= A*2.1 + B*3.5 +C*1.5的方程式吗? 回答: 我认为问题在于尺寸,而不是参数。以下代码对我有用: % you can switch it with your own image after you see it works I = imread('cameraman.tif'); A = im2double(I); % scalar*matrix works in matlab commandline, % but needs to be defined when it comes to equations x1=2.1*eye(size(A)); b=A*x1; opts.UT = true; opts.TRANSA = false; A1 = linsolve(x1,b,opts); figure; imshow(A1); [编辑] @SKM和@gary,这是详细的解决方案(对于RGB情况): % example for RGB image Img= im2double( imread('peppers.png') ); Dim = size(Img, 3); % transform the original image, % by multiplying every color channel by different scalar. % that is going to be a very red image... a = [1 0.5 0.2]; aMat = []; newImg = []; for Ind=1:Dim aMat(:, :, Ind) = a(Ind)*eye( size(Img, 1), size(Img, 2) ); newImg(:, :, Ind) = a(Ind)*squeeze(Img(:, :, Ind)); end % recontructing original image recontrcutedImg=[]; for Ind=1:Dim recontrcutedImg(:, :, Ind) = linsolve( aMat(:, :, Ind), newImg(:, :, Ind) ); end % show the images figure; subplot(1, 3, 1); imagesc(Img); title('original'); subplot(1, 3, 2); imagesc(newImg); title('changed image'); subplot(1, 3, 3); imagesc(recontrcutedImg); title('reconstructed image'); 更多&回答... |
![]() |
![]() |