Why do I write as Ib(1:478,31:565)(~BW) = 255
Show older comments
Ib(1:478,31:565)(~BW) = 255
Ib is a gray image. I want to set a fixed black region as blue, but this code is wrong.
Do we have simple method to finish it?
Accepted Answer
More Answers (1)
Walter Roberson
on 26 Feb 2025
Edited: Walter Roberson
on 26 Feb 2025
temp = Ib(1:478,31:565,:);
temp(~repmat(BW,1,1,ndims(temp))) = 255;
Ib(1:478,31:565,:) = temp;
3 Comments
xie
on 27 Feb 2025
Walter Roberson
on 27 Feb 2025
Ib = randi([0 255], 500, 600, 3, 'uint8');
temp = Ib(1:478,31:565,:);
BW = rand(size(temp,1), size(temp,2)) > 0.8;
temp(~repmat(BW,1,1,size(temp,3))) = 255;
Ib(1:478,31:565,:) = temp;
xie
on 27 Feb 2025
Categories
Find more on Contrast Adjustment in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!






