cant display my new image
조회 수: 2 (최근 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개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Get Started with MATLAB에 대해 자세히 알아보기
제품
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!