error using zeros Size inputs must be integers.

please help im having this trouble (Error using zeros Size inputs must be integers.)
F = imread("E:\PELAJAR\Unnes\PC\citra-grayscale2.jpg");
[tinggi, lebar] = size(F);
sudut = 45; % Sudut pemutaran
rad = pi * sudut/180;
cosa = cos(rad);
sina = sin(rad);
x11 = 1; y11 = 1;
x12 = lebar; y12 = 1;
x13 = lebar; y13 = tinggi;
x14 = 1; y14 = tinggi;
m = floor(tinggi/2);
n = floor(lebar/2);
% Menentukan pojok
x21 = ((x11-n) * cosa + (y11-m) * sina + n);
y21 = ((y11-m) * cosa - (x11-n) * sina + m);
x22 = ((x12-n) * cosa + (y12-m) * sina + n);
y22 = ((y12-m) * cosa - (x12-n) * sina + m);
x23 = ((x13-n) * cosa + (y13-m) * sina + n);
y23 = ((y13-m) * cosa - (x13-n) * sina + m);
x24 = ((x14-n) * cosa + (y14-m) * sina + n);
y24 = ((y14-m) * cosa - (x14-n) * sina + m);
ymin = min([y21 y22 y23 y24]);
xmin = min([x21 x22 x23 x24]);
ymak = max([y21 y22 y23 y24]);
xmak = max([x21 x22 x23 x24]);
lebar_baru = xmak - xmin + 1;
tinggi_baru = ymak - ymin + 1;
tambahan_y = floor((tinggi_baru-tinggi)/2);
tambahan_x = floor((lebar_baru-lebar)/2);
F2=zeros(tinggi_baru, lebar_baru);
for y=1 : tinggi
for x=1 : lebar
F2(y+tambahan_y, x+tambahan_x) = F(y, x);
end
end
figure(1);
imshow( uint8(F2));
% Putar citra
m = floor(tinggi_baru/2);
n = floor(lebar_baru/2);
for y=1 : tinggi_baru
for x=1 : lebar_baru
x2 = round((x-n) * cosa + (y-m) * sina + n);
y2 = round((y-m) * cosa - (x-n) * sina + m);
if (x2>=1) && (x2<=lebar_baru) && ...
(y2>=1) && (y2<=tinggi_baru)
G(y, x) = F2(y2,x2);
else
G(y,x) = 0;
end
end
end
figure(2);
G = uint8(G);
imshow(G);
clear all;
Error using zeros
Size inputs must be integers.

 채택된 답변

KSSV
KSSV 2022년 3월 21일

0 개 추천

Replace this line:
F2=zeros(tinggi_baru, lebar_baru);
with:
F2=zeros(fix(tinggi_baru), fix(lebar_baru));

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Mathematics and Optimization에 대해 자세히 알아보기

제품

릴리스

R2021b

질문:

2022년 3월 21일

댓글:

2022년 3월 21일

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by