cant display my new image
1 次查看(过去 30 天)
显示 更早的评论
hello,
i have an excericse ;
i have a little pic of mozart and a big one. i seperated my big pic into 30 pieces and replaced them with the small one, now i cant show my image. can any1 help please?
a=imread('smallMozart.tiff'); # the size is 38x25
b=imread('bigMozart.tiff'); # the size is 1140x750
disp(size(b));
disp(size(a));
c=mat2cell(b,[38,38,38,38,38,38,38,38,38,38,38,38,38,38,38,38,38,38,38,38,38,38,38,38,38,38,38,38,38,38],[25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25]);
for i=1:30
for j=1:30
c{i,j}=a;
end
end
imshow(c)
thanks
1 个评论
Jan
2021-4-10
编辑:Jan
2021-4-10
You get an error message, if you provide a cell array to the imshow command. Then it i useful to share the message with the readers. It is easier to solve a problem than to guess, what the problem is.
Why do you create c by mat2cell only to overwrite it immediately?
Avoid monsters as:
c=mat2cell(b,[38,38,38,38,38,38,38,38,38,38,38,38,38,38,38,38,38,38,38,38,38,38,38,38,38,38,38,38,38,38],[25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25]);
Easier to read:
c = mat2cell(b, repmat(38, 1, 30), repmat(25, 1, 30));
You can simplify:
for i=1:30
for j=1:30
c{i,j}=a;
end
end
to:
c(:) = {a};
采纳的回答
Jan
2021-4-10
imshow does not accept cell arrays as input. It needs a matrix.
Either create this matrix directly:
d = repmat(a, 30, 30);
or join the cell elements:
d = cell2mat(c);
更多回答(0 个)
另请参阅
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!