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 件のコメント

Geoff Hayes
Geoff Hayes 2020 年 11 月 14 日
Yogesh - I don't understand the code within your loops. For example,
for y=1:h
d = sqrt((x-Center(1))^2+(y-Center(2))^2);
end
you replace the d calculated on subsequent iterations with the d calculated on the current iteration. Is this an oversight? Don't you want to somehow include the previous iteration calculations? Similarly, in
D = 246.9261
r = d./D
you overwrite the r that has been caculated on the previous iteration of the outer for loop. Is this intentional? How should the "historical" values be used in your calculations?
Yogesh Bhambhwani
Yogesh Bhambhwani 2020 年 11 月 14 日
I did that since I wanted to find the max d and divide it by all of the d values and to do that I had to include it in the loop others wise it would only divide by the max d and not the other values.
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 日

0 投票

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 件)

カテゴリ

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by