# Vingetting an image using loop

2 views (last 30 days)
Yogesh Bhambhwani on 13 Nov 2020
Commented: Subhadeep Koley on 14 Nov 2020
This is my work below I keep getting a black image for my vinColor. Any suggestions?
Center = size(Color)/2+.5;
[l,h,~] = size(Color);
for x=1:l
for y=1:h
d = sqrt((x-Center(1))^2+(y-Center(2))^2);
end
D = 246.9261
r = d./D
end
imshow(Color)
VinColor = Color .* (1-r.^2);
figure(2)
imshow(VinColor)
Yogesh Bhambhwani on 14 Nov 2020
okay but I need to take that max and divide it by all of the values d how would I do that?

Subhadeep Koley on 14 Nov 2020
Hope this works.
center = size(colorImg)/2+.5;
[l,h,~] = size(colorImg);
d = zeros(l, h);
for x=1:l
for y=1:h
d(x, y) = sqrt((x-center(1))^2+(y-center(2))^2);
end
end
D = max(d);
r = d./D;
vinColor = colorImg .* (1-r.^2);
figure
montage({colorImg, vinColor})
##### 2 CommentsShowHide 1 older comment
Subhadeep Koley on 14 Nov 2020
That's just for visualization. You can use imshow too, like below.
center = size(colorImg)/2+.5;
[l,h,~] = size(colorImg);
d = zeros(l, h);
for x=1:l
for y=1:h
d(x, y) = sqrt((x-center(1))^2+(y-center(2))^2);
end
end
D = max(d);
r = d./D;
vinColor = colorImg .* (1-r.^2);
figure
imshow(colorImg)
figure
imshow(vinColor)