Why did the image duplicated 3 times?

4 ビュー (過去 30 日間)
Shu Yi Ho
Shu Yi Ho 2019 年 8 月 13 日
コメント済み: stanley Nwade 2020 年 10 月 12 日
How do I make it to display only once instead of 3 times for "after adjusting brightness" & "number of circles detected"?
[x,y] = size(ori_roi{i});
%%Replace each pixel of the image
for a=1:1:x
for b=1:1:y
C(a,b) = ori_roi{i}(a,b) + imageBrightness;
end
end

採用された回答

Geoff Hayes
Geoff Hayes 2019 年 8 月 13 日
編集済み: Geoff Hayes 2019 年 8 月 13 日
Shu - it looks like your original image is in colour so consider this line of code
[x,y] = size(ori_roi{i});
i suspect that y is three times what it should be...and so your image is replicated three times. For example,
Z = randi(255,100,50,3);
[x y] = size(Z);
Where x is 100 (correct) but y is 150 (incorrect!). And so the code
for a=1:1:x
for b=1:1:y
C(a,b) = Z(a,b) + 0;
end
end
creates C which is a 100x150 array.
To fix you can use
[x y, ~] = size(ori_roi{i});
so that the third dimension is ignored and your x and y should now be the correct height and width of your original image.
  1 件のコメント
stanley Nwade
stanley Nwade 2020 年 10 月 12 日
This was very useful. Thanks

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeGet Started with Image Processing Toolbox についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by