【发布时间】:2021-03-15 19:55:03
【问题描述】:
这行代码bloop(rj,cj) = J1(i,j) 有问题。我尝试了很多并更改了数字,但错误仍然存在。
错误是 位置 2 的索引超出数组范围
bloop(rj,cj) = J1(i,j).
我希望有人能解决这个问题。
clc
clear
close all
J = imread('logo.jpg'); %discolored image
J1 = im2double(J); %convert image to bouble precise
[r,c] = size(J1); %find size of image
rc = r*c; %151874
%find A inverse
x = [17;121;171];
xT = x';
xxT = x*xT;
inv = pinv(xxT); %find inverse for singular or badly scaled
y = [17;122;114];
yxT = y*xT;
Ainv = yxT*inv;
B = Ainv;
%find color correction
%reshape matrix to 3xn
i = 0;
j = 0;
bloop=zeros(3,50625);
for rj = 1:3 %row
i = i+1;
for cj = 1:50625 %cols
j = j+1;
bloop(rj,cj) = J1(i,j);
end
end
[w,t] = size(bloop);
bloop(:,:)
%I(r,c) = BJ(r,c)color correction equation
I = B*bloop;
【问题讨论】:
-
你的图片是 3x50625 吗?
-
是的,它的 3x50625
-
简单地使用reshape函数改变它的大小
标签: arrays matlab image-processing matrix reshape