Question about for loops and immultiply
Show older comments
I wanted to edit a zeros matrix with a certain pattern of some various function, for this argument lets say that the function is a square (any geometrical pattern should be the same method?) I also wanted to implement immultiply, except i get a whitespace... Without using a for loop as such:
Z = zeros(800,600);
for m=275:325
for n=375:425
Z(m,n,:)=1
end
end
Is = immultiply(Id,Z); imshow(Is);
How do i go about it? because the for loop takes like 15 minutes..
for example I can make a diamond looking square but idk know a regular square equation at the center
[M N]= size(Id);
X=0:N-1;
Y=0:M-1;
[X Y]=meshgrid(X,Y);
Cx=0.5*N;
Cy=0.5*M;
square = (abs(X-Cx)/25+abs(Y-Cy)/25)
imshow(square)
figure
Is = immultiply(Id, square); imshow(Is);
Thanks, Benjy
1 Comment
Accepted Answer
More Answers (0)
Categories
Find more on Image Arithmetic in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!