How to change pixel value of boundary pixel?
3 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
Hi, I need to change the boundary pixel into value ('2') of my binary image, How can I do this?. After that, I need to do some operation on the internal line (junction). Thanks
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/157520/image.jpeg)
0 Commenti
Risposta accettata
Image Analyst
il 25 Feb 2014
Modificato: Image Analyst
il 25 Feb 2014
It won't be binary if you set a value of 2. Binary images are only true/false, or 1/0 if viewing as a number. However if you use an int32, uint8, or double image you can set the edges to 2. Assuming your definition of boundary is the top and bottom lines and the left and right columns, you can do this:
grayImage(:,1) = 2;
grayImage(:,end) = 2;
grayImage(1,:) = 2;
grayImage(end,:) = 2;
If, instead, you want to set the white pixels of the image to 2, assuming you can do this
binaryImage = grayImage > 0; % All white pixels.
grayImage(binaryImage) = 2; % Change from 1 or 255 or whatever, into 2.
1 Commento
M.S. Khan
il 19 Ago 2019
Hi Community members;
i want to repeat the same question.
if i want to keep the boundary of closed binary image as 1 but want to fill the interior with any other number using imfil(bW,'holes').
Please anyone can help me.
Regards and greetings
Più risposte (0)
Vedere anche
Categorie
Scopri di più su Image Processing and Computer Vision in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!