Create a grid on an image

2 次查看(过去 30 天)
Alber
Alber 2020-7-3
Hello, this is my code:
for P = shaping
% Position beacon
img(1:n, 1:n,1+flag) = 255;
img(end-n:end, end-n:end,1+flag) = 255;
img(1:n, end-n:end,1+flag) = 255;
img(end-n:end,1:n,1+flag) = 255;
% We add the information only on the blue channel and add beacon
encodedBuffer(:,:,:,index) = frameBuffer(:,:,:,index);
encodedBuffer(:,:,3,index) = encodedBuffer(:,:,3,index) + ...
P*codeImage+img(:,:,1+flag);
index = index + 1;
end
I want to create some beacons on an image I have created, in which every time I enter this function (this loop belongs to a function) the value of flag will be changed to negative flag. Initially flag is 0. It creates the 4 squares inside the image but instead of being red or green it becomes blue (the image I'm adding it to is blue).

回答(1 个)

Image Analyst
Image Analyst 2020-7-3
You forgot to attach your image or screenshot. And you forgot to tell us what shaping and flag are. But it looks like this loop only adds to the blue channel so the red and green channel will stay as they were. To get it to show up as blue, you can't let the red and green stay as they were or else you'll just get a blue tint to the image. If you want pure blue you will have to set the red and green channels to zero in the same locations where you set the blue channel to 255.

类别

Help CenterFile Exchange 中查找有关 Convert Image Type 的更多信息

标签

产品


版本

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by