I want to use a character in for loop but I can't because I'm using ginput function and it's possible to first and end pixel in for loop changed by every mouse click I cant use an exact pixel it's my error when run my code.
Subscript indices must either be real positive integers or logicals.
A=imread('peppers.png');
C=imshow(A);
F=rgb2gray(A);
figure,imshow(F)
B=ginput(4)
a=min(B);
b=max(B);
a1=a(1)
a2=a(2)
b1=b(1)-a(1)
b2=b(2)-a(2)
for i=a1:a1+b1
for j=a2:a2+b2
F(j,i)=0;
end
end
figure,imshow(F)
F(a1:a1+b1,a2:a2+b2)=0fully replaces the two loops and is faster.