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!