how to change the interior pixel of a closed boundary surface to a different pixel using MATLAB?
Mostra commenti meno recenti
I have a closed boundary surface of an object. i want to fill the interior which is already zero. How can i change the zero to any other digit so that i can do some mathematical operations. Regards for all cooperation of community members.
i have used the following code to handle it but i couldnt figure out.
A = load('Boundary_closed_1s_3s.txt')
Perimeter=bwperim(A)
interior_filled = imfill(A,'holes')
A = 3*double(A)
interior_filled = 2*double(interior_filled)
interior_filled(Perimeter)=A(Perimeter)
The above code is giving me the closed boundary surface? Could anyone guide me how to replace the interior that is already filled as zero but i want to repalce with another number number like 2.
Thanks for all guidance in advance.
1 Commento
Image Analyst
il 7 Feb 2021
The shape is not closed. See the apex at the left. Do you want to close it, like with bwconvhull()?

Risposta accettata
Più risposte (4)
Walter Roberson
il 5 Feb 2021
1 voto
fill the holes. subtract the original, and what is left will be the interiors. Multiply by constant and add to the original.
1 Commento
M.S. Khan
il 5 Feb 2021
yanqi liu
il 5 Feb 2021
clear all; clc; close all;
A = load('Boundary_closed_1s_3s.txt');
b = im2bw(A);
b = imclose(b, strel('disk', 3));
b2 = imfill(b, 'holes');
b3 = logical(b2 - b);
A2 = im2uint8(mat2gray(A));
A2(b3) = 128;
figure;
imshowpair(A,A2,'montage');

please use different value, such as 64,100,128,……
1 Commento
M.S. Khan
il 5 Feb 2021
yanqi liu
il 5 Feb 2021
sir,may be use the follow code
clear all; clc; close all;
A = load('Boundary_closed_1s_3s.txt');
b = im2bw(A);
b = imclose(b, strel('line', 3, -45));
b2 = imfill(b, 'holes');
b3 = logical(b2 - b);
A2 = im2uint8(mat2gray(A));
A2(b) = 0;
A2(b3) = 128;
figure;
imshowpair(A,A2,'montage');

Categorie
Scopri di più su Graphics Performance in Centro assistenza e File Exchange
Prodotti
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
