how can solve this error?
조회 수: 1 (최근 30일)
이전 댓글 표시
hi
i used this code
a=imread('6.jpg');
b= imread('text.png');
% b=im2bw(a);
[x y]=size(a);
a1=imresize(b,[x y]);
b1=zeros(x,y,'uint8');
for i=1:x
for j=1:y
b1(i,j)= a1(i,j)+a(i,j);
end
end
figure;imshow(a),title('first image')
figure;imshow(b),title('second image')
figure;imshow(b1),title('after add')
but it give me the error
Error using +
Integers can only be combined with integers of the same class, or scalar doubles.
how solve it?
댓글 수: 0
답변 (1개)
James Long
2019년 1월 31일
can you attach a screenshot of the variable types?
it looks like you are trying to add a variable of type double to a variable of type unit8 or something along those lines. also, try to not designate the memory for b1 as type unit8 first. Rather, create b1 in the nested for-loop THEN change the variable type after the foor loop executes.
Also, this may help: https://www.mathworks.com/help/matlab/ref/typecast.html
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!