Vingetting an image using loop

조회 수: 2 (최근 30일)
Yogesh Bhambhwani
Yogesh Bhambhwani 2020년 11월 13일
댓글: Subhadeep Koley 2020년 11월 14일
This is my work below I keep getting a black image for my vinColor. Any suggestions?
Color = imread('sunflower.jpg');
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)
  댓글 수: 4
KSSV
KSSV 2020년 11월 14일
If you want to get the max..you have to store the d values in to an array.
for y=1:h
d(y) = sqrt((x-Center(1))^2+(y-Center(2))^2);
end
D = max(d) ;
Yogesh Bhambhwani
Yogesh Bhambhwani 2020년 11월 14일
okay but I need to take that max and divide it by all of the values d how would I do that?

댓글을 달려면 로그인하십시오.

채택된 답변

Subhadeep Koley
Subhadeep Koley 2020년 11월 14일
Hope this works.
colorImg = im2double(imread('kobi.png'));
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
Yogesh Bhambhwani
Yogesh Bhambhwani 2020년 11월 14일
It gives me the error
Undefined function 'montage' for input arguments of type 'cell'.
Subhadeep Koley
Subhadeep Koley 2020년 11월 14일
That's just for visualization. You can use imshow too, like below.
colorImg = im2double(imread('kobi.png'));
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)

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Display Image에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by