how can solve this error?
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
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 Kommentare
Antworten (1)
James Long
am 31 Jan. 2019
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 Kommentare
Siehe auch
Kategorien
Mehr zu Image Processing Toolbox finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!