Labfans是一个针对大学生、工程师和科研工作者的技术社区。 论坛首页 | 联系我们(Contact Us)
MATLAB爱好者论坛-LabFans.com
返回   MATLAB爱好者论坛-LabFans.com > 其它 > 资料存档
资料存档 资料存档
回复
 
主题工具 显示模式
旧 2019-12-14, 20:13   #1
poster
高级会员
 
注册日期: 2019-11-21
帖子: 3,006
声望力: 66
poster 正向着好的方向发展
帖子 linsolve中的错误

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');

更多&回答...
poster 当前离线   回复时引用此帖
回复


发帖规则
不可以发表新主题
不可以发表回复
不可以上传附件
不可以编辑自己的帖子

启用 BB 代码
论坛禁用 表情符号
论坛启用 [IMG] 代码
论坛启用 HTML 代码



所有时间均为北京时间。现在的时间是 20:42


Powered by vBulletin
版权所有 ©2000 - 2025,Jelsoft Enterprises Ltd.